Azure Custom Roles
What you'll learn: How to create custom Azure roles when the 200+ built-in roles don't quite fit your needs.
Why Custom Roles?
Azure's built-in roles (Contributor, Reader, Virtual Machine Contributor, etc.) cover most scenarios. But sometimes you need something more precise — like a role that can start/stop VMs but not delete them, or read storage accounts but not modify access keys. That's where custom roles come in.
Actions and NotActions
Custom roles are built around two key lists:
- Actions: What the role can do (e.g.,
Microsoft.Compute/virtualMachines/start/action) - NotActions: What to exclude from broader Actions (acts as a filter)
Think of Actions like giving someone a key ring with many keys. NotActions is like removing specific keys from that ring before handing it over.
How It Works
You define a custom role using JSON that specifies:
{
"Name": "VM Operator (Start/Stop Only)",
"Actions": [
"Microsoft.Compute/virtualMachines/start/action",
"Microsoft.Compute/virtualMachines/powerOff/action",
"Microsoft.Compute/virtualMachines/read"
],
"NotActions": [],
"AssignableScopes": ["/subscriptions/{subscription-id}"]
}
You can also use wildcards: "Microsoft.Storage/*/read" grants all read operations across Storage services, but "NotActions": ["Microsoft.Storage/storageAccounts/listKeys/action"] would prevent reading secret keys.
Granular Control
Custom roles let you implement the Principle of Least Privilege with surgical precision. Need someone to manage networking but not change security rules? Custom role. Need billing read access but not spending permissions? Custom role.
Key Takeaway: Azure Custom Roles use Actions (what's allowed) and NotActions (what's excluded) to create granular permissions that perfectly match your security requirements when built-in roles fall short.