Im trying to assign multiple AD group to Multiple RBAC roles to my storage account.
So I need to Loop through my adGroup variable ( array) and then need to also loop all my RoleIDs to assign each of my adGroup.
My attempt is below code but file showing some error so 100% syntax error. Im new to bicep so would be appraciated some help
my definition to call module:
param adGroup array
module addGroups 'platform/modules/roles/aad group/deploy.bicep' = {
name: 'datalake-rbac'
params: {
storageAccountName: storageAccountName
adGroup: adGroup
roleId: ['ba92f5b4-2d11-453d-a403-e96b0029c9fe' // Storage Blob Data Contributor
'b24988ac-6180-42a0-ab88-20f7382dd24c' // Contributor
]
}
dependsOn: [
storageAccountModule
]
}
/////////////////////
param storageAccountName string
param addGroup array
param roleId array
param principalType string = 'Group'
// Reference to the storage account
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' existing = {
name: storageAccountName
}
// Flatten the loop into a single array using a combined `for` loop
resource roleAssignments 'Microsoft.Authorization/roleAssignments@2022-04-01' = [for groupId in addGroup: for rId in roleId: {
name: guid(subscription().subscriptionId, resourceGroup().name, storageAccountName, groupId, rId)
scope: storageAccount
properties: {
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', rId)
principalId: groupId
principalType: principalType
}
}]