Azure RBAC: Roles, Scopes and Role Assignments

Azure RBAC (role-based access control) is the part of Azure that decides what each person is allowed to do with your resources. In Lesson 5, Entra ID told Azure who Asha is, and now RBAC decides she can manage one resource group and nothing more.

Any RBAC grant comes down to three questions: who gets it, which role they get, and where it applies (the scope). Once you start reading access in those terms, most “access denied” tickets take you a couple of minutes.

In the lab you’ll give the helpdesk group Contributor on one resource group, sign in as Asha in a separate CLI session and see where her access starts and where it stops. After that you’ll run into the two RBAC surprises that trip up nearly every new admin.

TimeYou needCostBy the end you can
About 50 minutesThe CLI, Asha’s password from Lesson 5, a private browser windowLess than USD 0.01 (one small storage account for a few minutes)Grant, test and remove Azure roles at the right scope, and read AuthorizationFailed errors

What it is, in one line

Azure RBAC gives a role (what you can do) to a person, group or app (who) at a scope (where), and Azure checks it on each request.

In Simple Words

Keys for a block of flats

A caretaker has a big ring of keys. The plumber gets the key to flat 12 for the day, the building manager gets one that opens every flat, and the cleaner gets the corridor keys but none for the flats.

So the key is the role, the person holding it is the who, and the flats it opens are the scope. And nobody gets the master key because it saves the caretaker a trip.

There’s one more detail. The plumber’s key opens the door to flat 12, but it won’t open the locked drawer inside where the owner keeps papers, which needs its own key. In Azure that’s the gap between managing a storage account and reading the files inside it.

Engineer's View

Role definitions, assignments and the data plane

  • Role definition: a list of operations the role allows. Actions cover the control plane (creating, changing and deleting resources), DataActions cover the data inside some services (blobs, queues, Key Vault secrets), and NotActions take things away from Actions.
  • Built-in roles to know: Reader can look at everything, Contributor can manage everything but can’t grant access, and Owner can do all of it including granting access. User Access Administrator and Role Based Access Control Administrator manage access only. On top of these there are lots of service roles, like Virtual Machine Contributor and Storage Blob Data Reader.
  • Role assignment: a principal (user, group, service principal or managed identity) plus a role plus a scope. The scope can be a management group, a subscription, a resource group or a single resource, and whatever you grant flows down to everything below it.
  • Permissions add up. If Asha has Reader on the subscription and Contributor on one group, she’s a Contributor in that group and a Reader everywhere else. The only thing that can take an allow away is a deny assignment, and Azure creates those itself for some managed features (Lesson 8).

Contributor has Actions: *, but its NotActions include Microsoft.Authorization/*/Write and Microsoft.Authorization/*/Delete, so a Contributor can build a whole environment and still can’t give anyone else access to it. Microsoft designed it that way on purpose.

None of the built-in control-plane roles have DataActions for blob data. A Contributor can create a storage account and even list its keys, but when they sign in with Entra ID (--auth-mode login) they can’t read or write blobs until someone gives them a data role such as Storage Blob Data Contributor.

A couple of limits to remember: a subscription can hold up to 4,000 role assignments, and changes normally take effect within a few minutes. When you add someone to a group, they often have to sign out and back in, because their group membership is carried inside the token.

How it works, step by step

Each time a request reaches Azure Resource Manager, RBAC goes through these steps:

Azure RBAC decision flow from token to AuthorizationFailed
  1. It reads the caller’s object ID and group memberships from the token.
  2. It collects the role assignments for those principals at the target scope and at each parent scope above it.
  3. It adds up the allowed Actions from those roles (or DataActions for data requests) and takes away their NotActions.
  4. It checks deny assignments, and if one matches, the deny wins.
  5. If the requested operation (say Microsoft.Network/networkSecurityGroups/write) is in the allowed set, the request moves on to Azure Policy. If not, Azure returns AuthorizationFailed.

An AuthorizationFailed message names the caller, the operation and the scope. Read it slowly, because it tells you which role is missing and where it has to be granted.

Azure RBAC control plane vs data plane roles for storage

