AuthorizationFailed and RBAC problems
-
Phase 0: Before you start
-
Phase 1: The foundation
-
Phase 2: Day-to-day operations
-
Phase 3: Enterprise architecture
-
Phase 4: Troubleshooting step by step
-
Phase 5: Final project and career
Azure AuthorizationFailed is the error you get when an identity tries to do something its roles don’t allow. It’s probably the most common error in Azure and also one of the most useful, because the message spells out who tried, which action they tried and at what scope.
Most people read the first few words and ask for “Contributor on the subscription”, which makes the error go away and opens up a security problem. A better habit is to read all three parts and grant only the missing action, at the right scope.
In the lab you’ll create a service principal, run commands as it, and decode three different refusals: a missing role, a role at the wrong scope, and a deny assignment that beats any role you give.
| Time | You need | Cost | By the end you can |
|---|---|---|---|
| About 45 minutes | A free account where you can create app registrations, the CLI and PowerShell | Nothing at all: service principals, roles, NSGs and deployment stacks don’t cost anything | Decode AuthorizationFailed messages, fix scope and propagation problems, and spot deny assignments |
What it is, in one line
AuthorizationFailed means an identity is missing a role for a specific action at a specific scope, and the message tells you all three.
In Simple Words
The office access card
Your office access card opens some doors and not others. When a door stays shut, the reader beeps and shows “Card 4471, Priya, no access to Server Room, Floor 3”, and that single line gives security everything they need: who, which door and which floor.
If security gives you access to the Floor 2 server room by mistake, the Floor 3 door still beeps, because the permission is right but the place is wrong. Some doors also carry a red sign saying “No entry during audit, even for managers”, and even if your card would normally open them, the sign wins. That sign is a deny assignment.
Engineer's View
How Azure decides, and what the error tells you
- Role assignment: a security principal + a role definition (a list of actions) + a scope (management group, subscription, resource group or resource). Child scopes inherit it.
- The message: “The client X with object id Y does not have authorization to perform action A over scope S”. X and Y identify the caller, A is the exact operation (for example Microsoft.Network/networkSecurityGroups/write) and S is where it was tried.
- LinkedAuthorizationFailed: you have rights on the resource you’re creating but not on something it links to. Joining a subnet in another resource group, for example, needs Microsoft.Network/virtualNetworks/subnets/join/action in that group.
- Deny assignments: Azure creates these, for example through deployment stacks or managed applications. They block actions even when a role allows them, and you can’t create them yourself.
- Locks: CanNotDelete and ReadOnly locks give you ScopeLocked, not AuthorizationFailed.
- Propagation: new assignments normally apply within minutes. If the message says “please refresh your credentials”, it’s hinting at a cached token, often after a group membership change.
How it works, step by step
Here’s what Azure Resource Manager does with every write request:
- It reads the caller’s token to find out who this is.
- It works out the action, like networkSecurityGroups/write, and the full scope of the target resource.
- It gathers every role assignment for the caller (and their groups) at that scope and above, and checks whether any of those roles includes the action.
- It checks for deny assignments at that scope and above, and a matching deny wins over any allow.
- If it’s allowed, the request moves on to Azure Policy (Lesson 54) and then to the resource provider.
Each kind of refusal comes from a different step: no matching role (step 3), the right role at the wrong scope (also step 3, but the scope in the message gives it away), or a deny (step 4).
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.
| Error code | Which step said no | What to check |
|---|---|---|
| AuthorizationFailed | No role with this action at this scope | Action and scope in the message; role assignments |
| LinkedAuthorizationFailed | Missing right on a linked resource | The linked resource’s scope, such as a subnet |
| DenyAssignmentAuthorizationFailed | A deny assignment matched | Deny assignments at the scope; who created them |
| ScopeLocked | A resource lock | Locks on the resource, group or subscription |
When no built-in role is small enough
Sometimes the action in the message belongs to a big role like Network Contributor when you only want to allow that one action, and that’s where custom roles come in. This one lets a pipeline join VMs to existing subnets and do nothing else, which is the fix for the LinkedAuthorizationFailed case in the story further down. Save it as C:\azure-lab\l66\subnet-joiner.json with your subscription ID:
{
"Name": "Subnet Joiner (SaatVedha)",
"Description": "Join VMs and NICs to existing subnets only.",
"Actions": [
"Microsoft.Network/virtualNetworks/read",
"Microsoft.Network/virtualNetworks/subnets/read",
"Microsoft.Network/virtualNetworks/subnets/join/action"
],
"AssignableScopes": [ "/subscriptions/<subscription-id>" ]
}az role definition create --role-definition '@C:\azure-lab\l66\subnet-joiner.json'Assign it at the scope of the shared VNet or subnet and never any wider. To find the exact action names for a resource type, list its operations with az provider operation show, for the Microsoft.Network namespace for example. Lesson 8 covers custom roles in depth.
Run commands as a service principal and decode refusals
1Two resource groups and a service principal
Create the groups and a service principal that has no roles yet. Keep the secret in this window only:
az group create --name rg-saat-l66 --location centralindia --tags course=saatvedha-azure lesson=66 -o none
az group create --name rg-saat-l66b --location centralindia --tags course=saatvedha-azure lesson=66 -o none
$rgId = az group show --name rg-saat-l66 --query id -o tsv
$sp = az ad sp create-for-rbac --name sp-saat-l66 --query "{appId:appId, secret:password, tenant:tenant}" -o json | ConvertFrom-Json
az role assignment create --assignee $sp.appId --role Reader --scope $rgId -o none2A helper to run commands as the service principal
This function uses its own CLI profile folder, so your own login isn’t affected:
function asSp { $env:AZURE_CONFIG_DIR = "$HOME\.azure-sp66"; try { az @args } finally { Remove-Item Env:AZURE_CONFIG_DIR } }
asSp login --service-principal --username $sp.appId --password=$($sp.secret) --tenant $sp.tenant -o none
asSp group show --name rg-saat-l66 --query name -o tsvYou should see rg-saat-l66, because Reader can read the group.
The --password= form is important here: a generated secret can begin with a hyphen, and without the equals sign the CLI would take it for another option.
3The first AuthorizationFailed
Try creating an NSG as the service principal:
asSp network nsg create --resource-group rg-saat-l66 --name nsg-test -o noneYou’ll hit an error like this:
(AuthorizationFailed) The client '5b1c...' with object id '9e2f...' does not have authorization to perform action 'Microsoft.Network/networkSecurityGroups/write' over scope '/subscriptions/.../resourceGroups/rg-saat-l66/providers/Microsoft.Network/networkSecurityGroups/nsg-test' or the scope is invalid. If access was recently granted, please refresh your credentials.Read it in three parts. Who: the client ID is $sp.appId. What: networkSecurityGroups/write. Where: rg-saat-l66. Reader has no write actions, so the smallest fix is a network role on that group rather than Contributor on the subscription.
To fix it, grant Network Contributor on the group, wait two minutes and try again:
az role assignment create --assignee $sp.appId --role "Network Contributor" --scope $rgId -o none
asSp network nsg create --resource-group rg-saat-l66 --name nsg-test --query provisioningState -o tsvYou should see Succeeded. If the error still comes back straight away, give it a bit longer, because role assignments take a little time to apply.


✅ Checkpoint: You can read who, what and where from an AuthorizationFailed message, and you fixed it with a scoped role.
Break It, Then Fix It
Hang on to the service principal and both groups, since both breaks use them.
1Break it: the right role, the wrong group
The pipeline gets pointed at a second group for a new environment:
asSp network nsg create --resource-group rg-saat-l66b --name nsg-test -o noneYou’ll get an error like this:
(AuthorizationFailed) The client '5b1c...' with object id '9e2f...' does not have authorization to perform action 'Microsoft.Network/networkSecurityGroups/write' over scope '/subscriptions/.../resourceGroups/rg-saat-l66b/providers/Microsoft.Network/networkSecurityGroups/nsg-test' or the scope is invalid. ...The action and identity are the same, and the role it needs does exist, but on rg-saat-l66, while the scope in the message is rg-saat-l66b. Put the message next to the role list and it’s obvious:
az role assignment list --assignee $sp.appId --all --query "[].{role:roleDefinitionName, scope:scope}" -o tableYou should see something like this:
Role Scope
------------------- ----------------------------------------
Reader /subscriptions/.../resourceGroups/rg-saat-l66
Network Contributor /subscriptions/.../resourceGroups/rg-saat-l66To fix it, grant the role on the new group as well, not on the whole subscription:
$rgbId = az group show --name rg-saat-l66b --query id -o tsv
az role assignment create --assignee $sp.appId --role "Network Contributor" --scope $rgbId -o none
asSp network nsg create --resource-group rg-saat-l66b --name nsg-test --query provisioningState -o tsvAfter a short wait you’ll get Succeeded.
2Break it: a deny assignment beats the role
Save this as C:\azure-lab\l66\nsg.bicep and deploy it as a deployment stack that denies deletes (Lesson 42):
@description('Location for the protected NSG')
param location string = resourceGroup().location
resource nsg 'Microsoft.Network/networkSecurityGroups@2024-05-01' = {
name: 'nsg-protected'
location: location
tags: {
course: 'saatvedha-azure'
lesson: '66'
}
}az stack group create --name stack-l66 --resource-group rg-saat-l66 --template-file C:\azure-lab\l66\nsg.bicep --deny-settings-mode denyDelete --action-on-unmanage deleteResources --yes -o none
asSp network nsg delete --resource-group rg-saat-l66 --name nsg-protectedYou’ll get an error like this:
(DenyAssignmentAuthorizationFailed) The client '5b1c...' with object id '9e2f...' has permission to perform action 'Microsoft.Network/networkSecurityGroups/delete' on scope '/subscriptions/.../networkSecurityGroups/nsg-protected'; however, the access is denied because of the deny assignment with name '...' and Id '...' at scope '/subscriptions/.../resourceGroups/rg-saat-l66'.The message even tells you the client has permission. Network Contributor allows the delete, but the deny assignment the stack created overrides it, so no number of extra roles will ever fix this.
Find the deny assignment and who owns it:
az rest --method get --url "https://management.azure.com${rgId}/providers/Microsoft.Authorization/denyAssignments?api-version=2022-04-01" --query "value[].properties.{name:denyAssignmentName, description:description}" -o tableYou should see a deny assignment that mentions deployment stack stack-l66.
Fix it properly by changing the stack rather than the resource. Deploy the stack with a template that no longer includes the NSG and let the stack delete it:
'output note string = ''nsg-protected removed from the stack''' | Set-Content C:\azure-lab\l66\empty.bicep
az stack group create --name stack-l66 --resource-group rg-saat-l66 --template-file C:\azure-lab\l66\empty.bicep --deny-settings-mode denyDelete --action-on-unmanage deleteResources --yes -o none
az network nsg list --resource-group rg-saat-l66 --query "[].name" -o tsvYou should see only nsg-test, because the stack that owned nsg-protected has deleted it.

