|
1 | 1 | --- |
2 | | -title: Block T-SQL Commands to Create or Modify Azure SQL Resources |
3 | | -description: This article details a feature allowing Azure administrators to block T-SQL commands to create or modify Azure SQL resources |
| 2 | +title: Block T-SQL Commands To Create Or Modify Azure SQL Resources |
| 3 | +description: This article details features allowing Azure administrators to block T-SQL commands to create or modify Azure SQL Database and Azure SQL Managed Instance resources. |
4 | 4 | author: WilliamDAssafMSFT |
5 | 5 | ms.author: wiassaf |
6 | 6 | ms.reviewer: wiassaf, mathoma |
7 | | -ms.date: 06/13/2025 |
8 | | -ms.service: azure-sql-database |
| 7 | +ms.date: 03/10/2026 |
| 8 | +ms.service: azure-sql |
9 | 9 | ms.subservice: security |
10 | 10 | ms.topic: how-to |
11 | 11 | ROBOTS: NOINDEX |
12 | 12 | monikerRange: "=azuresql || =azuresql-db " |
13 | 13 | ms.custom: sfi-image-nochange |
14 | 14 | --- |
15 | 15 |
|
16 | | -# What is Block T-SQL CRUD feature? |
| 16 | +# What is Block T-SQL CRUD? |
17 | 17 |
|
18 | | -[!INCLUDE[appliesto-sqldb](../includes/appliesto-sqldb.md)] |
| 18 | +[!INCLUDE[appliesto-sqldb-sqlmi](../includes/appliesto-sqldb-sqlmi.md)] |
19 | 19 |
|
20 | | -This feature allows Azure administrators to block the creation or modification of Azure SQL Database resources through T-SQL. This is enforced at the subscription level to block T-SQL commands from affecting Azure SQL Database resources. |
| 20 | +The Block T-SQL CRUD features allow Azure administrators to block the creation or modification of Azure SQL resources through T-SQL. Two separate subscription-level preview feature flags are available: |
21 | 21 |
|
22 | | -## Overview |
23 | | - |
24 | | -To block creation or modification of resources through T-SQL and enforce resource management through an Azure Resource Manager template (ARM template) for a given subscription, the subscription level preview features in Azure portal can be used. This is particularly useful when you are using [Azure Policies](/azure/governance/policy/overview) to enforce organizational standards through ARM templates. Since T-SQL does not adhere to Azure Policies, a block on T-SQL create or modify operations can be applied. The syntax blocked includes CRUD (create, update, delete) operations for databases in Azure SQL Database. |
25 | | - |
26 | | -T-SQL CRUD operations can be blocked via Azure portal, [PowerShell](/powershell/module/az.resources/register-azproviderfeature), or [Azure CLI](/cli/azure/feature#az-feature-register). |
| 22 | +| Preview feature flag | Scope | |
| 23 | +| --- | --- | |
| 24 | +| **Block T-SQL CRUD for logical servers** (`block-tsql-crud`) | Azure SQL Database (logical server) | |
| 25 | +| **Block T-SQL CRUD for managed instances** (`block-tsql-mi-crud`) | Azure SQL Managed Instance | |
27 | 26 |
|
28 | | -## Blocked statements |
| 27 | +Each flag is registered independently per subscription. You can enable one or both depending on which Azure SQL services you need to govern. |
29 | 28 |
|
30 | | -The following T-SQL statements are blocked when this feature is enabled: |
| 29 | +## Overview |
31 | 30 |
|
32 | | -1. `CREATE DATABASE` statements |
33 | | -1. `DROP DATABASE` statements |
34 | | -1. A subset of `ALTER DATABASE` statements, as follows: |
35 | | - - `ALTER DATABASE ... ADD SECONDARY ON SERVER` |
36 | | - - `ALTER DATABASE ... REMOVE SECONDARY ON SERVER` |
37 | | - - `ALTER DATABASE ... FAILOVER` |
38 | | - - `ALTER DATABASE ... MODIFY NAME ...` |
39 | | - - `ALTER DATABASE ... MODIFY (MAXSIZE | EDITION | SERVICE_OBJECTIVE ...)` |
40 | | - - `ALTER DATABASE ... MODIFY BACKUP_STORAGE_REDUNDANCY ...` |
41 | | - - `ALTER DATABASE ... SET ENCRYPTION ...` |
| 31 | +To block creation or modification of resources through T-SQL and enforce resource management through an Azure Resource Manager template (ARM template) for a given subscription, the subscription-level preview features in the Azure portal can be used. This is particularly useful when you are using [Azure Policies](/azure/governance/policy/overview) to enforce organizational standards through ARM templates. Since T-SQL does not adhere to Azure Policies, a block on T-SQL create or modify operations can be applied. |
| 32 | + |
| 33 | +T-SQL CRUD operations can be blocked via the Azure portal, [PowerShell](/powershell/module/az.resources/register-azproviderfeature), or [Azure CLI](/cli/azure/feature#az-feature-register). |
| 34 | + |
| 35 | +## Blocked statements for Azure SQL Database |
| 36 | + |
| 37 | +When the **Block T-SQL CRUD for logical servers** (`block-tsql-crud`) preview feature is registered, the following T-SQL statements are blocked for Azure SQL Database resources: |
| 38 | + |
| 39 | +1. `CREATE DATABASE` |
| 40 | +1. `DROP DATABASE` |
| 41 | +1. `CREATE DATABASE ... AS COPY OF` |
| 42 | +1. `ALTER DATABASE` (edition, service objective, max size, etc.) |
| 43 | +1. `ALTER DATABASE ... ADD SECONDARY ON SERVER` |
| 44 | +1. `ALTER DATABASE ... REMOVE SECONDARY ON SERVER` |
| 45 | +1. `ALTER DATABASE ... FAILOVER` |
| 46 | + |
| 47 | +## Blocked statements for Azure SQL Managed Instance |
| 48 | + |
| 49 | +When the **Block T-SQL CRUD for managed instances** (`block-tsql-mi-crud`) preview feature is registered, the following T-SQL statements are blocked for Azure SQL Managed Instance resources: |
| 50 | + |
| 51 | +1. `CREATE DATABASE` |
| 52 | +1. `DROP DATABASE` |
| 53 | +1. Cancel in-progress `CREATE DATABASE` |
| 54 | +1. `RESTORE DATABASE ... FROM URL` |
| 55 | +1. `ALTER DATABASE ... ADD FILE` |
| 56 | +1. `ALTER DATABASE ... MODIFY FILE` |
| 57 | +1. `ALTER DATABASE ... REMOVE FILE` (on geo-replicated file) |
| 58 | +1. `ALTER DATABASE tempdb ADD FILE` |
| 59 | +1. `ALTER DATABASE tempdb MODIFY FILE` |
| 60 | +1. `ALTER DATABASE tempdb REMOVE FILE` |
| 61 | +1. `ALTER DATABASE ... SET` (compatibility level, collation, etc.) |
| 62 | +1. `ALTER DATABASE ... SET ENCRYPTION ON/OFF` |
| 63 | +1. `ALTER AVAILABILITY GROUP ... FAILOVER` (MI Link / Failover Group) |
| 64 | +1. Failover stored procedure configuration |
| 65 | +1. `DBCC TRACEON` / `DBCC TRACEOFF` (global trace flags) |
| 66 | +1. `sp_configure` (SQL Agent enable/disable) |
| 67 | +1. `sp_configure` / MSDTC transition to primary |
| 68 | +1. MSDTC network settings (XA, LU, inbound/outbound) |
| 69 | +1. Vulnerability Assessment scan trigger via T-SQL |
42 | 70 |
|
43 | 71 | ## Permissions |
44 | 72 |
|
45 | | -In order to register or remove this feature, the Azure user must be a member of the Owner or Contributor role of the subscription. |
| 73 | +In order to register or remove either feature, the Azure user must be a member of the Owner or Contributor role of the subscription. |
46 | 74 |
|
47 | 75 | ## Examples |
48 | 76 |
|
49 | | -The following section describes how you can register or unregister a preview feature with Microsoft.Sql resource provider in Azure portal: |
50 | | - |
51 | | -### Register Block T-SQL CRUD |
| 77 | +The following section describes how you can register or unregister a preview feature with the Microsoft.Sql resource provider in the Azure portal. |
52 | 78 |
|
53 | | -1. Go to your subscription on Azure portal. |
54 | | -1. Select the **Preview Features** tab. |
55 | | -1. Select **Block T-SQL CRUD**. |
56 | | -1. After you select **Block T-SQL CRUD**, a new window will open, select **Register**, to register this block with Microsoft.Sql resource provider. |
| 79 | +### Register a Block T-SQL CRUD feature |
57 | 80 |
|
58 | | -:::image type="content" source="media/block-crud-tsql/block-tsql-crud.png" alt-text="Screenshot of the Azure portal showing how to select 'Block T-SQL CRUD' in the list of Preview Features." lightbox="media/block-crud-tsql/block-tsql-crud.png"::: |
| 81 | +1. Go to your subscription in the Azure portal. |
| 82 | +1. Select the **Preview Features** tab. |
| 83 | +1. Select the feature flag you want to enable: |
| 84 | + - **Block T-SQL CRUD for logical servers** — for Azure SQL Database |
| 85 | + - **Block T-SQL CRUD for managed instances** — for Azure SQL Managed Instance |
| 86 | +1. In the window that opens, select **Register** to register this block with the Microsoft.Sql resource provider. |
59 | 87 |
|
60 | 88 | :::image type="content" source="media/block-crud-tsql/block-tsql-crud-register.png" alt-text="With 'Block T-SQL CRUD' checked, select Register." lightbox="media/block-crud-tsql/block-tsql-crud-register.png"::: |
61 | 89 |
|
62 | 90 | ### Re-register Microsoft.Sql resource provider |
63 | 91 |
|
64 | | -After you register the block of T-SQL CRUD with Microsoft.Sql resource provider, you must re-register the Microsoft.Sql resource provider for the changes to take effect. To re-register the Microsoft.Sql resource provider: |
| 92 | +After you register either block feature with the Microsoft.Sql resource provider, you must re-register the Microsoft.Sql resource provider for the changes to take effect. To re-register the Microsoft.Sql resource provider: |
65 | 93 |
|
66 | | -1. Go to your subscription on Azure portal. |
| 94 | +1. Go to your subscription in the Azure portal. |
67 | 95 | 1. Select the **Resource Providers** tab. |
68 | 96 | 1. Search and select **Microsoft.Sql** resource provider. |
69 | | -1. Select **Re-register**. |
| 97 | +1. Select **Re-register**. |
70 | 98 |
|
71 | 99 | > [!NOTE] |
72 | | -> The re-registration step is mandatory for the T-SQL block to be applied to your subscription. |
| 100 | +> The re-registration step is mandatory for the T-SQL block to be applied to your subscription. |
73 | 101 |
|
74 | 102 | :::image type="content" source="media/block-crud-tsql/block-tsql-crud-re-register.png" alt-text="Screenshot of the Azure portal showing how to re-register the Microsoft.Sql resource provider." lightbox="media/block-crud-tsql/block-tsql-crud-re-register.png"::: |
75 | 103 |
|
|
0 commit comments