Skip to content

Commit 8915b7f

Browse files
authored
Merge pull request #263076 from rolyon/rolyon-rbac-troubleshoot-limits-query-condition-tabs
[Azure RBAC] Add conditions to troubleshoot limit queries as tabs
2 parents 7d1b768 + 4f463f0 commit 8915b7f

File tree

4 files changed

+115
-1
lines changed

4 files changed

+115
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
author: rolyon
3+
ms.service: resource-graph
4+
ms.topic: include
5+
ms.date: 01/12/2024
6+
ms.author: rolyon
7+
---
8+
9+
```kusto
10+
AuthorizationResources
11+
| where type =~ "microsoft.authorization/roleassignments"
12+
| where id startswith "/subscriptions"
13+
| extend PrincipalId = tostring(properties.principalId)
14+
| extend Scope = tolower(properties.scope)
15+
| extend RoleDefinitionId = tolower(tostring(properties.roleDefinitionId))
16+
| extend condition = tostring(properties.condition)
17+
| join kind = leftouter (
18+
AuthorizationResources
19+
| where type =~ "microsoft.authorization/roledefinitions"
20+
| extend RoleName = tostring(properties.roleName)
21+
| extend RoleId = tolower(id)
22+
| extend RoleType = tostring(properties.type)
23+
| where RoleType == "BuiltInRole"
24+
| extend RoleId_RoleName = pack(RoleId, RoleName)
25+
) on $left.RoleDefinitionId == $right.RoleId
26+
| summarize count_ = count(), AllRD = make_set(RoleId_RoleName) by PrincipalId, Scope, condition
27+
| where count_ > 1
28+
| order by count_ desc
29+
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
author: rolyon
3+
ms.service: resource-graph
4+
ms.topic: include
5+
ms.date: 01/12/2024
6+
ms.author: rolyon
7+
---
8+
9+
```kusto
10+
authorizationresources
11+
| where type =~ "microsoft.authorization/roleassignments"
12+
| where id startswith "/subscriptions"
13+
| extend RoleDefinitionId = tolower(tostring(properties.roleDefinitionId))
14+
| extend PrincipalId = tolower(properties.principalId)
15+
| extend RoleDefinitionId_PrincipalId = strcat(RoleDefinitionId, "_", PrincipalId)
16+
| extend condition = tostring(properties.condition)
17+
| join kind = leftouter (
18+
authorizationresources
19+
| where type =~ "microsoft.authorization/roledefinitions"
20+
| extend RoleDefinitionName = tostring(properties.roleName)
21+
| extend rdId = tolower(id)
22+
| project RoleDefinitionName, rdId
23+
) on $left.RoleDefinitionId == $right.rdId
24+
| summarize count_ = count(), Scopes = make_set(tolower(properties.scope)) by RoleDefinitionId_PrincipalId,RoleDefinitionName
25+
| project RoleDefinitionId = split(RoleDefinitionId_PrincipalId, "_", 0)[0], RoleDefinitionName, PrincipalId = split(RoleDefinitionId_PrincipalId, "_", 1)[0], count_, Scopes, condition
26+
| where count_ > 1
27+
| order by count_ desc
28+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
author: rolyon
3+
ms.service: resource-graph
4+
ms.topic: include
5+
ms.date: 01/12/2024
6+
ms.author: rolyon
7+
---
8+
9+
```kusto
10+
authorizationresources
11+
| where type =~ "microsoft.authorization/roleassignments"
12+
| where id startswith "/subscriptions"
13+
| extend RoleId = tolower(tostring(properties.roleDefinitionId))
14+
| extend condition = tostring(properties.condition)
15+
| join kind = leftouter (
16+
authorizationresources
17+
| where type =~ "microsoft.authorization/roledefinitions"
18+
| extend RoleDefinitionName = tostring(properties.roleName)
19+
| extend RoleId = tolower(id)
20+
| project RoleDefinitionName, RoleId
21+
) on $left.RoleId == $right.RoleId
22+
| extend principalId = tostring(properties.principalId)
23+
| extend principal_to_ra = pack(principalId, id)
24+
| summarize count_ = count(), AllPrincipals = make_set(principal_to_ra) by RoleDefinitionId = RoleId, Scope = tolower(properties.scope), RoleDefinitionName, condition
25+
| where count_ > 1
26+
| order by count_ desc
27+
```

