Skip to content

Commit 685b14a

Browse files
committed
updates
1 parent 1ccab5e commit 685b14a

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

docs/azure/sdk/authentication/user-assigned-managed-identity.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,55 @@ The command output prints the following values:
5555
- **ResourceGroup**: The resource group that contains the identity.
5656
- **TenantId**: The Microsoft Entra tenant that contains the identity.
5757

58-
For the steps ahead, you'll use the `principalId` to assign roles to the managed identity.
58+
---
59+
60+
## Assign the managed identity to your app
61+
62+
A user-assigned can be associated with one or more Azure resources. All of the resources that use that identity will gain the permissions applied through the identity's roles.
63+
64+
### [Azure portal](#tab/azure-portal)
65+
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.
67+
1. From the resource's **Overview** page, expand **Settings** and select **Identity** from the navigation.
68+
1. On the **Identity** page, switch to the **User assigned** tab.
69+
1. Select **+ Add** to open the **Add user assigned managed identity** panel.
70+
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.
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.
77+
78+
### [Azure CLI](#tab/azure-cli)
79+
80+
The Azure CLI provides different commands to assign a user-assigned identity to different types of hosting services.
81+
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:
83+
84+
```dotnetcli
85+
az identity show -n cli-identity -g aitesting -o json --query id
86+
```
87+
88+
Once you have the resource ID, use the Azure CLI command `az <resourceType> identity assign` command to associate the user-assigned identity with different resources, such as the following:
89+
90+
For Azure App Service, use the Azure CLI command `azd webapp identity assign`:
91+
92+
```azurecli
93+
az webapp identity assign --resource-group <resource-group-name> --name <webapp-name> --identities <user-assigned-identity-resource-id>
94+
```
95+
96+
For Azure Container Apps, use the Azure CLI command `az containerapp identity assign`:
97+
98+
```azurecli
99+
az webapp identity assign --resource-group <resource-group-name> --name <webapp-name> --identities <user-assigned-identity-resource-id>
100+
```
101+
102+
For Azure Container Apps, use the Azure CLI command `az containerapp identity assign`:
103+
104+
```azurecli
105+
az vm identity assign --resource-group <resource-group-name> --name <webapp-name> --identities <user-assigned-identity-resource-id>
106+
```
59107

60108
---
61109

@@ -91,7 +139,13 @@ The following example shows how to assign roles at the resource group scope, sin
91139

92140
### [Azure CLI](#tab/azure-cli)
93141

94-
A managed identity is assigned a role in Azure using the [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create) command:
142+
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:
143+
144+
```dotnetcli
145+
az identity show -n cli-identity -g aitesting -o json --query id
146+
```
147+
148+
Assign a role to a managed identity using the [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create) command:
95149

96150
```azurecli
97151
az role assignment create \
97.6 KB
Loading

0 commit comments

Comments
 (0)