How do you write a custom RBAC role?
IntermediateConceptEntra ID, RBAC and Identities
Answer
Define actions, data actions and assignable scopes in JSON, then create it:
{
"Name": "AKS Node Pool Scaler",
"Description": "Scale AKS node pools only",
"Actions": [
"Microsoft.ContainerService/managedClusters/read",
"Microsoft.ContainerService/managedClusters/agentPools/read",
"Microsoft.ContainerService/managedClusters/agentPools/write"
],
"NotActions": [],
"DataActions": [],
"AssignableScopes": ["/subscriptions/00000000-0000-0000-0000-000000000000"]
}
az role definition create --role-definition @aks-scaler.json
az provider operation show -n Microsoft.ContainerService -o table # find action names
Custom roles are limited per tenant (5,000), so we create a few reusable ones rather than one per team.
More on Entra ID, RBAC and Identities
What is Microsoft Entra ID and how is it different from on-prem Active Directory?BeginnerWhat is the difference between an app registration and a service principal?BeginnerWhat is a managed identity and what problem does it solve?BeginnerSystem-assigned vs user-assigned managed identity: when do you use each?IntermediateHow does Azure RBAC evaluate access?IntermediateName the core built-in roles and the difference between Owner, Contributor and User Access Administrator.Beginner