3Clean up
Delete the stack, both groups, the service principal and its CLI profile:
az stack group delete --name stack-l66 --resource-group rg-saat-l66 --action-on-unmanage deleteAll --yes
az group delete --name rg-saat-l66 --yes --no-wait
az group delete --name rg-saat-l66b --yes --no-wait
az ad app delete --id $sp.appId
Remove-Item -Recurse -Force "$HOME\.azure-sp66"✅ Checkpoint: You fixed a missing role and a wrong scope using only the message, and recognised a deny assignment that no role can beat.
This happened at work
The pipeline that suddenly needed Owner
After a network redesign, a software company’s deployment pipeline suddenly started failing with AuthorizationFailed. Its service principal had Contributor on the app’s resource group, which had always been enough, and the first suggestion in the team chat was “just give it Owner on the subscription”.
The engineer on call read the whole message instead. It was LinkedAuthorizationFailed, for the action Microsoft.Network/virtualNetworks/subnets/join/action, at the scope of a subnet in the new shared network resource group. After the redesign, the app’s VMs joined a central VNet, and the pipeline had no rights there at all.
What they changed: they made a custom role with only subnets/join/action and subnets/read and assigned it to the pipeline on the shared subnets it uses, so Owner was never needed. The review process now asks for the full error text before any role change gets approved.
Common mistakes and troubleshooting
| Mistake | What you see | What to do |
|---|---|---|
| Granting Contributor on the subscription | Error gone, security hole created | Grant the action you need at the scope in the message. |
| Role on the wrong scope | AuthorizationFailed with a different scope | Compare the scope in the message with the role assignments. |
| Ignoring LinkedAuthorizationFailed | Fails despite rights on the target | Grant rights on the linked resource, like subnet join. |
| Adding roles against a deny assignment | Still denied | Find who created the deny, and change it at the source. |
| Testing seconds after assigning | Old error repeats | Wait a few minutes, or refresh the token. |
| Confusing locks with RBAC | ScopeLocked | Remove or adjust the lock on purpose. |
Interview questions
Click a question to open it. Each one is phrased the way an interviewer would ask it, and underneath you’ll find why they ask it and one way you could answer in your own words.
Fresher level
1. What does AuthorizationFailed mean?
Why they ask this: The basic concept.
How you might answer: It means the caller doesn’t have any role that includes the requested action at that scope.
2. What three things does the message tell you?
Why they ask this: Reading skill.
How you might answer: Who it was (client and object ID), what they tried (the action) and where (the scope).
3. What is a role assignment made of?
Why they ask this: RBAC basics.
How you might answer: A security principal, a role definition and a scope.
2–5 years experience
4. A pipeline fails with LinkedAuthorizationFailed. What do you do?
Why they ask this: A real troubleshooting path.
How you might answer: I’d read the linked action and scope, which is usually a join on a subnet, public IP or some other linked resource, and grant the smallest role there, say a custom role with just the join actions.
5. Role assigned but still AuthorizationFailed. Why?
Why they ask this: Experience question.
How you might answer: It could be the wrong scope, the wrong principal (app versus user, or a different tenant), propagation delay, a cached token after group changes, or a deny assignment.
6. How do you see deny assignments?
Why they ask this: Tool knowledge.
How you might answer: In the portal under Access control, then Deny assignments, or through the denyAssignments REST API at that scope.
Senior level
7. How would you design RBAC for 30 app teams?
Why they ask this: They want governance.
How you might answer: Assign to groups, not users. Use built-in roles first and custom roles for narrow needs, assign at resource group scope, put elevated roles behind PIM, run access reviews, and keep all of it in code.
8. When would you use deny assignments or stacks?
Why they ask this: Advanced protection.
How you might answer: Deployment stacks with deny settings protect shared infrastructure from changes made outside the pipeline, even by Contributors, while still letting changes go through the stack.
9. How do you investigate who changed a role assignment?
Why they ask this: Audit thinking.
How you might answer: I’d search the Activity log for Microsoft.Authorization/roleAssignments/write and delete to get the caller, then check the Entra ID audit logs for group membership changes.
Quick quiz
Q1. Which part of the message tells you where access is missing?
- Client ID
- Scope
- Request ID
- Correlation ID
Show answer
B — The scope is where the action was attempted.
Q2. The message says the client has permission but a deny assignment blocks it. Fix?
- Add Owner
- Change whatever created the deny
- Wait 10 minutes
- Use another region
Show answer
B — Deny beats any role.
Q3. Joining a subnet in another group fails with?
- NotFound
- LinkedAuthorizationFailed
- ScopeLocked
- Conflict
Show answer
B — You need rights on the linked subnet.
Q4. A CanNotDelete lock returns?
- AuthorizationFailed
- ScopeLocked
- Forbidden
- InvalidTemplate
Show answer
B — Locks have their own error.
Q5. Best fix for a missing write on one group?
- Contributor on subscription
- A scoped role on that group
- Owner on tenant
- Disable RBAC
Show answer
B — Grant least privilege at the right scope.
Quick recap
You can now turn an AuthorizationFailed message into the smallest fix that’s correct.
- Read who, what and where in each message.
- Grant the missing action at the scope in the message.
- LinkedAuthorizationFailed points at a linked resource.
- Deny assignments beat roles, so change them where they come from.
- Give new assignments a few minutes to apply.
Next lesson
Lesson 67: Deployment failures: RequestDisallowedByPolicy and Bicep errors → You fix failed deployments: policy denials, Bicep and ARM errors, quota limits and how to read the deployment operations.
Further reading: Azure AuthorizationFailed
Want to go deeper into Azure AuthorizationFailed? See Microsoft’s Troubleshoot Azure RBAC and Understand Azure deny assignments. You can also see the full plan for this course on the Azure Cloud Administration course page.
