How do i add multiple groups in Azure RBAC permission as contributor by Bicep file

Emran Hossain 195 Reputation points
2023-08-16T08:39:07.9966667+00:00

Hi ,

I am facing some problem to implement a problem in my Company .

I want to automate RBAC Permission for a multiple group to Reader ,Owner & Contributor by Bicep Format.

" I can do that one group at the same time by PrincipleID/Object ID but i can not do that for Multiple group .

If Possible , Can anyone guide me please .

Thanks

Emran Hossain

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

Accepted answer
  1. AirGordon 7,150 Reputation points
    2023-08-16T22:22:58.13+00:00

    You'll use a for loop to iterate over the groups.

    Something like this;

    param groupIds array = ['123', '456']
    
    var AcrPullRole = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')
    
    resource aks_acr_pull 'Microsoft.Authorization/roleAssignments@2022-04-01' = [for groupId in groupIds: {
      name: guid('resourceId', groupId, AcrPullRole)
      properties: {
        roleDefinitionId: AcrPullRole
        principalId: groupId 
      }
    }]
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.