You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/azure/sdk/authentication/user-assigned-managed-identity.md
+18-22Lines changed: 18 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ The recommended approach to authenticate an Azure-hosted app to other Azure reso
19
19
20
20
## Create a user-assigned managed identity
21
21
22
-
User-assigned identities are created as standalone resources in your Azure subscription. You can create them using the Azure portal or the Azure CLI.
22
+
User-assigned identities are created as standalone resources in your Azure subscription. You can create them using the Azure portal or the Azure CLI. Azure CLI commands can be run in the [Azure Cloud Shell](https://shell.azure.com) or on a workstation with the [Azure CLI installed](/cli/azure/install-azure-cli).
23
23
24
24
### [Azure portal](#tab/azure-portal)
25
25
@@ -30,30 +30,29 @@ User-assigned identities are created as standalone resources in your Azure subsc
30
30
31
31
1. On the **Create User Assigned Managed Identity** page, select a subscription, resource group, and region for the user-assigned identity, and then provide a name.
32
32
1. Select **Review + create** to review and validate your inputs.
33
-
1. Select **Create** to create the user-assigned identity.
34
33
35
34
:::image type="content" source="../media/user-assigned-identity-form.png" alt-text="A screenshot showing the form to create a user-assigned identity.":::
36
35
36
+
1. Select **Create** to create the user-assigned identity.
37
37
1. After the identity is created, select **Go to resource**.
38
38
1. On the new identity's **Overview** page, copy the `Client ID` value to use for later when you configure the application code.
39
39
40
40
### [Azure CLI](#tab/azure-cli)
41
41
42
-
Azure CLI commands can be run in the [Azure Cloud Shell](https://shell.azure.com) or on a workstation with the [Azure CLI installed](/cli/azure/install-azure-cli).
43
-
44
-
Use the Azure CLI command [`az identity create`](/cli/azure/identity?view=azure-cli-latest#az-identity-create) to create a managed identity for an Azure resource:
42
+
Use the Azure CLI command [`az identity create`](/cli/azure/identity?view=azure-cli-latest#az-identity-create) to create a managed identity:
45
43
46
44
```azurecli
47
45
az identity create --resource-group <resource-group-name> --name <identity-name>
48
46
```
49
47
50
48
The command output prints the following values:
51
-
- **ClientID**: Used to configure application code that uses the identity.
52
-
- **Location**: The Azure region that contains the identity.
53
-
- **Name**: The name of the identity.
54
-
- **PrincipalId**: Used for access control and role assignments in Azure.
55
-
- **ResourceGroup**: The resource group that contains the identity.
56
-
- **TenantId**: The Microsoft Entra tenant that contains the identity.
49
+
50
+
-**ClientID**: Used to configure application code that uses the identity.
51
+
-**Location**: The Azure region that contains the identity.
52
+
-**Name**: The name of the identity.
53
+
-**PrincipalId**: Used for access control and role assignments in Azure.
54
+
-**ResourceGroup**: The resource group that contains the identity.
55
+
-**TenantId**: The Microsoft Entra tenant that contains the identity.
57
56
58
57
---
59
58
@@ -63,25 +62,22 @@ A user-assigned can be associated with one or more Azure resources. All of the r
63
62
64
63
### [Azure portal](#tab/azure-portal)
65
64
66
-
1. In the Azure portal, navigate to the resource that hosts your application code, such as an Azure App Service or Azure Container App instance.
65
+
1. In the Azure portal, navigate to the resource that hosts your app code, such as an Azure App Service or Azure Container App instance.
67
66
1. From the resource's **Overview** page, expand **Settings** and select **Identity** from the navigation.
68
67
1. On the **Identity** page, switch to the **User assigned** tab.
69
68
1. Select **+ Add** to open the **Add user assigned managed identity** panel.
70
69
1. On the **Add user assigned managed identity** panel, use the **Subscription** dropdown to filter the search results for your identities. Use the **Select** search box to locate the user-assigned managed identity you enabled for the Azure resource hosting your app.
70
+
1. Select the identity and choose **Add** at the bottom of the panel to continue.
71
71
72
-
:::image type="content" source="../media/add-user-assigned-identity-to-app.png" alt-text="A screenshot showing the form to create a user-assigned identity.":::
73
-
74
-
1. Select the identity and choose **Select** at the bottom of the panel to continue.
75
-
1. Select **Review + assign** at the bottom of the page.
76
-
1. On the final **Review + assign** tab, select **Review + assign** to complete the workflow.
72
+
:::image type="content" source="../media/add-user-assigned-identity-to-app.png" alt-text="A screenshot showing how to associate a user-assigned identity with an app.":::
77
73
78
74
### [Azure CLI](#tab/azure-cli)
79
75
80
76
The Azure CLI provides different commands to assign a user-assigned identity to different types of hosting services.
81
77
82
-
To assign a user-assigned identity to an Azure App Service web app using the Azure CLI, you'll need the resource ID of the identity. Use the `az identity show` command to retrieve the resource ID:
78
+
To assign a user-assigned identity to an Azure App Service web app using the Azure CLI, you'll need the resource ID of the identity. Use the [`az identity show`](/cli/azure/identity?view=azure-cli-latest#az-identity-show) command to retrieve the resource ID:
83
79
84
-
```dotnetcli
80
+
```azurecli
85
81
az identity show -n cli-identity -g aitesting -o json --query id
86
82
```
87
83
@@ -105,7 +101,7 @@ az webapp identity assign \
105
101
--identities <user-assigned-identity-resource-id>
106
102
```
107
103
108
-
For Azure Container Apps, use the Azure CLI command [`az vm identity assign`](/cli/azure/vm/identity?view=azure-cli-latest#az-vm-identity-assign):
104
+
For Azure Virtual Machines, use the Azure CLI command [`az vm identity assign`](/cli/azure/vm/identity?view=azure-cli-latest#az-vm-identity-assign):
109
105
110
106
```azurecli
111
107
az vm identity assign \
@@ -150,7 +146,7 @@ The following example shows how to assign roles at the resource group scope, sin
150
146
151
147
To assign a user-assigned identity to an Azure App Service web app using the Azure CLI, you'll need the principal ID of the identity. Use the `az identity show` command to retrieve the resource ID:
152
148
153
-
```dotnetcli
149
+
```azurecli
154
150
az identity show \
155
151
--resource-group <your-resource-group> \
156
152
--name <your-managed-identity-name> \
@@ -166,7 +162,7 @@ az role assignment create \
166
162
--scope <scope>
167
163
```
168
164
169
-
To get the role names to which a service principal can be assigned, use the [az role definition list](/cli/azure/role/definition#az-role-definition-list) command:
165
+
To explore which roles a managed identity can be assigned, use the [az role definition list](/cli/azure/role/definition#az-role-definition-list) command:
0 commit comments