Skip to content

Instantly share code, notes, and snippets.

@RylandDeGregory
Created July 10, 2024 23:37
Show Gist options
  • Select an option

  • Save RylandDeGregory/af5cb52357e31d7cc231cdf49470be18 to your computer and use it in GitHub Desktop.

Select an option

Save RylandDeGregory/af5cb52357e31d7cc231cdf49470be18 to your computer and use it in GitHub Desktop.
Add an Azure Cosmos DB NoSQL Data Plane Role Assignment using Azure PowerShell.
$RoleDefinitions = @(
@{
Name = 'Cosmos DB Built-in Data Reader'
Id = '00000000-0000-0000-0000-000000000001'
}
@{
Name = 'Cosmos DB Built-in Data Contributor'
Id = '00000000-0000-0000-0000-000000000002'
}
)
$RoleDefinitionId = $RoleDefinitions | Where-Object { $_.Name -like '*Contributor' } | Select-Object -ExpandProperty Id
$ResourceGroupName = ''
$AccountName = ''
$PrincipalId = ''
$CosmosDBParams = @{
AccountName = $AccountName
PrincipalId = $PrincipalId
ResourceGroupName = $ResourceGroupName
RoleDefinitionId = $RoleDefinitionId
Scope = '/'
}
New-AzCosmosDBSqlRoleAssignment @CosmosDBParams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment