You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A custom role requires a unique ID. The ID can be generated with the [guid()](../azure-resource-manager/bicep/bicep-functions-string.md#guid) function. Since a custom role also requires a [unique display name](custom-roles.md#custom-role-properties) for the tenant, you can use the role name as a parameter for the `guid()` function to create a [deterministic GUID](../azure-resource-manager/bicep/scenarios-rbac.md#name). A deterministic GUID is useful if you later need to update the custom role using the same Bicep file.
41
+
42
+
```bicep
43
+
targetScope = 'subscription'
44
+
45
+
@description('Array of actions for the roleDefinition')
> Create a variable called **myActions** and then pass that variable. Replace the sample actions with the actions for the roleDefinition.
71
-
72
120
When the deployment finishes, you should see a message indicating the deployment succeeded.
73
121
74
122
## Review deployed resources
@@ -91,53 +139,36 @@ Get-AzRoleDefinition "Custom Role - RG Reader"
91
139
92
140
## Update a custom role
93
141
94
-
Similar to creating a custom role, you can update an existing custom role using Bicep. To update a custom role, you need to specify the role you want to update.
142
+
Similar to creating a custom role, you can update an existing custom role using Bicep. To update a custom role, you need to specify the role you want to update. If you previously created the custom role in Bicep with a unique role ID that is [deterministic](../azure-resource-manager/bicep/scenarios-rbac.md#name), you can use the same Bicep file and specify the custom role by just using the display name.
95
143
96
-
Here are the changes you would need to make to the previous Bicep file to update the custom role.
97
-
98
-
1. Include the role ID as a parameter.
99
-
100
-
```bicep
101
-
...
102
-
@description('ID of the role definition')
103
-
param roleDefName string
104
-
...
105
-
106
-
```
107
-
108
-
2. Remove the roleDefName variable. You'll get a warning if you have a parameter and variable with the same name.
109
-
3. Use Azure CLI or Azure PowerShell to get the roleDefName.
144
+
1. Specify the updated actions.
110
145
111
146
# [CLI](#tab/CLI)
112
147
113
148
```azurecli-interactive
114
-
az role definition list --name "Custom Role - RG Reader"
4. Use Azure CLI or Azure PowerShell to deploy the updated Bicep file, replacing **\<name-id\>** with the roleDefName, and replacing the sample actions with the updated actions for the roleDefinition.
160
+
1. Use Azure CLI or Azure PowerShell to update roleDefinition.
-[Create a new role def via a subscription level deployment](https://github.com/Azure/azure-quickstart-templates/tree/master/subscription-deployments/create-role-def)
0 commit comments