articles/role-based-access-control/troubleshoot-limits.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ manager: amycolannino
77
ms.service: role-based-access-control
88
ms.topic: how-to
99
ms.workload: identity
10-
ms.date: 12/01/2023
10+
ms.date: 01/12/2024
1111
ms.author: rolyon
1212
---
1313

@@ -66,8 +66,18 @@ To reduce the number of role assignments in the subscription, add principals (us
6666

6767
This query checks active role assignments and doesn't consider eligible role assignments in [Microsoft Entra Privileged Identity Management](../active-directory/privileged-identity-management/pim-resource-roles-assign-roles.md).
6868

69+
If you are using [role assignment conditions](conditions-overview.md) or [delegating role assignment management with conditions](delegate-role-assignments-overview.md), you should use the Conditions query. Otherwise, use the Default query.
70+
71+
# [Default](#tab/default)
72+
6973
[!INCLUDE [resource-graph-query-authorization-same-role-scope](../governance/includes/resource-graph/query/authorization-same-role-scope.md)]
7074

75+
# [Conditions](#tab/conditions)
76+
77+
[!INCLUDE [resource-graph-query-authorization-same-role-scope-condition](../governance/includes/resource-graph/query/authorization-same-role-scope-condition.md)]
78+
79+
---
80+
7181
The following shows an example of the results. The **count_** column is the number of principals assigned the same role and at the same scope. The count is sorted in descending order.
7282

7383
:::image type="content" source="media/troubleshoot-limits/authorization-same-role-scope.png" alt-text="Screenshot of Azure Resource Graph Explorer that shows role assignments with the same role and at the same scope, but for different principals." lightbox="media/troubleshoot-limits/authorization-same-role-scope.png":::
@@ -140,8 +150,18 @@ To reduce the number of role assignments in the subscription, remove redundant r
140150

141151
This query checks active role assignments and doesn't consider eligible role assignments in [Microsoft Entra Privileged Identity Management](../active-directory/privileged-identity-management/pim-resource-roles-assign-roles.md).
142152

153+
If you are using [role assignment conditions](conditions-overview.md) or [delegating role assignment management with conditions](delegate-role-assignments-overview.md), you should use the Conditions query. Otherwise, use the Default query.
154+
155+
# [Default](#tab/default)
156+
143157
[!INCLUDE [resource-graph-query-authorization-same-role-principal](../governance/includes/resource-graph/query/authorization-same-role-principal.md)]
144158

159+
# [Conditions](#tab/conditions)
160+
161+
[!INCLUDE [resource-graph-query-authorization-same-role-principal-condition](../governance/includes/resource-graph/query/authorization-same-role-principal-condition.md)]
162+
163+
---
164+
145165
The following shows an example of the results. The **count_** column is the number of different scopes for role assignments with the same role and same principal. The count is sorted in descending order.
146166

147167
:::image type="content" source="media/troubleshoot-limits/authorization-same-role-principal.png" alt-text="Screenshot of Azure Resource Graph Explorer that shows role assignments for the same role and same principal, but at different scopes." lightbox="media/troubleshoot-limits/authorization-same-role-principal.png":::
@@ -200,8 +220,18 @@ To reduce the number of role assignments in the subscription, replace multiple b
200220

201221
This query checks active role assignments and doesn't consider eligible role assignments in [Microsoft Entra Privileged Identity Management](../active-directory/privileged-identity-management/pim-resource-roles-assign-roles.md).
202222

223+
If you are using [role assignment conditions](conditions-overview.md) or [delegating role assignment management with conditions](delegate-role-assignments-overview.md), you should use the Conditions query. Otherwise, use the Default query.
224+
225+
# [Default](#tab/default)
226+
203227
[!INCLUDE [resource-graph-query-authorization-same-principal-scope](../governance/includes/resource-graph/query/authorization-same-principal-scope.md)]
204228

229+
# [Condition](#tab/conditions)
230+
231+
[!INCLUDE [resource-graph-query-authorization-same-principal-scope-condition](../governance/includes/resource-graph/query/authorization-same-principal-scope-condition.md)]
232+
233+
---
234+
205235
The following shows an example of the results. The **count_** column is the number of different built-in role assignments with the same principal and same scope. The count is sorted in descending order.
206236

207237
:::image type="content" source="media/troubleshoot-limits/authorization-same-principal-scope.png" alt-text="Screenshot of Azure Resource Graph Explorer that shows role assignments for with the same principal and same scope." lightbox="media/troubleshoot-limits/authorization-same-principal-scope.png":::

0 commit comments

Comments
 (0)