Skip to content

Instantly share code, notes, and snippets.

@cdennig
Created October 3, 2021 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdennig/bad3cdb81bf19398625c95bc9b8d1ad5 to your computer and use it in GitHub Desktop.
Save cdennig/bad3cdb81bf19398625c95bc9b8d1ad5 to your computer and use it in GitHub Desktop.
roledef.bicep
@description('Principal ID of the managed identity')
param principalId string
var roleDefId = guid('sql-role-definition-', principalId, cosmosDbAccount.id)
var roleDefName = 'Custom Read/Write role'
resource roleDefinition 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions@2021-06-15' = {
name: '${cosmosDbAccount.name}/${roleDefId}'
properties: {
roleName: roleDefName
type: 'CustomRole'
assignableScopes: [
cosmosDbAccount.id
]
permissions: [
{
dataActions: [
'Microsoft.DocumentDB/databaseAccounts/readMetadata'
'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/*'
]
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment