Skip to content

Commit 1ccab5e

Browse files
committed
updates
1 parent 7519517 commit 1ccab5e

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

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

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,68 @@ For the steps ahead, you'll use the `principalId` to assign roles to the managed
5959

6060
---
6161

62-
[!INCLUDE [assign-roles-identity](../includes/assign-roles-identity.md)]
62+
## Assign roles to the managed identity
63+
64+
Next, determine which roles your app needs and assign those roles to the managed identity. You can assign roles to a managed identity at the following scopes:
65+
66+
- **Resource**: The assigned roles only apply to that specific resource.
67+
- **Resource group**: The assigned roles apply to all resources contained in the resource group.
68+
- **Subscription**: The assigned roles apply to all resources contained in the subscription.
69+
70+
The following example shows how to assign roles at the resource group scope, since many apps manage all their related Azure resources using a single resource group.
71+
72+
### [Azure portal](#tab/azure-portal)
73+
74+
1. Navigate to the **Overview** page of the resource group that contains the app with the user-assigned managed identity.
75+
1. Select **Access control (IAM)** on the left navigation.
76+
1. On the **Access control (IAM)** page, select **+ Add** on the top menu and then choose **Add role assignment** to navigate to the **Add role assignment** page.
77+
78+
:::image type="content" source="../media/add-role-assignment.png" alt-text="A screenshot showing how to access the identity role assignment page.":::
79+
80+
1. The **Add role assignment** page presents a tabbed, multi-step workflow to assign roles to identities. On the initial **Role** tab, use the search box at the top to locate the role you want to assign to the identity.
81+
1. Select the role from the results and then choose **Next** to move to the **Members** tab.
82+
1. For the **Assign access to** option, select **Managed identity**.
83+
1. For the **Members** option, choose **+ Select members** to open the **Select managed identities** panel.
84+
1. On the **Select managed identities** panel, use the **Subscription** and **Managed identity** dropdowns 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.
85+
86+
:::image type="content" source="../media/user-assigned-identity-assign-roles.png" alt-text="A screenshot showing the managed identity assignment process.":::
87+
88+
1. Select the identity and choose **Select** at the bottom of the panel to continue.
89+
1. Select **Review + assign** at the bottom of the page.
90+
1. On the final **Review + assign** tab, select **Review + assign** to complete the workflow.
91+
92+
### [Azure CLI](#tab/azure-cli)
93+
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:
95+
96+
```azurecli
97+
az role assignment create \
98+
--assignee "{principalId}" \
99+
--role "{roleName}" \
100+
--scope "{scope}"
101+
```
102+
103+
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:
104+
105+
```azurecli
106+
az role definition list \
107+
--query "sort_by([].{roleName:roleName, description:description}, &roleName)" \
108+
--output table
109+
```
110+
111+
For example, to allow the managed identity with the ID of `99999999-9999-9999-9999-999999999999` read, write, and delete access to Azure Storage blob containers and data to all storage accounts in the *msdocs-dotnet-sdk-auth-example* resource group, assign the application service principal to the *Storage Blob Data Contributor* role using the following command:
112+
113+
```azurecli
114+
az role assignment create \
115+
--assignee 99999999-9999-9999-9999-999999999999 \
116+
--role "Storage Blob Data Contributor" \
117+
--scope "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/msdocs-dotnet-sdk-auth-example"
118+
```
119+
120+
For information on assigning permissions at the resource or subscription level using the Azure CLI, see the article [Assign Azure roles using the Azure CLI](/azure/role-based-access-control/role-assignments-cli).
121+
122+
---
63123

64124
## Implement DefaultAzureCredential in your application
65125

66-
[!INCLUDE [Implement DefaultAzureCredential](<../includes/implement-defaultazurecredential.md>)]
126+
[!INCLUDE [Implement DefaultAzureCredential](<../includes/implement-user-assigned-identity.md>)]
46.7 KB
Loading
74.9 KB
Loading

0 commit comments

Comments
 (0)