Reputation: 728
I'm struggling to maintain a coherent mental model of how Azure RBAC custom role definitions are stored in Azure, their lifecycle and their relationship with their assignable scopes.
I created a new custom role called "some-custom-role". I set two assignable scopes, subscription_1 and subscription_2. After creating, I run these commands
az role definition list --name some-custom-role --subscription subscription_2 --query [].id -ot
sv
/subscriptions/subscription_2/providers/Microsoft.Authorization/roleDefinitions/b633f26b-3b4b-42ca-a0ed-501c354e4d23
az role definition list --name some-custom-role --subscription subscription_1 --query [].id -otsv
/subscriptions/subscription_1/providers/Microsoft.Authorization/roleDefinitions/b633f26b-3b4b-42ca-a0ed-501c354e4d23
I'm confused. These are two different resources with different IDs, yet they look eerily similar. Is one of the role definition resources the "primary", while the other one is a copy? Changing one of the resources seem to change the other as well. Will the role definition disappear if I delete one of the subscriptions? If I delete both? If I delete the role definition in one subscription, will it disappear in the other one as well? Is there some object in Entra or elsewhere which represents the source of truth for both of these role definition copies?
Upvotes: 1
Views: 429
Reputation: 728
I made many experiments while authoring the question, so I figured I might as well share my findings in a Q&A. There are several undocumented properties of Azure RBAC roles I've established
roleName
within a single tenant. If I try to create another role definition anywhere in my tenant which I also call some-custom-role
, I will get an error.id
property, which is different for each subscription.id
property of the role definition is unchanged.az resource delete --ids <sub-specific-role-definition-resource-id>
, any copies in other subscriptions are also deleted.Role definitions which are assignable across multiple subscriptions have similarities with databases in a multi-master replication setup. Changes to one copy are spontaneously reflected in other copies.
Upvotes: 1