Skip to content

Commit 40b9938

Browse files
committed
Update troubleshooting guidance
1 parent ede0131 commit 40b9938

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

articles/role-based-access-control/role-assignments.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ Role assignment resource names must be unique within the Azure Active Directory
127127
128128
### Resource deletion behavior
129129

130-
When you delete a user, group, service principal, or managed identity from Azure AD, it's a good practice to delete any role assignments. They aren't deleted automatically.
130+
When you delete a user, group, service principal, or managed identity from Azure AD, it's a good practice to delete any role assignments. They aren't deleted automatically. Any role assignments that refer to a deleted principal ID become invalid.
131131

132-
Any role assignments that refer to a deleted principal ID become invalid. If you try to reuse a role assignment's name for another role assignment, the deployment will fail. To work around this behavior, you should either remove the old role assignment before you recreate it, or ensure that you use a unique name when you deploy a new role assignment.
132+
If you try to reuse a role assignment's name for another role assignment, the deployment will fail. This issue is more likely to occur when you use Bicep or an Azure Resource Manager template (ARM template) to deploy your role assignments, because you have to explicitly set the role assignment name when you use these tools. To work around this behavior, you should either remove the old role assignment before you recreate it, or ensure that you use a unique name when you deploy a new role assignment.
133133

134134
## Description
135135

articles/role-based-access-control/troubleshooting.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,29 +122,52 @@ Set the `principalType` property to `ServicePrincipal` when creating the role as
122122

123123
### Symptom - ARM template role assignment returns BadRequest status
124124

125-
When you try to deploy an ARM template that assigns a role to a service principal you get the error:
125+
When you try to deploy a Bicep file or ARM template that assigns a role to a service principal you get the error:
126126

127127
`Tenant ID, application ID, principal ID, and scope are not allowed to be updated. (code: RoleAssignmentUpdateNotPermitted)`
128128

129+
For example, if you create a role assignment for a managed identity, then you delete the managed identity and recreate it, the new managed identity has a different principal ID. If you try to deploy the role assignment again and use the same role assignment name, the deployment fails.
130+
129131
**Cause**
130132

131133
The role assignment `name` is not unique, and it is viewed as an update.
132134

135+
Role assignments are uniquely identified by their name, which is a globally unique identifier (GUID). You can't create two role assignments with the same name, even in different Azure subscriptions. You also can't change the properties of an existing role assignment.
136+
133137
**Solution**
134-
Provide an idempotent unique value for the role assignment `name`
135138

139+
Provide an idempotent unique value for the role assignment `name`. It's a good practice to create a GUID that uses the scope, principal ID, and role ID together. It's a good idea to use the `guid()` function to help you to create a deterministic GUID for your role assignment names, like in this example:
140+
141+
# [Bicep](#tab/bicep)
142+
143+
```bicep
144+
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = {
145+
name: guid(resourceGroup().id, principalId, roleDefinitionId)
146+
properties: {
147+
roleDefinitionId: roleDefinitionId
148+
principalId: principalId
149+
principalType: principalType
150+
}
151+
}
136152
```
153+
154+
# [ARM template](#tab/armtemplate)
155+
156+
```json
137157
{
138-
"type": "Microsoft.Authorization/roleAssignments",
139-
"apiVersion": "2018-09-01-preview",
140-
"name": "[guid(concat(resourceGroup().id, variables('resourceName'))]",
141-
"properties": {
142-
"roleDefinitionId": "[variables('roleDefinitionId')]",
143-
"principalId": "[variables('principalId')]"
144-
}
158+
"type": "Microsoft.Authorization/roleAssignments",
159+
"apiVersion": "2020-10-01-preview",
160+
"name": "[guid(resourceGroup().id, variables('principalId'), variables('roleDefinitionId')]",
161+
"properties": {
162+
"roleDefinitionId": "[variables('roleDefinitionId')]",
163+
"principalId": "[variables('principalId')]",
164+
"principalType": "[variables('principalType')]"
165+
}
145166
}
146167
```
147168

169+
---
170+
148171
### Symptom - Role assignments with identity not found
149172

150173
In the list of role assignments for the Azure portal, you notice that the security principal (user, group, service principal, or managed identity) is listed as **Identity not found** with an **Unknown** type.
@@ -167,7 +190,7 @@ CanDelegate : False
167190

168191
Similarly, if you list this role assignment using Azure CLI, you might see an empty `principalName`. For example, [az role assignment list](/cli/azure/role/assignment#az-role-assignment-list) returns a role assignment that is similar to the following output:
169192

170-
```
193+
```json
171194
{
172195
"canDelegate": null,
173196
"id": "/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Authorization/roleAssignments/22222222-2222-2222-2222-222222222222",

0 commit comments

Comments
 (0)