Skip to content

Commit 1371254

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/sql-docs-pr (branch live)
2 parents 02e5de1 + 9f7430e commit 1371254

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

azure-sql/database/authentication-azure-ad-user-assigned-managed-identity.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn about system assigned and user assigned managed identities in
55
author: VanMSFT
66
ms.author: vanto
77
ms.reviewer: vanto, wiassaf, mathoma
8-
ms.date: 10/24/2023
8+
ms.date: 04/08/2025
99
ms.service: azure-sql
1010
ms.subservice: security
1111
ms.custom: has-azure-ad-ps-ref, azure-ad-ref-level-one-done
@@ -25,7 +25,7 @@ Previously, only an SMI could be assigned to the Azure SQL Managed Instance or S
2525

2626
In addition to using a UMI and an SMI as the instance or server identity, you can use them to access the database by using the SQL connection string option `Authentication=Active Directory Managed Identity`. You need to create a SQL user from the managed identity in the target database by using the [CREATE USER](/sql/t-sql/statements/create-user-transact-sql) statement. For more information, see [Using Microsoft Entra authentication with SqlClient](/sql/connect/ado-net/sql/azure-active-directory-authentication).
2727

28-
To retrieve the current UMI(s) or SMI for Azure SQL Managed instance or Azure SQL Database, see [Get or set a managed identity for a logical server or managed instance](#get-or-set-a-managed-identity-for-a-logical-server-or-managed-instance) later in this article.
28+
To retrieve the current UMIs or SMI for Azure SQL Managed instance or Azure SQL Database, see [Get or set a managed identity for a logical server or managed instance](#get-or-set-a-managed-identity-for-a-logical-server-or-managed-instance) later in this article.
2929

3030
## Benefits of using user-assigned managed identities
3131

@@ -61,6 +61,29 @@ These permissions should be granted before you provision a logical server or man
6161
- [GroupMember.Read.All](/graph/permissions-reference#group-permissions): Allows access to Microsoft Entra group information.
6262
- [Application.Read.ALL](/graph/permissions-reference#application-resource-permissions): Allows access to Microsoft Entra service principal (application) information.
6363

64+
### Permissions for SMI
65+
66+
The same Microsoft Graph applications are needed for the SMI, but the UMI permissions can be eliminated for Azure SQL Database using an SMI. The `CREATE USER` T-SQL syntax would need the `SID` and `TYPE` syntax, as described in the article, [CREATE USER (Transact-SQL)](/sql/t-sql/statements/create-user-transact-sql#syntax).
67+
68+
```syntaxsql
69+
CREATE USER
70+
{
71+
Microsoft_Entra_principal FROM EXTERNAL PROVIDER [ WITH <limited_options_list> [ ,... ] ]
72+
| Microsoft_Entra_principal WITH <options_list> [ ,... ]
73+
}
74+
[ ; ]
75+
76+
<limited_options_list> ::=
77+
DEFAULT_SCHEMA = schema_name
78+
| OBJECT_ID = 'objectid'
79+
<options_list> ::=
80+
DEFAULT_SCHEMA = schema_name
81+
| SID = sid
82+
| TYPE = { X | E }
83+
```
84+
85+
The above syntax allows creation of Microsoft Entra users without validation. For this to work, the `Object Id` of the Microsoft Entra principal would have to be supplied and used as an `SID` in the T-SQL statement, as explained in [Create a contained database user from a Microsoft Entra principal without validation](/sql/t-sql/statements/create-user-transact-sql#k-create-a-contained-database-user-from-a-microsoft-entra-principal-without-validation).
86+
6487
### Grant permissions
6588

6689
The following sample PowerShell script grants the necessary permissions for a managed identity. This sample assigns permissions to the user-assigned managed identity `umiservertest`.
@@ -149,7 +172,7 @@ The Azure portal displays the system-assigned managed identity (SMI) ID in the *
149172

150173
:::image type="content" source="media/authentication-azure-ad-user-assigned-managed-identity/get-system-assigned-managed-identity-azure-sql-server-azure-portal.png" alt-text="Screenshot of the Azure portal page for an Azure SQL Database logical server. In the Properties menu, the System Assigned Managed Identity is highlighted.":::
151174

152-
- To retrieve the UMI(s) for Azure SQL Managed Instance or Azure SQL Database, use the following PowerShell or Azure CLI examples.
175+
- To retrieve the UMIs for Azure SQL Managed Instance or Azure SQL Database, use the following PowerShell or Azure CLI examples.
153176
- To retrieve the SMI for Azure SQL Managed Instance, use the following PowerShell or Azure CLI examples.
154177

155178
### Set a managed identity in the Azure portal
@@ -211,7 +234,7 @@ The Azure CLI 2.26.0 (or later) is required to run these commands with a UMI.
211234
212235
- To provision a new server with a UMI, use the [New-AzSqlServer](/powershell/module/az.sql/new-azsqlserver) command.
213236
- To obtain the managed identities for a logical server, use the [Get-AzSqlServer](/powershell/module/az.sql/get-azsqlserver) command.
214-
- For example, to retrieve the UMI(s) of a logical server, look for the `principalId` of each:
237+
- For example, to retrieve the UMIs of a logical server, look for the `principalId` of each:
215238
216239
```powershell
217240
$MI = Get-AzSqlServer -ResourceGroupName "resourcegroupnamehere" -Name "sql-logical-server-name-here"
@@ -231,7 +254,7 @@ The Azure CLI 2.26.0 (or later) is required to run these commands with a UMI.
231254
232255
- To provision a new managed instance with a UMI, use the [New-AzSqlInstance](/powershell/module/az.sql/new-azsqlinstance) command.
233256
- To obtain the managed identities for a managed instance, use the [Get-AzSqlInstance](/powershell/module/az.sql/get-azsqlinstance) command.
234-
- For example, to retrieve the UMI(s) of a managed instance, look for the `principalId` of each:
257+
- For example, to retrieve the UMIs of a managed instance, look for the `principalId` of each:
235258
236259
```powershell
237260
$MI = Get-AzSqlInstance -ResourceGroupName "resourcegroupnamehere" -Name "sql-mi-name-here"

docs/t-sql/statements/create-user-transact-sql.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: CREATE USER (Transact-SQL)
44
author: VanMSFT
55
ms.author: vanto
66
ms.reviewer: wiassaf, jaszymas
7-
ms.date: 11/20/2024
7+
ms.date: 04/08/2025
88
ms.service: sql
99
ms.subservice: t-sql
1010
ms.topic: reference
@@ -121,8 +121,8 @@ CREATE USER user_name
121121
DEFAULT_SCHEMA = schema_name
122122
| DEFAULT_LANGUAGE = { NONE | lcid | language name | language alias }
123123
| SID = sid
124-
| ALLOW_ENCRYPTED_VALUE_MODIFICATIONS = [ ON | OFF ] ]
125-
124+
| ALLOW_ENCRYPTED_VALUE_MODIFICATIONS = [ ON | OFF ] ]
125+
126126
<limited_options_list> ::=
127127
DEFAULT_SCHEMA = schema_name ]
128128
| ALLOW_ENCRYPTED_VALUE_MODIFICATIONS = [ ON | OFF ] ]
@@ -160,7 +160,7 @@ CREATE USER Microsoft_Entra_principal FROM EXTERNAL PROVIDER
160160
[;]
161161
```
162162

163-
Syntax for [!INCLUDE [fabric-sqldb](../../includes/fabric-sqldb.md)]
163+
Syntax for [!INCLUDE [fabric-sqldb](../../includes/fabric-sqldb.md)] and Azure SQL Database
164164

165165
```syntaxsql
166166
CREATE USER
@@ -274,7 +274,7 @@ CREATE USER user_name
274274
In SQL database in Microsoft Fabric, `sid` should be a valid ID of the specified Microsoft Entra principal. If the principal is a user or a group, the ID should be a Microsoft Entra object ID of the user/group. If the Microsoft Entra principal is a service principal (an application or a managed identity), the ID should be an application ID (or a client ID). The specified ID must be a `binary(16)` value. The [!INCLUDE[ssDE](../../includes/ssde-md.md)] doesn't validate the specified ID in Microsoft Entra. The `SID` argument must be used together with `TYPE`.
275275

276276
#### TYPE = [ E | X ]
277-
**Applies to**: SQL database in Microsoft Fabric.
277+
**Applies to**: SQL database in Microsoft Fabric and Azure SQL Database.
278278

279279
Specifies the type of a Microsoft Entra principal. `E` indicates the principal is a user or a service principal (an application or a managed identity). `X` indicates the principal is a group.
280280

@@ -577,7 +577,7 @@ GO
577577

578578
### K. Create a contained database user from a Microsoft Entra principal without validation
579579

580-
**Applies to**: [!INCLUDE [fabric-sqldb](../../includes/fabric-sqldb.md)]
580+
**Applies to**: [!INCLUDE [fabric-sqldb](../../includes/fabric-sqldb.md)] and Azure SQL Database
581581

582582
The examples in this section create database users for Microsoft Entra principals, without validating principal names in Microsoft Entra.
583583

0 commit comments

Comments
 (0)