What keeps all this manageable is one habit: least privilege, through groups, at the smallest scope that works. Give Contributor on a resource group instead of the subscription, give it to a group instead of a person, and look at it again from time to time.

Hands-on lab: give Asha exactly the access she needs

Before you run any command, double-check it

Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.

You’ll work in two CLI sessions, your own admin one and Asha’s. The AZURE_CONFIG_DIR variable makes that possible, because it tells the CLI to keep a second, separate sign-in in a different folder. Run each block in your normal admin window unless it says Asha’s window.

1Create two resource groups

Run this:

$sub = az account show --query id -o tsv
$tenant = az account show --query tenantId -o tsv
foreach ($g in 'rg-saat-l07','rg-saat-l07b') { az group create --name $g --tags course=saatvedha-azure lesson=07 -o none }
$rg = az group show --name rg-saat-l07 --query id -o tsv
$rg

You should see something like this:

/subscriptions/6f1c2d3e-4a5b-4c6d-8e9f-0a1b2c3d4e5f/resourceGroups/rg-saat-l07

2Look inside the Contributor role

Run this:

az role definition list --name Contributor --query "[0].permissions[0].{actions:actions, notActions:notActions}" -o json

You should see something like this (the notActions list is longer):

{
  "actions": [
    "*"
  ],
  "notActions": [
    "Microsoft.Authorization/*/Delete",
    "Microsoft.Authorization/*/Write",
    "Microsoft.Authorization/elevateAccess/Action",
    ...
  ]
}

It’s everything, except anything under Microsoft.Authorization that writes or deletes, and those are the role assignment operations.

3Give the helpdesk group Contributor on one resource group

Run this:

$grp = az ad group show --group grp-saat-helpdesk --query id -o tsv
az role assignment create --assignee-object-id $grp --assignee-principal-type Group --role Contributor --scope $rg -o none
az role assignment list --scope $rg --query "[].{who:principalName, role:roleDefinitionName}" -o table

You should see something like this:

Who                Role
-----------------  -----------
grp-saat-helpdesk  Contributor

--assignee-principal-type Group tells Azure what kind of object you’re pointing at, so it skips a lookup that can fail in the first minutes after a group is created.

4Sign in as Asha in her own CLI session

Open a second PowerShell window (Asha’s window) and run this:

$env:AZURE_CONFIG_DIR = 'C:\azure-lab\asha-cli'
az login --tenant <your-tenant-id>
az group list --query "[].name" -o tsv

Swap <your-tenant-id> for the value of $tenant in your admin window. When the sign-in window opens, pick Use another account, sign in as Asha and approve the MFA prompt.

You should see this:

rg-saat-l07

Asha sees only the group she was given, and rg-saat-l07b doesn’t show up in her list at all.

5Asha builds something where she is allowed, and tries where she isn’t

In Asha’s window, run this:

az network nsg create --resource-group rg-saat-l07 --name nsg-saat-l07 --tags course=saatvedha-azure lesson=07 --query "NewNSG.provisioningState" -o tsv
az network nsg create --resource-group rg-saat-l07b --name nsg-saat-l07b --tags course=saatvedha-azure lesson=07

You should see something like this:

Succeeded
(AuthorizationFailed) The client 'asha.rao@priyakoutlook.onmicrosoft.com' with object id '3c2b1a09-...'
does not have authorization to perform action 'Microsoft.Network/networkSecurityGroups/write' over scope
'/subscriptions/6f1c2d3e-.../resourceGroups/rg-saat-l07b/providers/Microsoft.Network/networkSecurityGroups/nsg-saat-l07b'
or the scope is invalid. If access was recently granted, please refresh your credentials.
Code: AuthorizationFailed

A network security group is free, which makes it a safe thing to test with. The first one goes through and the second one fails with a message that names the action and the scope, which is least privilege doing its job.

Azure RBAC lab: Asha succeeds in rg-saat-l07 and gets AuthorizationFailed in rg-saat-l07b
Example output in Asha’s window. Your IDs and domain will be different.

6See all of Asha’s access in one view

Back in your admin window, run this:

