Skip to content

Instantly share code, notes, and snippets.

@azMantas
Last active June 8, 2021 06:43
Show Gist options
  • Save azMantas/7a1c519ce9c846d59ae756eb448593a3 to your computer and use it in GitHub Desktop.
Save azMantas/7a1c519ce9c846d59ae756eb448593a3 to your computer and use it in GitHub Desktop.
assign RBAC role for multiple principals in bicep
targetScope = 'managementGroup'
param roleDefinitionId string = 'b60367af-1334-4454-b71e-769d9a4f83d9'
param assignmentScope string = 'BicepRules'
param principalIds array = [
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy'
]
resource rbac 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = [for principal in principalIds: {
name: guid(roleDefinitionId, assignmentScope, principal)
properties: {
principalId: principal
roleDefinitionId: '/providers/Microsoft.Authorization/roleDefinitions/${roleDefinitionId}'
}
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment