D1 · Identity and Access

RBAC — Role-Based Access Control

Azure's authorization system. The AZ-104 tests role assignment, scope, inheritance, custom roles, and the principle of least privilege.

RBAC — concept and 3 components

controls who can do what on which resources in Azure. A role assignment = Security Principal + Role Definition + Scope.

👤

Security Principal

Who is the role assigned to?

  • User
  • Group — recommended
  • Service Principal (app)
📋

Role Definition

What can they do?

  • actions: allowed operations
  • notActions: excluded from actions
  • dataActions: operations on data
  • notDataActions: excluded
🎯

Scope

On which resources?

  • Individual resource
Icon-general-11

Scope hierarchy

Roles are inherited downward. Assigning at a higher scope affects all child resources.

Management Group

/providers/Microsoft.Management/managementGroups/{id}

↳ Affects every subscription in the group and their resources

Subscription

/subscriptions/{subscriptionId}

↳ Affects all RGs and resources in that subscription

Resource Group

/subscriptions/{id}/resourceGroups/{name}

↳ Affects all resources within the RG

Resource

/subscriptions/{id}/resourceGroups/{rg}/providers/{type}/{name}

↳ Only that specific resource

Inheritance: A role assigned at the Subscription level → the user has that role in EVERY RG and resource in that sub. Permissions flow from top to bottom, never the other way.

Key built-in roles

Azure has 300+ built-in roles. The AZ-104 tests the fundamental ones and when to use each.

RoleCanCannotTypical case
OwnerEverything, including assigning roles—Subscription technical lead
ContributorCreate, modify, delete resourcesAssign RBAC roles or Azure PoliciesSenior developers, DevOps
ReaderView all resources and configsAny write operationAuditors, management, L1 support
User Access AdministratorManage RBAC role assignmentsCreate/modify resourcesAdmin who manages permissions without touching resources
Virtual Machine ContributorCreate and manage VMsAccess the VNet/Storage where they live, or assign rolesVM operations team
Storage Blob Data ContributorRead/write/delete data in blobsManage the storage account itself (keys, configs)Apps that read/write blobs
AdministratorAll operations in Key Vault (secrets, keys, certs)Manage the Key Vault resource itself in ARMSecurity team managing secrets

Control vs Data plane — a critical distinction

Control plane (ARM)

Managing the RESOURCE: create, configure, delete. E.g., creating a blob container, changing the Storage tier. Controlled by actions/notActions.

Data plane

Accessing the DATA within the resource: reading/writing blobs, reading Key Vault secrets. Controlled by dataActions/notDataActions. Requires specific data roles.

Custom Roles

For when no built-in role fits your exact needs. Requires Entra ID P1 or higher.

Anatomy of a Custom Role (JSON)

{
  "Name": "VM Operator - Read Only + Start/Stop",
  "Description": "Can view VMs and start/stop them",
  "Actions": [
    "Microsoft.Compute/virtualMachines/read",
    "Microsoft.Compute/virtualMachines/start/action",
    "Microsoft.Compute/virtualMachines/deallocate/action"
  ],
  "NotActions": [],
  "DataActions": [],
  "AssignableScopes": [
    "/subscriptions/{subscriptionId}"
  ]
}

Creating a — options

Azure Portal

Entra ID → Roles and administrators → New custom role (Entra roles only) or Subscription → Access control (IAM) → Add custom role → Start from scratch / clone

PowerShell

New-AzRoleDefinition -InputFile "role.json" — accepts the JSON with the full definition.

Azure CLI

az role definition create --role-definition role.json

ARM/Bicep

A resource of type Microsoft.Authorization/roleDefinitions — for IaC.

Limits

  • • Maximum of 5,000 custom roles per tenant
  • • AssignableScopes defines where it can be assigned (not where it applies)
  • • NotActions is not a "deny" — it only subtracts from Actions
  • • To explicitly deny → use Deny Assignments (not user-editable)

Inheritance and Deny Assignments

Inheritance rules

1.Permissions are ADDITIVE — if you have Reader on the Sub and Contributor on an RG, in that RG you are Contributor.
2.There is no upward inheritance — Contributor on an RG grants you nothing on the parent Subscription.
3.The most permissive role wins — multiple assignments are unioned, not intersected.
4.The one exception: Deny Assignments — they take priority over any Allow.

Deny Assignments

They block specific actions even when there's an Allow in another role. Created by Azure Blueprints and Azure Managed Applications — users cannot create Deny Assignments directly.

PriorityAlways wins over any Allow (RBAC or Custom)
CreationOnly by Azure (Blueprints, Managed Apps). Not by users.
ScopeInherited the same way as roles (downward)
ExcludedSubscription owners or specific principals can be excluded

PIM — Privileged Identity Management

Just-in-time (JIT) access to privileged roles. Reduces the attack surface by eliminating standing permissions. Requires Entra ID P2.

Eligible vs Active

Permanent Active

The role is permanently assigned — the user ALWAYS has the access, with no action required.

High — if the account is compromised, the attacker has immediate access

Eligible (PIM)

The user is "eligible" for the role but must explicitly activate it. Activation can require justification, MFA, approval from another admin.

Low — limited access window, auditable, approvable

PIM activation flow

1.The admin configures the role as "Eligible" for the user (duration: 1-365 days)
2.The user goes to PIM → "My roles" → selects the eligible role
3.The user activates the role: enters a justification, duration (e.g., 1 hour), completes MFA
4.If the role requires approval → the approver receives a notification and approves/rejects
5.The role is active for the requested duration → it deactivates automatically
6.The whole activation is recorded in the audit log with justification and approver

PIM also covers: Entra ID roles (Global Admin, etc.) in addition to Azure RBAC roles. And it enables Access Reviews to clean up stale assignments.

Debugging effective access

When a user says "I don't have access" or "I have too much access," these are the tools to diagnose it.

Diagnostic tools

Access control (IAM) → Check access

On any resource/RG/Subscription: search for a user/SP and show every role they have at that scope (including inherited ones).

Portal: Resource → IAM → Check access → search by user

My Access portal

The user can see their own access, request access to packages (Entitlement Management), and review their active assignments.

aka.ms/myaccess

az role assignment list

Lists all role assignments for a principal or specific scope.

az role assignment list --assignee user@contoso.com --all

Get-AzRoleAssignment

PowerShell equivalent. Useful for audit scripts.

Get-AzRoleAssignment -SignInName user@contoso.com

Activity Log

Records role assignment changes: who assigned which role to whom, when. 90-day retention.

Monitor → Activity Log → filter by "Create role assignment"

Common problems and causes

User has access they shouldn't

Cause: Inheritance from a higher scope (Subscription or MG). Verify with "Check access" at a higher scope.

Solution: Revoke the assignment at the correct scope

"Unauthorized action" even though the role allows it

Cause: The specific resource might have a Resource Lock, or the action is a dataAction that requires a different role.

Solution: Check locks and whether the operation is control plane or data plane

Role change has no immediate effect

Cause: Access tokens are valid for up to 1 hour. The change applies on the next token.

Solution: Wait up to 1 hour, or have the user sign out and back in

Deny Assignment blocks an otherwise permitted action

Cause: An Azure Blueprint or Managed App created a Deny Assignment that takes priority over all roles.

Solution: Identify the Deny Assignment in IAM → Deny assignments and contact the Blueprint owner

Limits and operational considerations

RBAC limits in Azure

Role assignments per subscription2,000 (hard limit of Azure Resource Manager)

Critical for large tenants — use groups instead of individual users

Role assignments per MG500

Less common but worth keeping in mind

Custom roles per tenant5,000

Usually not a problem

Scopes in AssignableScopes per custom role2,000
Classic administratorsBeing retired — Co-Admin, Service Admin

Migrate to modern RBAC — classic accounts have effective Owner access

Scalable RBAC management

Use groups, not individual users

Assign roles to security groups. Manage group membership. 1 role assignment for 100 people uses only 1 of the 2,000 limit.

Principle of least privilege

Always assign the most restrictive role that allows the work to be done. Review periodically with Access Reviews (P2).

Most specific scope possible

Assign at the Resource Group, not the Subscription, if access is only needed for resources in that RG. Reduces the blast radius.

Time-bound assignments

In IAM → Add role assignment → there's an expiration date option. Without PIM, RBAC assignments can natively be time-limited.

Azure Policy vs RBAC — complementary, not substitutes

The AZ-104 tests this distinction. Many people confuse them because both "control" things in Azure.

RBAC answers: who can do what?

Controls the operations a security principal can perform. "User X can create VMs in this RG."

answers: what state should the resource have?

Controls the properties and configuration of resources. "All VMs must have tags. All Storage must be encrypted."

AspectAzure RBACAzure Policy
GoalControl who can execute operations (CRUD)Control the state/configuration of resources
Question it answersCan I create this VM?Does this VM comply with organizational rules?
Denial effectThe operation cannot be executed (not authorized)The resource cannot be created if it violates the policy (Deny effect)
ScopeMG > Subscription > RG > ResourceMG > Subscription > RG (not individual resources)
GranularityPer operation (e.g., read-only for VMs in an RG)Per resource property (e.g., required tag, allowed region)
RetroactiveNo — only applies to future operationsYes — Audit can flag existing non-compliant resources
Used forIAM — who manages infrastructureCompliance — what configurations are acceptable

Combined example

RBAC: a Developer has Contributor on RG-Dev

They can create VMs, modify storage, deploy apps in that RG.

Policy: "VMs only in East US, no premium SKU"

Even though the dev CAN create VMs (RBAC), if they try to create one in West Europe or with a premium SKU, the Policy rejects it.

RBAC controls capability. Policy controls the rules. You need both.

Did you get this topic?

Test what you just learned

An external auditor needs to review all resources in an Azure subscription without being able to modify anything. Which RBAC role should be assigned to them?

Ready to test "Role-Based Access Control"?

Put what you learned to the test with original AZ-104 exam questions.

Start AZ-104 mock exam

Unlimited mock exams with the Pro plan

Log in to track your progress.