$domain = az rest --method get --url "https://graph.microsoft.com/v1.0/domains" --query "value[?isDefault].id" -o tsv
az role assignment list --assignee "asha.rao@$domain" --all --include-groups --query "[].{role:roleDefinitionName, scope:scope}" -o table

You should see something like this:

Role         Scope
-----------  --------------------------------------------------------------------------
Contributor  /subscriptions/6f1c2d3e-4a5b-4c6d-8e9f-0a1b2c3d4e5f/resourceGroups/rg-saat-l07

--include-groups adds the roles she gets through group membership, and that’s how most access arrives at work. Leave it off and the list comes back empty, so you’d think she has no access at all.

✅ Checkpoint: Asha can create things in rg-saat-l07 and gets AuthorizationFailed in rg-saat-l07b.

Break It, Then Fix It

Asha is a Contributor, so you’d expect her to do anything in her group. She can’t, and these two limits cause more tickets than anything else.

1Break it: a Contributor tries to give someone access

In Asha’s window, run this:

$ravi = az ad user list --filter "startswith(displayName,'Ravi')" --query "[0].id" -o tsv
az role assignment create --assignee-object-id $ravi --assignee-principal-type User --role Reader --resource-group rg-saat-l07

You’ll get an error like this:

(AuthorizationFailed) The client 'asha.rao@priyakoutlook.onmicrosoft.com' with object id '3c2b1a09-...'
does not have authorization to perform action 'Microsoft.Authorization/roleAssignments/write' over scope
'/subscriptions/6f1c2d3e-.../resourceGroups/rg-saat-l07/providers/Microsoft.Authorization/roleAssignments/...'
or the scope is invalid. If access was recently granted, please refresh your credentials.
Code: AuthorizationFailed

Microsoft.Authorization/roleAssignments/write sits in Contributor’s NotActions. Handing out access needs Owner, User Access Administrator, or the narrower Role Based Access Control Administrator, which you’ll limit with conditions in Lesson 8.

To fix it, either do the assignment yourself from the admin window or decide Asha shouldn’t be doing it in the first place. Here you’ll do it yourself:

$ravi = az ad user list --filter "startswith(displayName,'Ravi')" --query "[0].id" -o tsv
az role assignment create --assignee-object-id $ravi --assignee-principal-type User --role Reader --scope $rg -o none

2Break it: Contributor can’t read the data inside storage

In Asha’s window, create a small storage account and try to add a container with her Entra ID sign-in:

$st = 'stsaat07' + (Get-Random -Maximum 999999)
az storage account create --name $st --resource-group rg-saat-l07 --sku Standard_LRS --kind StorageV2 --tags course=saatvedha-azure lesson=07 -o none
az storage container create --name reports --account-name $st --auth-mode login
$st

You’ll get an error like this:

You do not have the required permissions needed to perform this operation.
Depending on your operation, you may need to be assigned one of the following roles:
    "Storage Blob Data Owner"
    "Storage Blob Data Contributor"
    "Storage Blob Data Reader"
    "Storage Queue Data Contributor"
    "Storage Queue Data Reader"
    "Storage Table Data Contributor"
    "Storage Table Data Reader"

If you want to use the old authentication method and allow querying for the right account key, please use the "--auth-mode" parameter and "key" value.
stsaat07418273

Creating the account was a control-plane action, and Contributor allows that. Creating a container with --auth-mode login is a data action, so it needs a data role, and the CLI even suggests the old shortcut of using the account key.

Don’t take it, because a key gives full access to everything in the account (Lesson 24).

The fix is to give the group a data role on that one storage account from your admin window. Use the account name Asha’s window printed:

$st = 'stsaat07418273'
$stId = az storage account show --name $st --resource-group rg-saat-l07 --query id -o tsv
az role assignment create --assignee-object-id $grp --assignee-principal-type Group --role "Storage Blob Data Contributor" --scope $stId -o none

Give it two minutes, then run this again in Asha’s window:

az storage container create --name reports --account-name $st --auth-mode login

You should see this:

{
  "created": true
}
Azure RBAC errors: Contributor cannot assign roles and needs a data role for blobs
Example output of both RBAC limits.

