Skip to content

Commit 9b5a5b9

Browse files
authored
Merge pull request #88208 from rolyon/rolyon-rbac-mg-custom-roles
[Azure RBAC] Management group and custom role updates
2 parents 3c916a1 + 51730b5 commit 9b5a5b9

File tree

6 files changed

+132
-35
lines changed

6 files changed

+132
-35
lines changed

articles/role-based-access-control/custom-roles-cli.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ ms.devlang: na
1212
ms.topic: conceptual
1313
ms.tgt_pltfrm: na
1414
ms.workload: identity
15-
ms.date: 02/20/2019
15+
ms.date: 03/18/2020
1616
ms.author: rolyon
1717
ms.reviewer: bagovind
1818
---
1919
# Create or update custom roles for Azure resources using Azure CLI
2020

21+
> [!IMPORTANT]
22+
> Adding a management group to `AssignableScopes` is currently in preview.
23+
> This preview version is provided without a service level agreement, and it's not recommended for production workloads. Certain features might not be supported or might have constrained capabilities.
24+
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
25+
2126
If the [built-in roles for Azure resources](built-in-roles.md) don't meet the specific needs of your organization, you can create your own custom roles. This article describes how to list, create, update, or delete custom roles using Azure CLI.
2227

2328
For a step-by-step tutorial on how to create a custom role, see [Tutorial: Create a custom role for Azure resources using Azure CLI](tutorial-custom-role-cli.md).
@@ -181,7 +186,7 @@ To update a custom role, first use [az role definition list](/cli/azure/role/def
181186
az role definition update --role-definition <role_definition>
182187
```
183188

184-
The following example adds the *Microsoft.Insights/diagnosticSettings/* operation to the *Actions* of the *Virtual Machine Operator* custom role.
189+
The following example adds the *Microsoft.Insights/diagnosticSettings/* operation to `Actions` and adds a management group to `AssignableScopes` for the *Virtual Machine Operator* custom role. Adding a management group to `AssignableScopes` is currently in preview.
185190

186191
vmoperator.json
187192

@@ -208,7 +213,8 @@ vmoperator.json
208213
],
209214
"AssignableScopes": [
210215
"/subscriptions/11111111-1111-1111-1111-111111111111",
211-
"/subscriptions/33333333-3333-3333-3333-333333333333"
216+
"/subscriptions/33333333-3333-3333-3333-333333333333",
217+
"/providers/Microsoft.Management/managementGroups/marketing-group"
212218
]
213219
}
214220
```

articles/role-based-access-control/custom-roles-powershell.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ ms.devlang: na
1212
ms.topic: conceptual
1313
ms.tgt_pltfrm: na
1414
ms.workload: identity
15-
ms.date: 02/20/2019
15+
ms.date: 03/18/2020
1616
ms.author: rolyon
1717
ms.reviewer: bagovind
1818
---
1919
# Create or update custom roles for Azure resources using Azure PowerShell
2020

21+
> [!IMPORTANT]
22+
> Adding a management group to `AssignableScopes` is currently in preview.
23+
> This preview version is provided without a service level agreement, and it's not recommended for production workloads. Certain features might not be supported or might have constrained capabilities.
24+
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
25+
2126
If the [built-in roles for Azure resources](built-in-roles.md) don't meet the specific needs of your organization, you can create your own custom roles. This article describes how to list, create, update, or delete custom roles using Azure PowerShell.
2227

2328
For a step-by-step tutorial on how to create a custom role, see [Tutorial: Create a custom role for Azure resources using Azure PowerShell](tutorial-custom-role-powershell.md).
@@ -69,7 +74,7 @@ If the selected subscription isn't in the `AssignableScopes` of the role, the cu
6974
To list a custom role definition, use [Get-AzRoleDefinition](/powershell/module/az.resources/get-azroledefinition). This is the same command as you use for a built-in role.
7075

7176
```azurepowershell
72-
Get-AzRoleDefinition <role name> | ConvertTo-Json
77+
Get-AzRoleDefinition <role_name> | ConvertTo-Json
7378
```
7479

7580
```Example
@@ -104,7 +109,7 @@ PS C:\> Get-AzRoleDefinition "Virtual Machine Operator" | ConvertTo-Json
104109
The following example lists just the actions of the role:
105110

106111
```azurepowershell
107-
(Get-AzRoleDefinition <role name>).Actions
112+
(Get-AzRoleDefinition <role_name>).Actions
108113
```
109114

110115
```Example
@@ -292,6 +297,42 @@ AssignableScopes : {/subscriptions/00000000-0000-0000-0000-000000000000,
292297
/subscriptions/22222222-2222-2222-2222-222222222222}
293298
```
294299

300+
The following example adds a management group to `AssignableScopes` of the *Virtual Machine Operator* custom role. Adding a management group to `AssignableScopes` is currently in preview.
301+
302+
```azurepowershell
303+
Get-AzManagementGroup
304+
305+
$role = Get-AzRoleDefinition "Virtual Machine Operator"
306+
$role.AssignableScopes.Add("/providers/Microsoft.Management/managementGroups/{groupId1}")
307+
Set-AzRoleDefinition -Role $role
308+
```
309+
310+
```Example
311+
PS C:\> Get-AzManagementGroup
312+
313+
Id : /providers/Microsoft.Management/managementGroups/marketing-group
314+
Type : /providers/Microsoft.Management/managementGroups
315+
Name : marketing-group
316+
TenantId : 99999999-9999-9999-9999-999999999999
317+
DisplayName : Marketing group
318+
319+
PS C:\> $role = Get-AzRoleDefinition "Virtual Machine Operator"
320+
PS C:\> $role.AssignableScopes.Add("/providers/Microsoft.Management/managementGroups/marketing-group")
321+
PS C:\> Set-AzRoleDefinition -Role $role
322+
323+
Name : Virtual Machine Operator
324+
Id : 88888888-8888-8888-8888-888888888888
325+
IsCustom : True
326+
Description : Can monitor and restart virtual machines.
327+
Actions : {Microsoft.Storage/*/read, Microsoft.Network/*/read, Microsoft.Compute/*/read,
328+
Microsoft.Compute/virtualMachines/start/action...}
329+
NotActions : {}
330+
AssignableScopes : {/subscriptions/00000000-0000-0000-0000-000000000000,
331+
/subscriptions/11111111-1111-1111-1111-111111111111,
332+
/subscriptions/22222222-2222-2222-2222-222222222222,
333+
/providers/Microsoft.Management/managementGroups/marketing-group}
334+
```
335+
295336
### Update a custom role with a JSON template
296337

297338
Using the previous JSON template, you can easily modify an existing custom role to add or remove Actions. Update the JSON template and add the read action for networking as shown in the following example. The definitions listed in the template are not cumulatively applied to an existing definition, meaning that the role appears exactly as you specify in the template. You also need to update the Id field with the ID of the role. If you aren't sure what this value is, you can use the [Get-AzRoleDefinition](/powershell/module/az.resources/get-azroledefinition) cmdlet to get this information.

articles/role-based-access-control/custom-roles-rest.md

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ ms.reviewer: bagovind
2020
---
2121
# Create or update custom roles for Azure resources using the REST API
2222

23+
> [!IMPORTANT]
24+
> Adding a management group to `AssignableScopes` is currently in preview.
25+
> This preview version is provided without a service level agreement, and it's not recommended for production workloads. Certain features might not be supported or might have constrained capabilities.
26+
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
27+
2328
If the [built-in roles for Azure resources](built-in-roles.md) don't meet the specific needs of your organization, you can create your own custom roles. This article describes how to list, create, update, or delete custom roles using the REST API.
2429

2530
## List custom roles
@@ -54,9 +59,10 @@ To list custom roles at a scope, use the [Role Definitions - List](/rest/api/aut
5459
> [!div class="mx-tableFixed"]
5560
> | Scope | Type |
5661
> | --- | --- |
57-
> | `subscriptions/{subscriptionId}` | Subscription |
58-
> | `subscriptions/{subscriptionId}/resourceGroups/myresourcegroup1` | Resource group |
59-
> | `subscriptions/{subscriptionId}/resourceGroups/myresourcegroup1/providers/Microsoft.Web/sites/mysite1` | Resource |
62+
> | `subscriptions/{subscriptionId1}` | Subscription |
63+
> | `subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}` | Resource group |
64+
> | `subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}/providers/Microsoft.Web/sites/{site1}` | Resource |
65+
> | `providers/Microsoft.Management/managementGroups/{groupId1}` | Management group |
6066
6167
1. Replace *{filter}* with the role type.
6268
@@ -80,9 +86,10 @@ To get information about a custom role by its display name, use the [Role Defini
8086
> [!div class="mx-tableFixed"]
8187
> | Scope | Type |
8288
> | --- | --- |
83-
> | `subscriptions/{subscriptionId}` | Subscription |
84-
> | `subscriptions/{subscriptionId}/resourceGroups/myresourcegroup1` | Resource group |
85-
> | `subscriptions/{subscriptionId}/resourceGroups/myresourcegroup1/providers/Microsoft.Web/sites/mysite1` | Resource |
89+
> | `subscriptions/{subscriptionId1}` | Subscription |
90+
> | `subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}` | Resource group |
91+
> | `subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}/providers/Microsoft.Web/sites/{site1}` | Resource |
92+
> | `providers/Microsoft.Management/managementGroups/{groupId1}` | Management group |
8693
8794
1. Replace *{filter}* with the display name for the role.
8895
@@ -108,9 +115,10 @@ To get information about a custom role by its unique identifier, use the [Role D
108115
> [!div class="mx-tableFixed"]
109116
> | Scope | Type |
110117
> | --- | --- |
111-
> | `subscriptions/{subscriptionId}` | Subscription |
112-
> | `subscriptions/{subscriptionId}/resourceGroups/myresourcegroup1` | Resource group |
113-
> | `subscriptions/{subscriptionId}/resourceGroups/myresourcegroup1/providers/Microsoft.Web/sites/mysite1` | Resource |
118+
> | `subscriptions/{subscriptionId1}` | Subscription |
119+
> | `subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}` | Resource group |
120+
> | `subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}/providers/Microsoft.Web/sites/{site1}` | Resource |
121+
> | `providers/Microsoft.Management/managementGroups/{groupId1}` | Management group |
114122
115123
1. Replace *{roleDefinitionId}* with the GUID identifier of the role definition.
116124
@@ -146,7 +154,11 @@ To create a custom role, use the [Role Definitions - Create Or Update](/rest/api
146154
}
147155
],
148156
"assignableScopes": [
149-
"/subscriptions/{subscriptionId}"
157+
"/subscriptions/{subscriptionId1}",
158+
"/subscriptions/{subscriptionId2}",
159+
"/subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}",
160+
"/subscriptions/{subscriptionId2}/resourceGroups/{resourceGroup2}",
161+
"/providers/Microsoft.Management/managementGroups/{groupId1}"
150162
]
151163
}
152164
}
@@ -157,14 +169,17 @@ To create a custom role, use the [Role Definitions - Create Or Update](/rest/api
157169
> [!div class="mx-tableFixed"]
158170
> | Scope | Type |
159171
> | --- | --- |
160-
> | `subscriptions/{subscriptionId}` | Subscription |
161-
> | `subscriptions/{subscriptionId}/resourceGroups/myresourcegroup1` | Resource group |
172+
> | `subscriptions/{subscriptionId1}` | Subscription |
173+
> | `subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}` | Resource group |
174+
> | `providers/Microsoft.Management/managementGroups/{groupId1}` | Management group |
162175
163176
1. Replace *{roleDefinitionId}* with the GUID identifier of the custom role.
164177
165178
1. Within the request body, replace *{roleDefinitionId}* with the GUID identifier.
166179
167-
1. In the `assignableScopes` property, replace *{subscriptionId}* with your subscription identifier. Or specify a resource group.
180+
1. If `assignableScopes` is a subscription or resource group, replace the *{subscriptionId}* or *{resourceGroup}* instances with your identifiers.
181+
182+
1. If `assignableScopes` is a management group, replace the *{groupId}* instance with your management group identifier. Adding a management group to `assignableScopes` is currently in preview.
168183
169184
1. In the `actions` property, add the operations that the role allows to be performed.
170185
@@ -199,7 +214,8 @@ To create a custom role, use the [Role Definitions - Create Or Update](/rest/api
199214
}
200215
],
201216
"assignableScopes": [
202-
"/subscriptions/00000000-0000-0000-0000-000000000000"
217+
"/subscriptions/00000000-0000-0000-0000-000000000000",
218+
"/providers/Microsoft.Management/managementGroups/marketing-group"
203219
]
204220
}
205221
}
@@ -222,8 +238,9 @@ To update a custom role, use the [Role Definitions - Create Or Update](/rest/api
222238
> [!div class="mx-tableFixed"]
223239
> | Scope | Type |
224240
> | --- | --- |
225-
> | `subscriptions/{subscriptionId}` | Subscription |
226-
> | `subscriptions/{subscriptionId}/resourceGroups/myresourcegroup1` | Resource group |
241+
> | `subscriptions/{subscriptionId1}` | Subscription |
242+
> | `subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}` | Resource group |
243+
> | `providers/Microsoft.Management/managementGroups/{groupId1}` | Management group |
227244
228245
1. Replace *{roleDefinitionId}* with the GUID identifier of the custom role.
229246
@@ -247,7 +264,11 @@ To update a custom role, use the [Role Definitions - Create Or Update](/rest/api
247264
}
248265
],
249266
"assignableScopes": [
250-
"/subscriptions/{subscriptionId}"
267+
"/subscriptions/{subscriptionId1}",
268+
"/subscriptions/{subscriptionId2}",
269+
"/subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}",
270+
"/subscriptions/{subscriptionId2}/resourceGroups/{resourceGroup2}",
271+
"/providers/Microsoft.Management/managementGroups/{groupId1}"
251272
]
252273
}
253274
}
@@ -283,7 +304,8 @@ To update a custom role, use the [Role Definitions - Create Or Update](/rest/api
283304
}
284305
],
285306
"assignableScopes": [
286-
"/subscriptions/00000000-0000-0000-0000-000000000000"
307+
"/subscriptions/00000000-0000-0000-0000-000000000000",
308+
"/providers/Microsoft.Management/managementGroups/marketing-group"
287309
]
288310
}
289311
}
@@ -306,8 +328,9 @@ To delete a custom role, use the [Role Definitions - Delete](/rest/api/authoriza
306328
> [!div class="mx-tableFixed"]
307329
> | Scope | Type |
308330
> | --- | --- |
309-
> | `subscriptions/{subscriptionId}` | Subscription |
310-
> | `subscriptions/{subscriptionId}/resourceGroups/myresourcegroup1` | Resource group |
331+
> | `subscriptions/{subscriptionId1}` | Subscription |
332+
> | `subscriptions/{subscriptionId1}/resourceGroups/{resourceGroup1}` | Resource group |
333+
> | `providers/Microsoft.Management/managementGroups/{groupId1}` | Management group |
311334
312335
1. Replace *{roleDefinitionId}* with the GUID identifier of the custom role.
313336

0 commit comments

Comments
 (0)