sample.bicep.txt 875 B

1234567891011121314151617181920212223242526272829
  1. targetScope = 'subscription'
  2. param deployStorage bool = true
  3. @description('The object ID of the principal that will get the role assignment')
  4. param aadPrincipalId string
  5. module stg './storage.bicep' = if(deployStorage) {
  6. name: 'storageDeploy'
  7. scope: resourceGroup('another-rg') // this will target another resource group in the same subscription
  8. params: {
  9. storageAccountName: '<YOURUNIQUESTORAGENAME>'
  10. }
  11. }
  12. var contributor = 'b24988ac-6180-42a0-ab88-20f7382dd24c'
  13. resource roleDef 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = {
  14. name: contributor
  15. }
  16. resource rbac 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
  17. name: guid(subscription().id, aadPrincipalId, contributor)
  18. properties: {
  19. roleDefinitionId: roleDef.id
  20. principalId: aadPrincipalId
  21. }
  22. }
  23. output storageName array = stg.outputs.containerProps