3Clean up

In Asha’s window, sign her out and close it:

az logout
Remove-Item Env:AZURE_CONFIG_DIR
Remove-Item C:\azure-lab\asha-cli -Recurse -Force

In your admin window, remove the roles and the groups:

$stId, $rg | ForEach-Object { az role assignment delete --scope $_ }
az group delete --name rg-saat-l07 --yes
az group delete --name rg-saat-l07b --yes
C:\azure-lab\Find-LabResources.ps1

You should see this:

Nothing tagged course=saatvedha-azure is left.

az role assignment delete --scope with no principal removes all the assignments at that exact scope, which is what you want in this lab. At work, be careful with it.

✅ Checkpoint: Both RBAC limits reproduced and fixed, Asha signed out, and nothing tagged for the course is left.

This happened at work

“Just make them Owner” on a Friday

This was at a retail company. Their new data team had to get a reporting app deployed in a hurry, the Azure admin was on leave, and a manager asked the cloud lead to “just make the team Owner on the subscription for now”. The lead did it at 6 p.m. on a Friday.

Over the weekend one of the data engineers followed a guide they’d found online and, being an Owner, gave a third-party analytics tool’s service principal Contributor on the subscription, which was the same subscription that held the payment API. Nothing went wrong that week. A month later the security team found the tool’s credentials in a public code repository, and they still had Contributor on production.

What they changed: nobody below the platform team keeps standing Owner any more. Teams get Contributor on their own resource groups through Entra groups, and anything beyond that goes through PIM with approval and a time limit. People who need to hand out roles get Role Based Access Control Administrator with conditions, so they can’t grant Owner.

On top of that, a weekly report now lists each Owner and each service principal that has Contributor or higher.

Common mistakes and troubleshooting

MistakeWhat you seeWhat to do
Giving Owner because “it works”People who can hand out access to anyoneGive Contributor, and add narrow access roles only when someone needs them.
Assigning roles to single usersHundreds of assignments, impossible to reviewAssign to groups.
Forgetting data rolesContributor can’t read blobs, queues or secretsAdd the data role at the smallest scope that works, for example Storage Blob Data Reader.
Testing right after adding someone to a groupAuthorizationFailed for a few minutesSign out and back in so the token picks up the new group, and give it a few minutes.
Looking for access without --include-groups“This user has no roles” when they doList with --all --include-groups.
Using account keys to “fix” accessFull access to all data, shared secretsSign in with Entra ID and use data roles, not keys.

Interview questions

Click a question to open it. Each one is worded the way an interviewer would put it, and underneath you’ll find why they ask it and one way you could answer in your own words.

Fresher level

1. What three things make up an Azure role assignment?

Why they ask this: A basic RBAC concept they expect you to know cold.

How you might answer: There’s a security principal, which is the who, like a user, a group or a managed identity. Then a role definition, which is what they can do, and a scope, which is where it applies: a management group, a subscription, a resource group or one resource.

2. What’s the difference between Owner and Contributor?

Why they ask this: They want to see you know the access-management boundary.

How you might answer: Both of them can create and manage resources. The difference is that an Owner can also give other people access and a Contributor can’t, because role assignment writes are in Contributor’s NotActions.

3. Why give roles to groups instead of users?

Why they ask this: They want good habits around scale and reviews.

How you might answer: With groups, a joiner or a leaver is just a membership change and you don’t have to hunt through assignments. And reviewing a handful of group assignments is far easier than going through hundreds of individual ones.

2–5 years experience

4. A user is Contributor on a storage account but gets “permission” errors uploading a blob with the CLI. Why?

Why they ask this: They’re checking that you know control plane from data plane, which comes up all the time in real work.

How you might answer: Contributor is a control-plane role, and uploading with --auth-mode login is a data action, so they need a data role like Storage Blob Data Contributor at the account or container scope. I’d assign that to their group and wait a couple of minutes, rather than hand them the account key.

5. How do you read an AuthorizationFailed error?

Why they ask this: They want to see you use the error’s details instead of guessing.

