Azure RBAC: Roles, Scopes and Assignments
Azure doesn't attach policy documents to identities. It uses three pieces: a role definition (a list of allowed operations), a scope (where), and a role assignment that joins a principal, a role and a scope. Read "who" + "what" + "where" and you can read every Azure permission.
On AWS this is… identity-based IAM policies attached to users, groups and roles, and the evaluation logic from IAM Policies.
The three pieces
| Piece | Azure | Closest AWS idea |
|---|---|---|
| Role definition | JSON with Actions, NotActions, DataActions, NotDataActions, AssignableScopes |
a managed policy |
| Scope | management group, subscription, resource group or single resource | the Resource element, but as a place in the tree |
| Role assignment | principal + role + scope (+ optional condition) | attaching a policy to a user/role |
| Deny assignment | blocks actions for principals at a scope; created by Azure features (deployment stacks, managed applications), not hand-written | an explicit Deny |
Built-in roles you'll use every day:
| Role | Can do | Notes |
|---|---|---|
| Owner | everything, including granting access | keep to very few people |
| Contributor | create and manage all resources | cannot grant access to others |
| Reader | view everything | can't read data like blob contents or secrets |
| User Access Administrator | manage role assignments | the "grant" half of Owner |
| Role Based Access Control Administrator | manage assignments, can be limited by conditions to certain roles | safer delegation than UAA |
| Service roles | e.g. Storage Blob Data Reader, Key Vault Secrets User, AcrPull, Azure Kubernetes Service RBAC Reader |
least privilege |
Control plane vs data plane
Actions cover the management API (Microsoft.Storage/storageAccounts/write: create or change the storage account). DataActions cover the data inside (Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read: read a blob). Contributor and Owner have no DataActions, so a subscription Owner can't read blobs through Entra ID authorisation until someone assigns a data role such as Storage Blob Data Reader. On AWS, s3:GetObject is just another IAM action.
Evaluation
- Collect all role assignments for the principal (and its groups) at the target scope and every parent scope.
- The operation is allowed if any assigned role's
Actions(orDataActions) match it and it isn't excluded by that same role'sNotActions(NotDataActions). - A deny assignment that matches overrides any allow.
NotActions is not a deny. It only trims that one role. If another role grants the operation, it is allowed. This is the most common misreading of Azure RBAC.
Model: an RBAC evaluator
from fnmatch import fnmatchcase
ROLES = {
"Reader": {"Actions": ["*/read"], "NotActions": []},
"Contributor": {"Actions": ["*"], "NotActions": [
"Microsoft.Authorization/*/Delete", "Microsoft.Authorization/*/Write"]},
"Storage Blob Data Reader": {"Actions": [], "NotActions": [],
"DataActions": ["Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read"]},
}
SUB = "/subscriptions/sub-prod"
RG = SUB + "/resourceGroups/rg-shop"
ST = RG + "/providers/Microsoft.Storage/storageAccounts/stshop"
assignments = [ # (principal, role, scope)
("ada", "Contributor", RG),
("ada", "Reader", SUB),
("bob", "Storage Blob Data Reader", ST),
]
deny_assignments = [("*", "Microsoft.Storage/storageAccounts/delete", ST)] # e.g. from a deployment stack
def in_scope(target, scope):
return target == scope or target.lower().startswith(scope.lower() + "/")
def m(patterns, op):
return any(fnmatchcase(op.lower(), p.lower()) for p in patterns)
def check(who, op, target, data=False):
for p, denied, scope in deny_assignments:
if p in ("*", who) and in_scope(target, scope) and m([denied], op):
return "DENY (deny assignment)"
for p, role, scope in assignments:
if p != who or not in_scope(target, scope):
continue
r = ROLES[role]
allow = r.get("DataActions", []) if data else r["Actions"]
trim = r.get("NotDataActions", []) if data else r["NotActions"]
if m(allow, op) and not m(trim, op):
return f"ALLOW via {role} at {'/'.join(scope.split('/')[-2:])}"
return "DENY (no matching assignment)"
blob = "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read"
tests = [
("ada", "Microsoft.Compute/virtualMachines/write", RG + "/providers/Microsoft.Compute/virtualMachines/vm1", False),
("ada", "Microsoft.Authorization/roleAssignments/write", RG, False),
("ada", "Microsoft.Network/virtualNetworks/read", SUB + "/resourceGroups/rg-net", False),
("ada", "Microsoft.Storage/storageAccounts/delete", ST, False),
("ada", blob, ST, True),
("bob", blob, ST, True),
]
for who, op, target, data in tests:
short = "/".join(op.split("/")[-2:])
print(f"{who} {short:<24} {check(who, op, target, data)}")ada virtualMachines/write ALLOW via Contributor at resourceGroups/rg-shop
ada roleAssignments/write DENY (no matching assignment)
ada virtualNetworks/read ALLOW via Reader at subscriptions/sub-prod
ada storageAccounts/delete DENY (deny assignment)
ada blobs/read DENY (no matching assignment)
bob blobs/read ALLOW via Storage Blob Data Reader at storageAccounts/stshop
Read the results:
- Ada's
Contributoron the resource group lets her create a VM there, butNotActionsstops her from writing role assignments. - She can read a network in another resource group because
Readerwas assigned at the subscription and inherits down. - She is Contributor on the storage account's group, yet she can't read a blob: Contributor has no
DataActions. Bob, with only a data role, can.
Real commands
Sample session (IDs made up):
# Assign a built-in role to a group at resource group scope
az role assignment create \
--assignee-object-id 9d8c7b6a-5f4e-4d3c-8b2a-1f0e9d8c7b6a --assignee-principal-type Group \
--role "Contributor" \
--scope /subscriptions/6c1f0a52-0d7e-4a8e-9a51-3c2b7e1d9f10/resourceGroups/rg-shop-dev-app
# What does someone have, including inherited assignments?
az role assignment list --assignee ada@contoso.com --all --include-inherited -o table
# Inspect a role definition
az role definition list --name "Storage Blob Data Reader" --query "[0].permissions"Principal Role Scope
---------------- ----------- ----------------------------------------------------------------
ada@contoso.com Reader /subscriptions/6c1f0a52-0d7e-4a8e-9a51-3c2b7e1d9f10
ada@contoso.com Contributor /subscriptions/6c1f0a52-.../resourceGroups/rg-shop-dev-appA custom role (assign it like a built-in one) that can restart and read VMs but not create them:
{
"Name": "VM Operator (shop)",
"Description": "Start, stop and restart VMs; read everything in compute.",
"Actions": [
"Microsoft.Compute/*/read",
"Microsoft.Compute/virtualMachines/start/action",
"Microsoft.Compute/virtualMachines/restart/action",
"Microsoft.Compute/virtualMachines/deallocate/action"
],
"NotActions": [],
"DataActions": [],
"NotDataActions": [],
"AssignableScopes": ["/subscriptions/6c1f0a52-0d7e-4a8e-9a51-3c2b7e1d9f10"]
}az role definition create --role-definition @vm-operator.jsonThings that bite
- Propagation delay. A new role assignment can take several minutes to take effect. Scripts that assign then immediately use a role should retry.
- Orphaned assignments. Deleting a user or managed identity leaves its assignments showing as "Identity not found". Clean them up, since they count toward the per-subscription limit on role assignments.
- Conditions. Role assignments can carry ABAC conditions (for example, only blobs with a given index tag, or a delegated admin who may only assign certain roles). They are powerful but harder to audit than separate roles.
Go further: IAM Concepts Across AWS, Azure and GCP asks the same access question in all three clouds.
Test yourself
A principal is Contributor on a storage account. Can it read blob data with its Entra ID token?
- Yes, Contributor allows everything
- No: Contributor has no DataActions; a data role such as Storage Blob Data Reader is needed
- Only in the portal
- Only if it is also Reader
Role A has NotActions: ["Microsoft.Compute/*/delete"]. Role B, also assigned to the user, has Actions: ["*"]. Can the user delete a VM?
- No, NotActions is a deny
- Yes: NotActions only trims role A; role B still allows it
- Only with Owner
- Only at subscription scope
Which built-in role can manage resources but cannot grant access to others?
- Owner
- Contributor
- User Access Administrator
- Role Based Access Control Administrator