0
votes

I would like to have a service principal that can regenerate keys for service buses. Unfortunately, my organization is over their limit for custom role creation. I was hoping to give "Contributor" access to all service buses in the subscription, but I can't find a way to do it. Is there a way to accomplish this with something like wild cards? Like this:

az role assignment create --assignee (service-principal) --role Contributor --scope "/subscriptions/(subscription)/resourceGroups/\*/providers/Microsoft.ServiceBus/namespaces/\*"

I can't find a built-in role related to service buses like there is for storage accounts with the "Storage Account Key Operator Service Role".

Any help would be appreciated. Thanks!

1
I'll accept it because it might work for other people's situations, but I was hoping for a service principal that would have access to all service buses that exist currently and ones that will be made in the future, like you get with the Storage Account Key operator service role. I'm guessing that there is no solution to my problem without having a custom role.R Wood

1 Answers

1
votes

The Azure CLI seems not to support wildcard in --scope, if you want to give your service principal a Contributor role for all the service buses in the subscription, my workaround is to do that via Azure Powershell, you could refer to the command below, it works fine on my side.

$ResourceId = (Get-AzureRmResource -ResourceType Microsoft.ServiceBus/namespaces).ResourceId
foreach($rid in $ResourceId){
    New-AzureRmRoleAssignment -ObjectId <Service Principal ObjectId> -Scope $rid -RoleDefinitionName Contributor
}