How you might answer: The error tells you the client, the action, like Microsoft.Network/networkSecurityGroups/write, and the scope. I’d check what role assignments that principal has at that scope or above, including through groups, and whether any of those roles include the action. If access was granted only a few minutes ago, I’d ask them to sign in again, since group changes need a fresh token.

6. Someone was added to the right group but still gets access denied. What do you check?

Why they ask this: They want propagation and token awareness.

How you might answer: First I’d confirm they’re in the group that holds the role and that the role’s scope covers the resource. Then I’d think about timing, because role and group changes can take a few minutes and group membership sits in the token, so they should sign out and in. I’d also look for a deny assignment on that scope, since az role assignment list won’t show it.

Senior level

7. How would you let a team lead manage access for their own team without the risk of them handing out Owner?

Why they ask this: They want delegation with guardrails.

How you might answer: I’d make the lead Role Based Access Control Administrator on the team’s resource groups, with a condition that lets them assign only a few roles, say Reader and Virtual Machine Contributor, and only to members of the team’s groups. They can handle the daily requests themselves, but they have no way to give out Owner or User Access Administrator.

8. How would you find and reduce excessive access in a subscription that has grown for years?

Why they ask this: They want a practical review plan.

How you might answer: I’d start by exporting the role assignments with az role assignment list --all --include-inherited and flagging Owner and User Access Administrator, assignments to single users, and service principals with Contributor or more. Unknown or orphaned identities go once I’ve checked the sign-in logs. After that I’d move people into groups, put the high roles behind PIM and run access reviews each quarter.

9. An app’s service principal needs to write blobs to one container. What would you grant?

Why they ask this: They’re checking least privilege at the right scope and the right plane.

How you might answer: I’d give Storage Blob Data Contributor on that one container, not on the storage account and definitely not Contributor on the resource group. And if the app runs in Azure, I’d use a managed identity so there’s no service principal secret to look after.

Quick quiz

Q1. Which role can create resources but can’t grant access?

  1. Owner
  2. Contributor
  3. User Access Administrator
  4. Reader
Show answer

B — Contributor’s NotActions remove role assignment writes.

Q2. Asha has Reader on the subscription and Contributor on rg-saat-l07. What can she do in rg-saat-l07?

  1. Only read
  2. Contributor actions
  3. Nothing
  4. Owner actions
Show answer

B — Permissions add up; she gets Contributor there.

Q3. What does reading blob data with --auth-mode login need?

  1. Contributor
  2. A data role such as Storage Blob Data Reader
  3. Owner on the subscription
  4. A storage account key
Show answer

B — Blob data is the data plane and needs a data role.

Q4. Which option shows roles a user gets through groups?

  1. --include-inherited
  2. --include-groups
  3. --all-users
  4. --expand
Show answer

B — The --include-groups option adds assignments to groups the user belongs to.

Q5. Why did AZURE_CONFIG_DIR let you sign in as Asha separately?

  1. It changes the tenant
  2. It makes the CLI store its sign-in in another folder
  3. It disables MFA
  4. It creates a new subscription
Show answer

B — The CLI keeps tokens in that folder, so two folders give two separate sessions.

Quick recap

You can now give access precisely and read an RBAC error like a map.

  • A role assignment is who + role + scope, and it is inherited downward.
  • Contributor manages resources but can’t grant access; Owner can.
  • Control-plane roles don’t give data access; add data roles like Storage Blob Data Reader.
  • Permissions add up; AuthorizationFailed names the missing action and scope.
  • Use groups, the smallest scope, and --include-groups when you check access.

Next lesson

Lesson 8: Azure custom roles, deny assignments and conditions → You’ll build a custom role that does one job only, and see the two ways Azure can still say no.

Further reading: Azure RBAC

Want to go deeper into Azure RBAC? Microsoft’s overview is What is Azure role-based access control (Azure RBAC)?, and every built-in role is listed in Azure built-in roles. You can also see the full plan for this course on the Azure Cloud Administration course page.

Scroll to Top

This website uses cookies

We use a few cookies to keep this site working. If you allow it, we also use Google Analytics to count visits so we can improve our lessons. You can accept all, deny the optional ones, or choose what to allow.