Hour 3: Identity and Access (Entra ID, RBAC, and PIM)

The management groups are in place and the policies are assigned. Now answer the question: who can do what, at which layer, on what authority, and for how long. Tenant boundary → RBAC inheritance → custom roles → PIM just-in-time access → break-glass and Conditional Access → deployment identity → managed identities and Lighthouse → review and troubleshooting
Microsoft Entra IDAzure RBACPIM: requires Entra ID P2 or ID GovernanceAzure mandatory MFA phase 2: enforced in stages from 2025-10-01Checked against official docs · 2026-11-18
Do not experiment in a production tenant. All labs in this hour should be done in a dedicated sandbox Entra tenant (a free new tenant or a company-provided lab tenant). This hour creates break-glass accounts, Conditional Access policies, PIM eligible assignments, and a root-scope role assignment. A mistake at any of these steps in a production tenant could lock every administrator in the organization out. All cloud commands in this hour were not run against a real tenant; their outputs are marked as examples.
\n Overall learning objectives\n
  • Explain the trust relationship between Azure subscriptions and Entra tenants. Decide when a single tenant is enough and when a multitenant setup is required. Know what B2B, cross-tenant access settings, and Azure Lighthouse each solve.
  • Read how Azure RBAC makes a decision: security principal + role definition + scope, inherited downward through the management group chain alz → landingzones → corp → subscription → resource group. Tell Entra roles apart from Azure roles, and control plane from data plane.
  • Apply the ALZ platform team / application team split: the 5 custom roles in the ALZ library (Subscription-Owner, Application-Owners, Network-Management, Network-Subnet-Contributor, Security-Operations), and use a conditional Role Based Access Control Administrator role to delegate role-assignment rights safely.
  • Write least-privilege custom roles. Know that NotActions is not "deny," that AssignableScopes can hold only one management group, and that a role with DataActions cannot be assigned at management group scope.
  • Use PIM to change high-privilege roles such as Owner and User Access Administrator into "eligible + activate + approval + time-limited." Explain the licensing requirement (Microsoft Entra ID P2 or Microsoft Entra ID Governance) and what happens when the license expires.
  • Create at least two break-glass accounts, and use Conditional Access to protect administrators. Understand how the two phases of Azure mandatory MFA affect the portal, CLI, PowerShell, and IaC tools, and why automation that uses a user account as a service account must move to workload identities.
  • Design deployment identities for platform and application pipelines: workload identity federation (OIDC), user-assigned managed identities, and least-privilege identities split by environment. Use managed identities for workloads, and use Azure Lighthouse for cross-tenant operations.

1-hour timetable

#TimeModuleCore contentAnimation / interactionLab (sandbox tenant)
0Before classSetup: test users, groups, and starting permissionsElevate access, confirm the management group hierarchy, create test users and security groupsStarting-permissions self-check5 groups + 3 test users
100–06Tenant designSubscription trust in one tenant, single tenant vs multitenant, B2B and cross-tenant access settings, administrative unitsTenant topology decision toolCheck the subscription-to-tenant binding
206–13RBAC and ALZ role splitThe three parts of a role assignment, inheritance, Entra roles vs Azure roles, platform/application team split table, conditional delegationRBAC decision simulator (evaluates down the management group tree)Assign roles on platform / corp / subscription and verify
313–21Custom roles and least privilegeActions / NotActions / DataActions, wildcards, AssignableScopes restrictions, the 5 ALZ custom rolesCustom role builder (checks in real time whether an operation is allowed)Create the Landing Zone VM Operator role
421–28PIM just-in-time accessEligible vs active assignment, activation settings, approval, PIM for Groups, licensing and consequences of expiryCore animation: eligibility → activation and approval → role assignment takes effect → RBAC decision → expiry and revocationConvert Owner to PIM eligibility and activate it once
528–35Break-glass and Conditional Accessbreak-glass accounts, FIDO2/CBA, CA exclusions and monitoring, the two phases of Azure mandatory MFA"Will this sign-in be blocked?" evaluator2 emergency accounts + report-only CA policy + sign-in alerts
635–42Deployment identity: workload identity federationSplitting platform and application pipeline identities, federated credential matching rules, the 20-credential limit, flexible federated identity credentials (preview)Core animation: OIDC token exchange (including a failure on subject mismatch)Configure federated credentials for id-alz-platform-plan / -apply
742–50Managed identities and Azure LighthouseSystem-assigned vs user-assigned, getting tokens from IMDS, managed identities for DINE policies, Lighthouse authorization and limitsTwo-scenario animation: IMDS token / Lighthouse projectionmyapp reads Key Vault with a managed identity; Lighthouse template walkthrough
850–60Identity review and troubleshootingResource Graph inventory of role assignments, access reviews, common authorization errorsReview scorecard + interactive troubleshooting treeExport a role assignment report and find 5 types of risk
—After classCheat sheet · Capstone labDeliver a complete identity baseline for a new application landing zoneFinal quiz (12 questions)Capstone lab

Knowledge coverage matrix

Target skillM1M2M3M4M5M6M7M8Key commands / objectsLab
Tenant boundary and cross-tenant collaboration✓·····✓✓az account show, cross-tenant access settingsSubscription ownership
RBAC inheritance and decisions·✓✓✓·✓✓✓az role assignment list --include-inheritedLayered assignment
ALZ platform / application team split·✓✓✓·✓·✓Application-Owners, Subscription-Ownermyapp application team
Least privilege and custom roles··✓··✓✓✓az role definition createVM Operator role
Delegating role-assignment rights (ABAC condition)·✓✓····✓--condition, --condition-version 2.0Restricted access administrator
PIM and just-in-time access···✓✓·✓✓roleEligibilityScheduleRequestsOwner eligibility
Break-glass, Conditional Access, mandatory MFA···✓✓✓·✓CA policies, SigninLogsbreak-glass + alerts
Deployment identity and managed identities····✓✓✓✓az identity federated-credential createPlatform pipeline identity
Azure Lighthouse✓·····✓·registrationDefinitionsTemplate walkthrough

What this hour does not cover (and where to learn it)

TopicWhy it is not in this hourWhere to learn it
Setting up the management group hierarchy, subscription placement, policy inheritanceThis hour uses the hierarchy built in hour 1Hour 1
Azure Policy effects, remediation tasks, exemptionsThis hour only covers the managed identities that DINE policies needHour 2
Full OIDC setup steps in GitHub Actions / Azure PipelinesAlready covered step by step in the CI course. This hour only covers identity design from the ALZ perspectiveGitHub hour 3, Module 2 · Azure DevOps hour 3, Module 2
Domain controllers in the identity subscription, Entra Connect / Cloud Sync, hybrid identityBelongs to the hybrid identity topic. This hour only explains where the identity subscription fitsCAF: Hybrid identity
Network connectivity (hub, firewall, private DNS)Next hourHour 4
AKS workload identity (pod-level managed identities)Belongs to the Kubernetes topicAKS in 8 hours

How to use this course material

10 pages per module
Principles · diagrams · animation · commands · lab · production case · troubleshooting · quiz · voice · video. The animations in Module 4 (PIM authorization chain) and Module 6 (OIDC token exchange) are the core of this hour.
Learning progress
A module counts as complete when the quiz score is 70% or higher, or when you click "Mark this module complete." Progress is saved in this browser (if local storage is blocked, it is cleared on refresh).
English voice
The "Voice" tab reads the script aloud with the browser's built-in Web Speech API (en-US). Without a English voice pack, the script can still be read or passed to a TTS tool.
Version and license notes This hour follows the official docs as of 2026-11-18. ALZ library platform/alz/2026.11.0 (the management group IDs and the 5 custom roles come from the alz architecture definition in that library). Azure CLI 2.76 or later is recommended (clearer error messages for mandatory MFA). Licensing: Conditional Access requires Entra ID P1 (or P2). PIM (including PIM for Groups) requires Entra ID P2 or Entra ID Governance, counted per user with eligible or time-bound assignments, per approver, and per access review participant. Lighthouse eligible authorization requires the managing tenant to have Entra ID Governance licensing that supports PIM. Without these licenses, this hour offers alternatives: security defaults, self-enforced MFA through Azure Policy, and read-only walkthroughs.

Module 0 · Setup: test users, groups, and starting permissions (complete before class)

In the sandbox tenant, get root management group access, confirm the hour 1 management group hierarchy, and create the test users and security groups this hour uses
Before class ≈ 15 minutesSandbox Entra tenantRequires Global Administrator (sandbox only)
Reminder Work only in the dedicated sandbox tenant. The "Elevate access" step below gives you User Access Administrator at the root scope /, and you must revoke it after the labs (Module 8 and the capstone lab both check for it).
Prerequisites\n
  • In the sandbox tenant you are a Global Administrator and have registered MFA for your own account (Azure portal and CLI write operations both require MFA; see Module 5).
  • You have completed Hour 1: the management group hierarchy starts with the intermediate root alz (display name "Azure Landing Zones"), and subscriptions have been placed under groups such as management, connectivity, identity, and corp.
  • On your machine: Azure CLI 2.76+ (az version) and jq. Optionally, Azure PowerShell 14.3+ (the minimum version the docs suggest).
  • Licenses (optional but recommended): a trial or lab license for Entra ID P2 or ID Governance. Without a license, complete the PIM part of Module 4 and the Conditional Access part of Module 5 as a read-only walkthrough plus alternatives.

Step 1: elevate access (root scope) and confirm the management group hierarchy

The Entra Global Administrator has no access to Azure resources by default. In the Entra admin center or the Azure portal, go to Entra ID → Properties → the "Access management for Azure resources" toggle (or call the REST API below). This gives the current user User Access Administrator at root scope /.

az login --tenant <sandbox-tenant-id>\naz rest --method post --url "/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"\naz logout; az login --tenant <sandbox-tenant-id>     # sign in again to refresh the token\naz role assignment list --role "User Access Administrator" --scope "/" -o table\naz account management-group list --query "[].{id:name, name:displayName}" -o table
Principal                     Role                       Scope
----------------------------  -------------------------  -------
admin@contosolab.onmicrosoft.com  User Access Administrator  /
Id              Name
--------------  ---------------------
alz             Azure Landing Zones
platform        Platform
landingzones    Landing zones
corp            Corp
online          Online
...

Management group IDs follow hour 1 and your deployment (the default IDs in the ALZ library alz architecture have no prefix: alz, platform, landingzones, corp, online, local, sandbox, decommissioned, management, connectivity, identity, security). If you added a prefix when you deployed, replace the IDs in this hour's commands accordingly.

Step 2 (only if you have no results from the previous hour): minimal starting point

If you do not have an ALZ hierarchy yet, deploy it following Hour 1, "Setup". If you only want to practice identity, you can create just the 4 management groups this hour uses and place your only subscription in corp (single-subscription fallback, see the note below).

az account management-group create --name alz --display-name "Azure Landing Zones"
az account management-group create --name platform --display-name "Platform" --parent alz
az account management-group create --name landingzones --display-name "Landing zones" --parent alz
az account management-group create --name corp --display-name "Corp" --parent landingzones
SUB=$(az account show --query id -o tsv)
az account management-group subscription add --name corp --subscription $SUB
With only one subscription, platform and application resources sit in the same subscription. This hour assigns the "platform roles" at the platform management group (they do not inherit to the subscription under corp, which shows the boundary), and assigns the "application team roles" at the resource group rg-lz-myapp-cc. The decision logic is the same as with multiple subscriptions; only the scope is narrower. The ideal layout uses four subscriptions: sub-alz-management, sub-alz-connectivity, sub-alz-identity, and sub-lz-corp-myapp.

Step 3: create test users and security groups

Following ALZ guidance, "assign roles to groups, not directly to people; each Landing Zone has its own groups." This hour uses the following objects throughout (later modules refer to them directly):

ObjectTypePurpose (module)
grp-alz-platform-adminsSecurity group (PIM eligibility)Platform administrators; Contributor eligibility on the platform management group (2, 4)
grp-alz-platform-readersSecurity groupDay-to-day read-only access for the platform team; Reader on alz (2)
grp-alz-netops / grp-alz-secopsSecurity groupNetwork-Management / Security-Operations custom roles (3)
grp-lz-myapp-prod-ownersSecurity groupmyapp application team, Application-Owners (2, 3)
grp-lz-myapp-prod-access-adminsSecurity groupRBAC Administrator with conditions (2)
grp-alz-emergency-accessSecurity groupBreak-glass accounts, excluded from CA block-type policies (5)
alz-admin1, app-dev1, app-sec1Test usersPlatform administrator / application developer / application security administrator
DOMAIN=$(az rest --url https://graph.microsoft.com/v1.0/domains --query "value[?isInitial].id" -o tsv)
for u in alz-admin1 app-dev1 app-sec1; do
  az ad user create --display-name "$u" --user-principal-name "$u@$DOMAIN" \
    --password "$(openssl rand -base64 18)Aa1!" --force-change-password-next-sign-in true -o none
done
for g in grp-alz-platform-admins grp-alz-platform-readers grp-alz-netops grp-alz-secops \
         grp-lz-myapp-prod-owners grp-lz-myapp-prod-access-admins grp-alz-emergency-access; do
  az ad group create --display-name $g --mail-nickname $g -o none
done
az ad group member add --group grp-alz-platform-admins  --member-id $(az ad user show --id alz-admin1@$DOMAIN --query id -o tsv)
az ad group member add --group grp-lz-myapp-prod-owners --member-id $(az ad user show --id app-dev1@$DOMAIN --query id -o tsv)
az ad group member add --group grp-lz-myapp-prod-access-admins --member-id $(az ad user show --id app-sec1@$DOMAIN --query id -o tsv)
az ad group list --query "[?starts_with(displayName,'grp-')].displayName" -o tsv
grp-alz-emergency-access
grp-alz-netops
grp-alz-platform-admins
grp-alz-platform-readers
grp-alz-secops
grp-lz-myapp-prod-access-admins
grp-lz-myapp-prod-owners

The passwords are generated this way only in the sandbox. In a real environment, use a Temporary Access Pass (TAP) or an invitation flow so users register passwordless credentials themselves. The openssl in the commands needs Bash; PowerShell users can create the accounts in the portal.

Step 4: create the resource groups for the application landing zone

az group create -n rg-lz-myapp-cc -l canadacentral \
  --tags env=prod owner=app-team costCenter=cc-1001 workload=myapp
az group create -n rg-alz-mgmt-cc -l canadacentral \
  --tags env=prod owner=platform costCenter=cc-0001 workload=alz-mgmt

With multiple subscriptions, create rg-lz-myapp-cc in sub-lz-corp-myapp and rg-alz-mgmt-cc in sub-alz-management (run az account set first).

Warm-up: answer from memory (30 seconds)

Can a Global Administrator directly delete a virtual machine in an Azure subscription?

Not by default. Entra roles and Azure RBAC are two separate authorization systems. A Global Administrator can only grant themselves User Access Administrator at root scope through "Elevate access," and then assign themselves Azure roles. This process leaves an audit record.

Does a Reader assigned on the alz management group apply to resource groups in subscriptions under corp?

Yes. Azure RBAC role assignments inherit downward through "root → management group → subscription → resource group → resource," and they are additive only (the union of what is allowed). A lower scope cannot revoke what a higher scope grants. The only way to block access is a deny assignment, or not granting the role at the higher scope.

Starting-permissions self-assessment (6 items)

Check the items your organization has already done (results are saved in this browser). Come back and check again after you finish this hour.

Environment check list\n

Module 1 · Entra ID tenant design: single tenant, multitenant, and B2B

00:00 – 06:00 · Each Azure subscription trusts exactly one Entra tenant. Management groups, policies, and RBAC all stop at the tenant boundary. Get this boundary right first, and the next seven modules make sense
6 minutesCAF guidance: start with a single tenantLicenses do not cross tenants★★★★☆
Learning objectives
  • Explain how subscriptions, tenants, management groups, and billing accounts relate. A subscription trusts only one tenant, and the ALZ management group hierarchy exists in only one tenant.
  • Following CAF guidance, use a primary enterprise tenant (single tenant) by default. List the scenarios that really need an extra tenant, and know that with multiple tenants, ALZ must be deployed once in each tenant.
  • Distinguish what B2B collaboration, B2B direct connect, cross-tenant access settings, cross-tenant sync, multitenant organizations, administrative units, and Azure Lighthouse each solve.
Prerequisite: the management group hierarchy from hour 1. Importance: ★★★★☆ (a wrong tenant decision is expensive to undo, because moving subscriptions is costly)

What: the tenant is the identity and governance boundary

A Microsoft Entra tenant is a dedicated, trusted instance of Entra ID. It stores users, groups, app registrations, service principals, and managed identities. Every Azure subscription has a trust relationship with exactly one tenant: only identities in that tenant (and B2B guests invited into it) can be granted Azure roles on the subscription. Three facts follow that matter for ALZ:

  1. The management group hierarchy belongs to the tenant: each tenant has one root management group (its ID equals the tenant ID), and the ALZ intermediate root alz hangs under it. A subscription from another tenant cannot be placed in this tree.
  2. Azure Policy and RBAC assignments are also inside the tenant: policy assignments, role definitions (including custom roles), and role assignments can only apply to management groups, subscriptions, and resources in their own tenant.
  3. Licenses are counted per tenant: Entra ID P1 / P2, ID Governance, and Microsoft 365 licenses do not apply across tenants. Each extra tenant means another set of PIM, Conditional Access, emergency accounts, and monitoring.

The CAF multitenant docs state the conclusion plainly: ALZ is deployed in a single Entra tenant. If you have multiple tenants to govern, you must deploy a separate ALZ in each one.

Why: why single tenant is the default

  • Native integration: the Entra integration of services such as Azure Storage, Azure SQL, Azure Files, and Azure Virtual Desktop usually supports only "home tenant" identities. Support for B2B guests is limited and often arrives later than GA. Keeping subscriptions in the same tenant as your users imposes the fewest limits on workload teams.
  • Operational burden: each tenant needs its own JML (joiner, mover, leaver) process, auditing, Conditional Access, PIM, alerts, and licenses.
  • Collaboration experience: Microsoft 365 collaboration works best within one tenant. Cross-tenant collaboration needs extra setup, such as B2B and cross-tenant access settings.
  • Migration cost: moving a subscription to another tenant takes substantial work before and after (role assignments, managed identities, and Key Vault access policies are all affected). CAF even recommends that, rather than migrating, you rebuild workloads in a new subscription in the target tenant.

How: when an extra tenant is really needed

ScenarioApproachNotes
Acquisition: the acquired company already has a tenant and Microsoft 365, and may be sold again laterKeep a separate tenant and deploy its own ALZ in each tenant; simplify management with B2B, cross-tenant sync, and LighthouseThe CAF examples Fabrikam and Tailwind are this case
Testing Entra ID / Microsoft 365 configuration itself (Conditional Access, authentication methods, sync rules)A separate identity test tenantThe CAF example stresses that this tenant only tests identity and M365; Azure resources are still tested in the main tenant (using a sandbox subscription or a canary management group hierarchy)
Sovereign cloud or regulation requires physically isolated identitySeparate tenant (possibly in a different Microsoft cloud)Cross-cloud B2B settings are required
ISV-hosted SaaS for customersDesign following the CAF ISV guidanceDo not create a tenant per customer unless the business model requires it
"The development team needs isolation"No new tenant needed: use sandbox management groups and subscriptions, and delegate Entra management with administrative unitsCAF explicitly recommends sandbox subscriptions and administrative units instead of a new tenant

Multitenant and cross-tenant: toolbox comparison

CapabilityWhat it solvesWhere it appears in this hour
B2B collaborationAdds external users (or users from another tenant you own) as guests, so they can be assigned Azure rolesModules 1, 5 (mandatory MFA also applies to guests)
Cross-tenant access settingsControls inbound and outbound B2B, and whether to trust the other tenant's MFA and device claimsModules 1, 5
Cross-tenant sync / multitenant organizationAutomatically creates, updates, and deletes B2B users across your own tenants to improve collaborationModule 1
Administrative unitsWithin one tenant, delegates users, groups, and devices to different administrators; a "restricted management" administrative unit can also stop Global-level administrators from changing specific objectsModules 1, 2
Azure LighthouseProjects a subscription or resource group from another tenant into the managing tenant. The managing tenant operates it with its own accounts and built-in roles, without guest accountsModule 7
Multitenant appsAn operations tool (such as ITSM) is registered once and authorized for use in multiple tenantsModule 7

When: design checklist

  • Are all Azure subscriptions in the primary enterprise tenant? If not, record the reason in writing (acquisition, sovereignty, regulation).
  • Are the EA / MCA account owner, invoice section owner, and subscription creators in the target tenant? This way a new subscription is in the right tenant from the start, avoiding a later "change directory."
  • Are there fewer than 5 Global Administrators, all going through PIM and requiring approval? Is the "Access management for Azure resources" toggle set to "No" when it is not needed?
  • Is the tenant where test identity configuration happens separate from the tenant that hosts Azure workloads?
Common misconceptions ① "One tenant per environment (dev / test / prod) is safer." This multiplies ALZ, PIM, Conditional Access, and licensing by 3, and identity integrations validated in dev may not hold in the production tenant. CAF recommends separating environments with sandbox / different Landing Zone subscriptions. ② "B2B guests can use all Azure services." Many services' Entra integration supports only home-tenant identities. ③ "Moving a subscription to a new tenant is just a dropdown change." The move deletes all RBAC role assignments and custom roles on the subscription; managed identities, Key Vault, and so on must be reconfigured.

Architecture diagram: one tenant, one management group tree, many subscriptions

Entra tenant contosolab.onmicrosoft.com (identity + governance boundary) Identity directory Users / groups / guestsApp registrations / service principalsManaged identitiesConditional Access · PIMAdministrative units Root management group (ID = tenant ID) alz (intermediate root) platform landingzones management · connectivityidentity · security corp · online · local sub-alz-managementsub-alz-identity … sub-lz-corp-myapprg-lz-myapp-cc Policy assignments · role definitions · role assignmentsAll take effect only within this tenant Trust Another tenant (acquired Fabrikam) Its own root management group and ALZ (must be deployed separately)Its own licenses, PIM, CA, and break-glass accountsSubscriptions cannot be attached to the contosolab alz tree Lighthouse projection / B2B / cross-tenant sync Identity test tenant (optional) Tests only Entra / M365 configurationAzure resources are still tested in the main tenant(sandbox subscription / canary hierarchy)
Figure 1-1: a subscription trusts only one tenant; the ALZ management group tree, policies, and RBAC all stop at the tenant boundary

Comparison diagram: the "multiplication effect" of single tenant vs multitenant

What you need one copy of for each extra tenantSingle tenantThree tenants
ALZ deployment (management group tree + policies + platform subscriptions)13
Break-glass accounts (at least 2 per tenant)26
Conditional Access policy set and PIM configuration1 set3 sets (prone to drift)
Entra ID P2 / Governance licensingCounted per userPurchased separately in each tenant
Deployment identities and federated credentialsPer environmentPer environment × tenant
Logs and alerts (SigninLogs, AuditLogs)1 workspaceCross-tenant aggregation needed (e.g. Lighthouse + Sentinel)

Interactive: tenant topology decision tool

Check the requirements your organization faces. The decision tool gives a topology following CAF guidance and lists the extra work each choice creates. The rules come from the CAF "multitenant considerations and recommendations."

Recommended topology
Check the requirements, then click "Assess."
Waiting for input…

Core commands: check which tenant a subscription belongs to

CommandPurposeNotes
az account show --query "{sub:id, tenant:tenantId, home:homeTenantId}"Tenant of the current subscriptiontenantId is the tenant the subscription trusts; homeTenantId is the subscription's home tenant (the two mean different things under Lighthouse projection)
az account tenant listTenants the current account can accessB2B guests see multiple tenants
az account management-group show -n alz -e -rExpand the management group tree-e expands children, -r recurses
az rest --url https://graph.microsoft.com/v1.0/organizationTenant information (display name, verified domains)Requires directory read permission
az rest --url "https://graph.microsoft.com/v1.0/policies/crossTenantAccessPolicy/default"Default cross-tenant access settingsView inbound trust (MFA / device) configuration
az rest --url https://graph.microsoft.com/v1.0/directory/administrativeUnitsList administrative unitsDelegation boundary within a single tenant
az account show --query "{subscription:name, tenant:tenantId, home:homeTenantId}" -o table
az account tenant list --query "[].{tenant:tenantId, name:displayName, domain:defaultDomain}" -o table
az account management-group show -n alz -e -r --query "children[].{id:name, children:children[].name}" -o json
Subscription         Tenant                                Home
-------------------  ------------------------------------  ------------------------------------
sub-lz-corp-myapp    aaaabbbb-0000-cccc-1111-dddd2222eeee  aaaabbbb-0000-cccc-1111-dddd2222eeee
Tenant                                Name         Domain
------------------------------------  -----------  ---------------------------
aaaabbbb-0000-cccc-1111-dddd2222eeee  Contoso Lab  contosolab.onmicrosoft.com
[
  {"id": "platform", "children": ["security","management","connectivity","identity"]},
  {"id": "landingzones", "children": ["corp","online","local"]},
  {"id": "sandbox", "children": null},
  {"id": "decommissioned", "children": null}
]

How to verify: all ALZ subscriptions should have the same tenantId; a second tenant ID means some subscription is not in this tree. Common mistake: treating homeTenantId as "the tenant I signed in to." It describes the subscription itself. Production use: assert the tenantId of a new subscription in the subscription vending process.

Lab 1: inventory the tenant boundary (about 5 minutes)

List all visible subscriptions and their tenants\n
az account list --all --query "[].{name:name, tenant:tenantId, state:state}" -o table

If your account is a B2B guest of another tenant, different tenantId values appear here. Those subscriptions will not appear in your alz management group tree.

Confirm where each subscription sits in the management group tree\n
for s in $(az account list --query "[?tenantId=='$(az account show --query tenantId -o tsv)'].id" -o tsv); do
  az graph query -q "resourcecontainers | where type =~ 'microsoft.resources/subscriptions' and subscriptionId == '$s' | project name, mg=properties.managementGroupAncestorsChain[0].name" -o tsv --query "data[].[name,mg]"
done
sub-lz-corp-myapp	corp

Needs the resource-graph extension (running az graph for the first time prompts you to install it). The first element of managementGroupAncestorsChain is the direct parent management group.

Check the default cross-tenant access settings\n
az rest --url "https://graph.microsoft.com/v1.0/policies/crossTenantAccessPolicy/default" \
  --query "{b2bIn:b2bCollaborationInbound.usersAndGroups.accessType, trust:inboundTrust}"
{ "b2bIn": "allowed", "trust": { "isMfaAccepted": false, "isCompliantDeviceAccepted": false, "isHybridAzureADJoinedDeviceAccepted": false } }

isMfaAccepted: false means guests must complete MFA again in this tenant. For other tenants you own, you can add an organizational setting to trust their MFA (the mandatory MFA from Module 5 also applies to guests). Requires directory read permissions such as Policy.Read.All.

Write down your tenant decision record (ADR): the number of tenants, the purpose of each, which subscriptions are in which tenant, how cross-tenant collaboration works (B2B / sync / Lighthouse), and whether an identity test tenant exists. The capstone lab uses this.

Case 1: one tenant per environment, unmaintainable after three years

Problem: a company created one tenant each for dev / test / prod and deployed ALZ in each. Three years later, the three Conditional Access policy sets had drifted apart, an Entra app integration validated in the test tenant behaved differently in the prod tenant, and licensing costs doubled. Approach: put all new workloads in the primary enterprise tenant and separate environments using different subscriptions under corp; keep one test tenant only for testing identity configuration. Limitation: old subscriptions need to be rebuilt or migrated, and migration means recreating all role assignments and managed identities.

Case 2: keep a separate tenant after an acquisition

Problem: the acquired subsidiary has its own Microsoft 365 and Azure, and may be sold in the future. Approach: do not merge tenants; deploy one ALZ inside the subsidiary's tenant. The parent company's platform team gets read-only and limited operations access through Azure Lighthouse (Module 7), and the security team aggregates Sentinel data through Lighthouse. Configuration: in cross-tenant access settings, trust the other tenant's MFA claims to reduce duplicate MFA.

Case 3: "changing directory" on a subscription breaks applications

Problem: someone moved a subscription from a personal trial tenant to the enterprise tenant. All role assignments were deleted, the system-assigned managed identity stopped working, and Key Vault access failed. Approach: following the official "transfer subscription" checklist, first export role assignments, custom roles, managed identities, and Key Vault settings, then rebuild them after the transfer. Prevention: in EA / MCA, make sure subscription creators sit directly in the target tenant.

Common errors and fixes

The subscription '…' doesn't exist in cloud 'AzureCloud' / subscription not visible in az account list

Cause: the tenant you are signed in to is not the tenant the subscription trusts, or the account has no roles on that subscription.

az account tenant list -o table
az login --tenant <subscription-tenant-id>
az account list --all -o table

Fix: sign in with the correct tenant. If you are a B2B guest, confirm the invitation has been redeemed and you have a role assignment.

Cannot move a subscription into a management group: the subscription is not in this tenant

Cause: a management group tree belongs to only one tenant. A subscription from another tenant cannot be attached.

Fix: either deploy your own ALZ in the other tenant, or assess the full impact of "transfer subscription" before changing directory (rebuilding the workloads in the target tenant is recommended).

AADSTS50020: User account from identity provider does not exist in tenant

Cause: the user tried to sign in to a tenant where they are neither a member nor a guest.

Fix: send a B2B invitation or set up cross-tenant sync, or use Lighthouse to project the other tenant's resources into the user's home tenant.

After transferring the subscription: AuthorizationFailed, original role assignments all gone

Cause: changing directory deletes role assignments and custom roles on the subscription; system-assigned managed identities must be re-enabled.

az role assignment list --all --include-inherited -o json > ra-before.json   # export before the transfer\naz role definition list --custom-role-only true -o json > roles-before.json

Fix: rebuild in the new tenant based on the exported files (principal IDs will differ and need to be remapped).

Command-line exercise\n
1. Use one command to show the current subscription name, the tenant ID it trusts, and the home tenant ID.
az account show --query "{subscription:name, tenant:tenantId, home:homeTenantId}" -o table
2. Use Resource Graph to list all subscriptions and their direct parent management groups.
az graph query -q "resourcecontainers | where type =~ 'microsoft.resources/subscriptions' | project name, parent=properties.managementGroupAncestorsChain[0].name"
Scenario analysis question\n
The security team proposes: "Create a separate tenant for production workloads, so people in the development tenant cannot reach production." How do you respond?

First confirm whether the motivation is "permission isolation" or "regulatory isolation." Permission isolation can be done within a single tenant: put production subscriptions under corp / online, and development under sandbox or a separate Landing Zone subscription; assign roles only to groups organized by Landing Zone; use PIM for high-privilege access; and use a restricted-management administrative unit on the Entra side. A new tenant doubles ALZ, PIM, CA, emergency accounts, licensing, and logging, and many services' Entra integration does not support guest identities. Only requirements that a single tenant cannot meet, such as regulation or acquisition, justify a new tenant, and then ALZ must be deployed separately in the new tenant.

Verified training videos

▶
Exploring the Real Relationship Between Azure AD and Azure Subscriptions — John Savill's Technical Training
English · the trust relationship between subscriptions and tenants, the core of this module
▶
Azure AD Cross-Tenant Access Settings Deep Dive — John Savill's Technical Training
English · cross-tenant access settings and trusting the other tenant's MFA (the product has been renamed Entra ID)
▶
Azure AD B2B Overview — John Savill's Technical Training
English · how B2B guests work

Official docs and further reading

Video storyboard (about 90 seconds)

This course material cannot generate video or MP3 directly. A storyboard and narration script are provided, and can be handed to a video tool.

Shot 1 · 0–20s
Visual: a large box labeled "Tenant," with a management group tree inside and subscriptions attached to the leaves.
Narration: each subscription trusts only one Entra tenant, and the ALZ management groups, policies, and roles all live inside that tenant.
Shot 2 · 20–50s
Visual: two more tenants are drawn, each with a full copy of ALZ, PIM, and break-glass accounts; the counter jumps from 1 to 3.
Narration: each extra tenant multiplies all governance work. That is why CAF recommends starting with the primary enterprise tenant.
Shot 3 · 50–75s
Visual: the acquired company's tenant connects to the main tenant through dashed lines (Lighthouse, B2B, sync).
Narration: when you really need multitenancy, use Lighthouse to manage resources, and B2B plus cross-tenant sync to manage people.
Shot 4 · 75–90s
Visual: the development team's request is pointed by arrows to a sandbox management group and administrative units, not to a new tenant.
Narration: to isolate teams, use subscriptions and administrative units first, not a new tenant.
Or pass the quiz with a score of 70% or higher

Module 2 · Azure RBAC model and ALZ recommended role split

06:00 – 13:00 · A role assignment = who + what role + which scope. The ALZ trick: policies sit at the management group, and Landing Zone role assignments sit at the subscription or resource group. Application teams get autonomy, but cannot change the policies that govern them
7 minutesPlatform team / application team5000 role assignments per subscription (fixed)★★★★★
Learning objectives
  • Describe any authorization as "security principal + role definition + scope," and trace through the ARM decision order to see whether a request is allowed.
  • Tell apart Entra roles (tenant-level: users, apps, Conditional Access) from Azure roles (resource-level: management groups, subscriptions, resources), and control plane from data plane permissions.
  • Using CAF's example table, design role assignments for the platform team, security, networking, FinOps, and the myapp application team. Use a conditional Role Based Access Control Administrator so application teams can manage access themselves, but cannot escalate privileges.
Prerequisites: the groups and resource groups from Module 0. Importance: ★★★★★

What: the three parts of a role assignment

PartMeaningExample in ALZ
Security principal (principal)Users, groups, service principals, managed identitiesgrp-lz-myapp-prod-owners (a group, not an individual)
Role definitionA set of Actions / NotActions / DataActions / NotDataActionsALZ custom role Application-Owners
Scoperoot / → management group → subscription → resource group → resource/subscriptions/<sub-lz-corp-myapp>

An optional fourth part is a condition (ABAC, conditionVersion 2.0): for example, "only allow assigning Reader to groups." Assignments are inherited downward and are additive only: a lower scope cannot revoke permissions granted above. The only way to "subtract" is a deny assignment, which you cannot create directly. It can only be produced by Azure services (for example, the denySettings of Deployment Stacks, or managed applications).

How: how ARM decides a request (in the order described in the official docs)

  1. The user or workload gets a token from Entra to access ARM (the token contains the user's object ID and group memberships).
  2. The request reaches management.azure.com with the token. ARM reads the role assignments and deny assignments that apply to the target resource, including all parent scopes: resource group, subscription, each management group level, and root.
  3. If a deny assignment matches, reject immediately.
  4. Filter the role assignments belonging to the user or to a group the user is in, and merge the effective permissions of those roles (within each role, first subtract NotActions from Actions, then take the union across roles).
  5. Is the requested operation (such as Microsoft.Compute/virtualMachines/write) in the effective permissions? If the assignment has a condition, evaluate the condition too.
  6. If all checks pass, allow; otherwise return AuthorizationFailed (403).

Only after this does Azure Policy evaluate the same request (hour 2). RBAC answers "are you allowed to do this?", and Policy answers "is this compliant?" Only when both pass is the resource created.

Entra roles vs Azure roles

Microsoft Entra rolesAzure RBAC roles
What they manageTenant-level: users, groups, app registrations, Conditional Access, licensing, Microsoft 365Azure resources: management groups, subscriptions, resource groups, resources
Typical rolesGlobal Administrator, Privileged Role Administrator, Conditional Access Administrator, Application Administrator, Groups AdministratorOwner, Contributor, Reader, User Access Administrator, Role Based Access Control Administrator
ScopeTenant, administrative unit, individual appRoot, management group, subscription, resource group, resource
OverlapA Global Administrator has no Azure resource permissions by default. They can only "elevate access" to get User Access Administrator at root scope (Module 0). A "role-assignable group" (isAssignableToRole=true) is protected: only the Global Administrator, the Privileged Role Administrator, or group owners can change its members.

Control plane vs data plane

Actions covers the control plane (creating a Key Vault, changing a storage account's network rules), and DataActions covers the data plane (reading secrets, reading and writing blobs). ALZ recommends using Azure RBAC for data-plane access where possible, and keeping the two separate: someone who can manage a Key Vault resource should not necessarily be able to read its secrets. Note that Contributor has no DataActions, yet it can call listKeys to get a storage account key. This is the classic route to bypassing data-plane RBAC with keys.

ALZ recommended role split (compiled from the CAF example table)

WhoRoleAssigned toScope
Platform management teamContributor (built-in)grp-alz-platform-admins (PIM group)platform management group
Day-to-day platform teamReader (built-in)grp-alz-platform-readersTop-level organization management group alz
Security teamSecurity-Operations (ALZ custom)grp-alz-secopsalz
Security team (Entra side)Conditional Access Administrator (built-in Entra role, enables protected operations)Security administrators groupTenant
Networking teamNetwork-Management (ALZ custom)grp-alz-netopsAll subscriptions (or connectivity + each Landing Zone)
FinOpsBilling Reader (built-in)FinOps groupalz
myapp application teamApplication-Owners (ALZ custom)grp-lz-myapp-prod-ownerssub-lz-corp-myapp
myapp security administratorsRBAC Administrator + condition (CAF calls it Application Access Administrator)grp-lz-myapp-prod-access-adminssub-lz-corp-myapp
Sandbox development teamOwner (built-in)Development groupResource groups in the sandbox subscription

Three principles that run through the whole table (key points from the CAF original):

  • Policies sit at the management group, and Landing Zone roles sit at the subscription / resource group: application teams have full autonomy, but cannot change the policy assignments that govern them.
  • Each Landing Zone and each environment has its own groups: do not create one "all application admins" group assigned to several Landing Zones. Dev/test and prod also do not share groups, service principals, or managed identities.
  • Assign roles to groups, not people: this reduces pressure on the limit of 5000 assignments per subscription (500 per management group), and when someone changes roles, you only update group membership.

Delegating the right to assign permissions: a conditional RBAC Administrator

Application teams often need to assign AcrPull to their own managed identities and Reader to test groups. Giving them Owner or User Access Administrator means they can also give Owner to anyone. CAF recommends assigning Role Based Access Control Administrator (which only has the right to manage role assignments), and adding a condition, for example "may only assign Reader / AcrPull / Key Vault Secrets User, and only to groups or service principals," or "may assign any role except Owner, User Access Administrator, and RBAC Administrator." The official docs warn about the second form: when new roles that can assign roles appear in the future, the condition will not automatically block them.

Common misconceptions ① "Granting Reader on a resource group limits someone's Contributor role on the subscription." No. Permissions are a union, and Reader does not override Contributor. ② "NotActions means deny." NotActions only removes operations from this role. If another role grants the operation, the user still has permission. ③ "A Global Administrator is automatically the Azure super-admin." Not by default. It requires elevating access, which is audited. ④ "Owner is just a bit more than Contributor." What Owner adds is exactly Microsoft.Authorization/*: it can give anyone any role, which means holding all the keys for that scope.

Architecture diagram: role assignments on the ALZ management group tree

alz (intermediate root) Reader → grp-alz-platform-readersSecurity-Operations → grp-alz-secops platform Contributor (PIM eligible) → grp-alz-platform-admins landingzones → corp Policy assignments here (Deny / DINE / Audit)Application teams have no roles at this layer sub-alz-connectivity Network-Management → grp-alz-netops sub-lz-corp-myapp Application-Owners → grp-lz-myapp-prod-owners RBAC Admin + condition → grp-lz-myapp-prod-access-admins Network-Management → grp-alz-netops rg-lz-myapp-cc (inherits all of the above) With only one subscription:platform roles stay at the platform management group (to show the boundary),application team roles move to rg-lz-myapp-cc
Figure 2-1: policies sit at the management group, and Landing Zone role assignments sit at the subscription / resource group; all assignments inherit downward and are additive only

Flow diagram: authorization decision for a request

Entra tokenoid + groups Collect assignmentsresource → … → root Deny assignment?Match: 403 Merge effective permissions(A−NotA) union Condition (ABAC)Evaluate if present Allow → PolicyHour 2
Figure 2-2: RBAC answers "can you do this?" first, then Policy answers "is this compliant?"

RBAC decision simulator: evaluating down the management group tree

Select a principal and an operation, then click "Step through decision." The simulator uses the role assignments from this hour's lab (data in the log below), collecting assignments layer by layer in ARM order, merging permissions, and evaluating conditions. The role definitions match the JSON in the ALZ library.

Select a principal and an operation to begin.
$ az role assignment list --assignee … --include-inherited

Core commands: assign, view, and delegate with conditions

CommandPurposeNotes
az role assignment create --assignee-object-id ID --assignee-principal-type Group --role R --scope SCreate a role assignmentUsing the object ID and principal type avoids directory lookup and replication delay
az role assignment list --assignee X --all --include-inheritedAll assignments for a principal (including inherited)Management group assignments are not visible without --include-inherited
az role assignment list --scope S --include-inheritedAssignments effective at a scopeMost useful when auditing a Landing Zone
az role assignment create … --condition "…" --condition-version 2.0Delegation with conditionsThe condition is written on the assignment, not on the role definition
az role definition list --name "Owner" --query "[].permissions"View a role's permissionsCompare the differences between Owner and Contributor
az role assignment delete --ids IDDelete an assignmentBefore deleting, confirm it is not the last Owner
LZ_SUB=$(az account show --query id -o tsv)          # sub-lz-corp-myapp (the only subscription when there is just one)\ngid() { az ad group show -g "$1" --query id -o tsv; }\n# Platform read-only: top-level organization management group\naz role assignment create --assignee-object-id $(gid grp-alz-platform-readers) --assignee-principal-type Group \\\n  --role Reader --scope /providers/Microsoft.Management/managementGroups/alz\n# Application team: Application-Owners (ALZ custom role, created when hour 1 deployed ALZ; confirm the name with az role definition list)\nAPPOWN=$(az role definition list --custom-role-only true --query "[?starts_with(roleName,'Application-Owners')].name | [0]" -o tsv)\naz role assignment create --assignee-object-id $(gid grp-lz-myapp-prod-owners) --assignee-principal-type Group \\\n  --role $APPOWN --scope /subscriptions/$LZ_SUB\naz role assignment list --scope /subscriptions/$LZ_SUB --include-inherited \\\n  --query "[].{who:principalName, role:roleDefinitionName, scope:scope}" -o table
Who                              Role                     Scope
-------------------------------  -----------------------  ------------------------------------------------
grp-alz-platform-readers         Reader                   /providers/Microsoft.Management/managementGroups/alz
grp-alz-secops                   Security-Operations      /providers/Microsoft.Management/managementGroups/alz
grp-lz-myapp-prod-owners         Application-Owners       /subscriptions/1111…
admin@contosolab.onmicrosoft.com User Access Administrator /

Conditional RBAC Administrator (application security administrator)

# Only allow assigning Reader(acdd72a7…) and AcrPull(7f951dda…) to groups or service principals\nCOND="((!(ActionMatches{'Microsoft.Authorization/roleAssignments/write'})) OR (@Request[Microsoft.Authorization/roleAssignments:RoleDefinitionId] ForAnyOfAnyValues:GuidEquals {acdd72a7-3385-48ef-bd42-f606fba81ae7, 7f951dda-4ed3-4680-a7ca-43fe172d538d} AND @Request[Microsoft.Authorization/roleAssignments:PrincipalType] ForAnyOfAnyValues:StringEqualsIgnoreCase {'Group', 'ServicePrincipal'})) AND ((!(ActionMatches{'Microsoft.Authorization/roleAssignments/delete'})) OR (@Resource[Microsoft.Authorization/roleAssignments:RoleDefinitionId] ForAnyOfAnyValues:GuidEquals {acdd72a7-3385-48ef-bd42-f606fba81ae7, 7f951dda-4ed3-4680-a7ca-43fe172d538d} AND @Resource[Microsoft.Authorization/roleAssignments:PrincipalType] ForAnyOfAnyValues:StringEqualsIgnoreCase {'Group', 'ServicePrincipal'}))"\naz role assignment create --assignee-object-id $(gid grp-lz-myapp-prod-access-admins) --assignee-principal-type Group \\\n  --role "Role Based Access Control Administrator" --scope /subscriptions/$LZ_SUB \\\n  --condition "$COND" --condition-version "2.0"

How to verify: sign in as app-sec1. Assigning Reader to grp-lz-myapp-prod-owners should succeed; assigning yourself Owner should fail with a message like "does not have authorization or an ABAC condition not fulfilled." Common mistake: writing the condition only for the write branch and forgetting the delete branch, so the delegate can delete the platform team's assignments. Production use: deploy this assignment consistently in the subscription vending template.

Lab 2: assign roles by the ALZ split and verify the boundaries (about 8 minutes)

Complete the three assignments on the "Commands" tab (platform read-only, application team, and conditional access administrator). With a single subscription, replace --scope /subscriptions/$LZ_SUB with /subscriptions/$LZ_SUB/resourceGroups/rg-lz-myapp-cc.
Sign in as app-dev1 and verify "autonomy"\n
az login --tenant <sandbox-tenant-id>          # sign in as app-dev1 (the first sign-in asks you to register MFA)\naz storage account create -n stmyapp$RANDOM -g rg-lz-myapp-cc -l canadacentral --sku Standard_LRS \\\n  --tags env=prod owner=app-team costCenter=cc-1001 workload=myapp -o none && echo OK
OK

If a policy from hour 2 requires certain tags or blocks public access, you may see RequestDisallowedByPolicy. That error comes from Policy, not RBAC.

Verify "cannot change the boundary": the NotActions of Application-Owners include Microsoft.Network/virtualNetworks/write and Microsoft.Authorization/*/write.\n
az network vnet create -g rg-lz-myapp-cc -n vnet-test --address-prefixes 10.9.0.0/16
az role assignment create --assignee app-dev1@<domain> --role Owner --scope /subscriptions/$LZ_SUB
(AuthorizationFailed) The client 'app-dev1@contosolab.onmicrosoft.com' with object id '…' does not have authorization to perform action 'Microsoft.Network/virtualNetworks/write' over scope '/subscriptions/…/resourceGroups/rg-lz-myapp-cc/providers/Microsoft.Network/virtualNetworks/vnet-test' or the scope is invalid.
(AuthorizationFailed) … does not have authorization to perform action 'Microsoft.Authorization/roleAssignments/write' …
Sign in as app-sec1 and verify the conditional delegation\n
az role assignment create --assignee-object-id $(az ad group show -g grp-lz-myapp-prod-owners --query id -o tsv) \\\n  --assignee-principal-type Group --role Reader --scope /subscriptions/$LZ_SUB   # succeeds\naz role assignment create --assignee app-sec1@<domain> --role Owner --scope /subscriptions/$LZ_SUB   # fails
{ "roleDefinitionName": "Reader", "principalType": "Group", … }
(AuthorizationFailed) The client 'app-sec1@…' … does not have authorization or an ABAC condition not fulfilled to perform action 'Microsoft.Authorization/roleAssignments/write' …
Refresh and delay: if a newly assigned role does not take effect, run az logout and sign in again. The official docs note that role assignment changes can take up to about 10 minutes to take effect.

Case 1: one big "all application admins" group

Problem: to save effort, the platform team created an AllAppAdmins group and gave it Contributor on the landingzones management group. One application team member accidentally deleted another team's production database. Approach: following CAF guidance, switch to a separate group per Landing Zone and per environment, delegate assignments to the subscription, and move high privileges to PIM. Limitation: more groups to manage, and membership needs to be managed through access packages in ID Governance.

Case 2: Owner delegation leads to self-escalation of privileges

Problem: the application team had subscription Owner, added outsourced staff as Owners, and assigned User Access Administrator to its pipeline service principal. Approach: switch the application team to Application-Owners (no Microsoft.Authorization/*/write), and set up a separate conditional RBAC Administrator group that may assign only allowlisted roles to groups and service principals. Result: assignments outside the allowlist are blocked by the ABAC condition and leave a trace in the activity log.

Case 3: subscription hits the 5000 role assignment limit

Problem: automation assigned roles to each managed identity individually, and the subscription's assignment count approached 5000 (a fixed limit that cannot be raised). Approach: use Resource Graph to find assignments with the same role, same scope, and different principals, and convert them to group assignments. Delete redundant lower-level assignments. Where possible, convert them to PIM eligibility (eligible assignments do not count toward the limit). Note: permissions a managed identity gets through a group may take hours to take effect (token caching of about 24 hours), so for latency-sensitive scenarios, keep direct assignments.

Common errors and fixes

(AuthorizationFailed) The client '…' with object id '…' does not have authorization to perform action '…' over scope '…'

Cause: the operation is not in the effective permissions: there is no assignment, the assignment is at the wrong scope, or it is excluded by NotActions.

az role assignment list --assignee <upn-or-id> --all --include-inherited -o table
az role definition list --name "<role>" --query "[].permissions[].{a:actions, na:notActions}"

Fix: add the assignment at the narrowest correct scope. If it comes from Application-Owners' NotActions (such as VNet write), this is by design: contact the platform networking team.

PrincipalNotFound: Principal … does not exist in the directory …

Cause: a newly created user, service principal, or managed identity has not yet replicated to the region processing the request.

Fix: in CLI, use --assignee-object-id + --assignee-principal-type ServicePrincipal; in Bicep / ARM, set principalType; for a newly created group, wait a few minutes.

RoleAssignmentUpdateNotPermitted: Tenant ID, application ID, principal ID, and scope are not allowed to be updated.

Cause: in Bicep, the role assignment's name (GUID) was reused, but the principal has changed (for example, the managed identity was recreated).

Fix: generate a deterministic name with guid(scope, principalId, roleDefinitionId); delete the old assignment before creating the new one.

Status: 401 (Unauthorized) —— newly added role has no effect

Cause: ARM caching, up to about 10 minutes; permissions a managed identity gets through a group may take hours.

Fix: az logout; az login to refresh the token; for managed identities, assign the role directly rather than through a group.

Cannot delete the last RBAC admin assignment

Cause: deleting the last Owner on a subscription is blocked by default, to prevent the subscription from becoming "orphaned."

Fix: first confirm there is another Owner (or PIM eligibility); the Global Administrator is not subject to this restriction.

Command-line exercise\n
1. List all effective role assignments (including inherited) on rg-lz-myapp-cc, showing only the principal, role, and scope.
az role assignment list -g rg-lz-myapp-cc --include-inherited --query "[].{who:principalName, role:roleDefinitionName, scope:scope}" -o table
2. Without a directory lookup, assign Reader to the managed identity whose object ID is $OID (subscription scope).
az role assignment create --assignee-object-id $OID --assignee-principal-type ServicePrincipal --role Reader --scope /subscriptions/$LZ_SUB
Scenario analysis question\n
The myapp team asks for "Owner on the subscription, because we need to assign roles to our pipelines and managed identities." How do you meet the need without giving Owner?

Split into two groups. grp-lz-myapp-prod-owners gets Application-Owners (autonomy over resource management, but without Microsoft.Authorization/*/write, and unable to change VNets or public IPs). grp-lz-myapp-prod-access-admins gets Role Based Access Control Administrator with a condition: it may assign only allowlisted roles (Reader, AcrPull, Key Vault Secrets User, etc.) to groups or service principals, and both the write and delete branches must be written. When temporary Owner is needed, use PIM eligibility with approval. Pipeline identities are created and authorized by the platform team during subscription vending (Module 6).

Verified training videos

▶
Azure Role-Based Access Control Deep Dive — John Savill's Technical Training
English · role definitions, scope, inheritance, Actions/NotActions, deny assignments
▶
Azure Master Class v2 - Module 3 - Governance — John Savill's Technical Training
English · how management groups, RBAC, and policy work together in governance (long video; you can skip to the RBAC chapter)

Official docs and further reading

Video storyboard (about 90 seconds)

Shot 1 · 0–20s
Visual: three puzzle pieces, "who / role / scope," fit together into one role assignment.
Narration: every authorization can be broken into three questions: who, what they can do, and at which layer.
Shot 2 · 20–45s
Visual: on the management group tree, Reader flows down from alz to the resource group.
Narration: assignments inherit downward and are additive only; a lower level cannot revoke what a higher level grants.
Shot 3 · 45–70s
Visual: a policy shield on the corp management group, and the Application-Owners key on the subscription.
Narration: Policy lives at the management group, and the application team's key lives on the subscription. They get autonomy, but they cannot change the rules.
Shot 4 · 70–90s
Visual: a lock hangs on the RBAC Administrator key, labeled "Reader, AcrPull only; groups only".
Narration: To delegate role assignment, use RBAC Administrator with conditions, not Owner.
or score ≥ 70% on the quiz

Module 3 · Custom roles and least privilege

13:00 – 21:00 · Start with the built-in roles. Write a custom role only when the built-in roles grant too much. Before you write one, understand the three traps: NotActions, wildcards, and AssignableScopes.
8 minALZ library: 5 custom roles5,000 custom roles per tenant★★★★☆
Learning objectives
  • Read the six key fields of a role definition JSON. Explain how Actions − NotActions and DataActions − NotDataActions are calculated, and how far wildcards expand.
  • Remember the hard limits on custom roles: 5,000 per tenant. AssignableScopes cannot be the root /, cannot use wildcards, and can contain only one management group. A custom role with DataActions cannot be assigned at management group scope.
  • Read the 5 custom roles in the ALZ library. Write a least-privilege Landing Zone VM Operator role, and reuse it under the alz management group.
Prerequisite: Module 2. Importance: ★★★★☆

What: structure of a role definition

{
  "Name": "Landing Zone VM Operator",
  "Description": "Start, stop, restart VMs and read monitoring data in a landing zone.",
  "Actions": [
    "Microsoft.Compute/virtualMachines/read",
    "Microsoft.Compute/virtualMachines/start/action",
    "Microsoft.Compute/virtualMachines/restart/action",
    "Microsoft.Compute/virtualMachines/deallocate/action",
    "Microsoft.Compute/virtualMachines/instanceView/read",
    "Microsoft.Network/networkInterfaces/read",
    "Microsoft.Insights/metrics/read",
    "Microsoft.Resources/subscriptions/resourceGroups/read",
    "Microsoft.Support/*"
  ],
  "NotActions": [],
  "DataActions": [],
  "NotDataActions": [],
  "AssignableScopes": [ "/providers/Microsoft.Management/managementGroups/alz" ]
}
FieldMeaningPitfall
ActionsAllowed control-plane operations, in the format {provider}/{resource type}/{operation}Wildcards automatically include future operations. Microsoft recommends listing operations explicitly wherever possible.
NotActionsSubtracted from the Actions of this roleNot a deny: the same operation granted by another role still works
DataActions / NotDataActionsData-plane operations (read secrets, read and write blobs)A custom role with DataActions cannot be assigned at management group scope. (You can put a management group in AssignableScopes, then assign the role on a subscription under it.)
AssignableScopesScopes where this role can be assigned (up to 2,000)Cannot be /; cannot use wildcards; only one management group; ARM does not validate that the management group exists

Other limits: each operation string can contain only one wildcard; a tenant can have at most 5,000 custom roles (2,000 in Azure China, operated by 21Vianet); role names are unique within a tenant; renaming does not change the ID, so automation should use the role ID; before you delete a role, you must delete all assignments that use it (including PIM eligible assignments), or you get RoleDefinitionHasAssignments.

Why: when a custom role is worth writing

  • Built-in roles grant too much dangerous permission. For example, Virtual Machine Contributor includes Microsoft.Storage/storageAccounts/listKeys/action, which can return storage keys.
  • The permissions you need are spread across several built-in roles. Merging them into one custom role also reduces the number of role assignments (easing the 5,000-per-subscription limit).
  • The ALZ separation of duties needs combinations like "Contributor, but cannot change networking or grant access."

On the other hand, do not copy built-in roles in large numbers just to look stricter. You have to maintain custom roles yourself, while Microsoft updates built-in roles as new features arrive. CAF guidance: use built-in roles where possible, and create custom roles only when necessary. Also review newly added built-in roles regularly to see whether any of them can replace your custom roles.

The 5 custom roles in the ALZ library (platform/alz, deployed at the intermediate root alz)

RoleActionsNotActionsPurpose
Subscription-Owner*Microsoft.Authorization/*/write, Microsoft.Network/vpnGateways/*, expressRouteCircuits/*, routeTables/write, vpnSites/*Delegated to subscription owners: nearly full control, but cannot grant access and cannot touch hybrid connectivity or route tables
Application-Owners*Microsoft.Authorization/*/write, Microsoft.Network/publicIPAddresses/write, virtualNetworks/write, Microsoft.KeyVault/locations/deletedVaults/purge/actionApplication and operations teams' "Contributor": cannot grant access, cannot create public IPs, cannot change VNets, cannot purge soft-deleted Key Vaults
Network-Management*/read, Microsoft.Network/*, Microsoft.Resources/deployments/*, Microsoft.Support/*—NetOps: manages global connectivity (VNets, UDRs, NSGs, NVAs, VPN, ExpressRoute)
Network-Subnet-ContributorMicrosoft.Network/*/read, Microsoft.Network/virtualNetworks/subnets/*, deployments, alert rules, and more—Can manage only subnets, not other network resources
Security-Operations*/read, */register/action, Key Vault purge, Microsoft.PolicyInsights/*, policy assignments / definitions / exemptions / set definitions, Microsoft.Security/*, and more—SecOps: read-only across the environment, plus security and policy management

In the library, these roles' assignableScopes are the placeholder ${current_scope_resource_id}, which the alz provider / AVM modules replace with the intermediate root management group at deployment. After deployment, the roleName may get a suffix to keep it unique within the tenant. Run az role definition list --custom-role-only true to see the roles in your environment.

How: working with least privilege

  1. Start from the closest built-in role: az role definition list --name "Virtual Machine Contributor" -o json.
  2. List all operations for a resource provider with az provider operation show --namespace Microsoft.Compute, and pick only what you need.
  3. Set AssignableScopes to the alz management group (reused across the whole landing zone) or to a specific subscription.
  4. In a sandbox, test each "can do / cannot do" with a test user, and add the tests to your pipeline (Module 8).
  5. Commit the role definitions to your IaC repository (the custom library for ALZ Terraform / Bicep), and review changes through PRs.

When: built-in role vs custom role vs conditions

RequirementPreferred
Standard duties (read-only, VM management, network management)Built-in role
"Nearly full control, but cannot grant access or change networking"ALZ custom roles (Application-Owners, etc.)
"Can assign roles, but only some of them, and only to groups"RBAC Administrator + conditions (Module 2), not a custom role
"Can read only blobs with a certain index tag"Built-in data role + ABAC conditions
Managed identity used for DINE policy remediationBuilt-in roles only (CAF: remediation managed identities do not support custom roles)
Common misconceptions ① "Putting dangerous operations in NotActions makes them safe." If the same principal also holds Contributor, NotActions does nothing. NotActions only matters when this is the principal's only write role. ② "Listing several management groups in AssignableScopes makes the role reusable." You can list only one. To reuse a role across levels, put it at a common parent (usually alz). ③ "Custom roles can be used with Lighthouse." Lighthouse supports only built-in roles (Module 7). ④ "Microsoft.Compute/*/read is read-only." Note that some /action operations (such as listKeys) can return secrets.

Diagram: effective permissions = union of (Actions − NotActions) across each role

Application-Owners Actions: *NotActions: virtualNetworks/write …= everything except VNet writes and similar Network-Management Actions: */read, Microsoft.Network/*NotActions: —= includes virtualNetworks/write ∪ Effective permissions for the same user virtualNetworks/write: Allowed (from Network-Management)NotActions has no "deny" effect A true "deny" Deny assignmentCreated by deployment stack denySettings,or by services such as managed applications
Figure 3-1: NotActions applies only to the role it is in. A principal's multiple roles are combined as a union.

Valid and invalid ways to write AssignableScopes

AssignableScopesResult
["/providers/Microsoft.Management/managementGroups/alz"]✓ Recommended: usable by all subscriptions under alz
["/subscriptions/A", "/subscriptions/B"]✓ Usable on two subscriptions (the creator must have roleDefinitions/write on both)
[".../managementGroups/corp", ".../managementGroups/online"]✗ Only one management group allowed → change it to their common parent, landingzones
["/"] or ["/subscriptions/*"]✗ Cannot be root, cannot use wildcards
Contains DataActions + [".../managementGroups/alz"]✓ Can be created, but can only be assigned at subscription or lower scope, not on a management group

Custom role builder: live evaluation

Tick the permission strings to put in Actions and NotActions. The panel on the right evaluates in real time whether 8 test operations are allowed (using the same case-insensitive, wildcard-matching rules as ARM). Tick "Also holds Contributor" to see why NotActions is not a deny.

Actions
NotActions
Test operations
After you select permissions, the panel on the right updates in real time.
{ "Actions": [], "NotActions": [] }

Core commands: list operations, create roles, update roles

CommandPurposeNotes
az provider operation show --namespace Microsoft.Compute --query "resourceTypes[?name=='virtualMachines'].operations[].name"List all VM operationsPick the operation strings you need
az role definition list --name "Virtual Machine Contributor" -o jsonView built-in rolesAs a starting point
az role definition create --role-definition @role.jsonCreate a custom roleRequires roleDefinitions/write on all AssignableScopes
az role definition update --role-definition @role.jsonUpdateThe JSON must include Id (or name)
az role definition list --custom-role-only true --query "[].{name:roleName, scopes:assignableScopes}"List custom rolesFor auditing
az role definition delete --name "…" --scope …DeleteDelete all assignments first (including PIM eligible assignments)
cat > vm-operator.json <<'EOF'
{
  "Name": "Landing Zone VM Operator",
  "Description": "Start, stop, restart VMs and read monitoring data in a landing zone.",
  "Actions": [
    "Microsoft.Compute/virtualMachines/read",
    "Microsoft.Compute/virtualMachines/start/action",
    "Microsoft.Compute/virtualMachines/restart/action",
    "Microsoft.Compute/virtualMachines/deallocate/action",
    "Microsoft.Compute/virtualMachines/instanceView/read",
    "Microsoft.Network/networkInterfaces/read",
    "Microsoft.Insights/metrics/read",
    "Microsoft.Resources/subscriptions/resourceGroups/read",
    "Microsoft.Support/*"
  ],
  "NotActions": [], "DataActions": [], "NotDataActions": [],
  "AssignableScopes": ["/providers/Microsoft.Management/managementGroups/alz"]
}
EOF
az role definition create --role-definition @vm-operator.json --query "{name:roleName, id:name, scopes:assignableScopes}"
{
  "id": "5d0a1f3e-…",
  "name": "Landing Zone VM Operator",
  "scopes": [ "/providers/Microsoft.Management/managementGroups/alz" ]
}

How to verify: az role definition list --name "Landing Zone VM Operator" should find the role in any subscription under alz. Common mistakes: when you write the JSON in a PowerShell here-string, the quotes get escaped; the creator has permission on only one subscription but lists several AssignableScopes (you get a "linked scope(s)" error). Production use: put the JSON in the ALZ custom library and deploy it through the platform pipeline.

Lab 3: Create and verify the Landing Zone VM Operator (about 8 minutes)

View the custom roles deployed by ALZ
az role definition list --custom-role-only true \
  --query "[].{name:roleName, notActions:permissions[0].notActions}" -o json | head -40

If ALZ is not deployed, this list is empty. You can download the JSON from the ALZ library and create the role manually, replacing ${current_scope_resource_id} with /providers/Microsoft.Management/managementGroups/alz.

Create the VM Operator role from the "Commands" tab, and assign it to a new group other than grp-lz-myapp-prod-owners (for example, grp-lz-myapp-prod-operators), with scope rg-lz-myapp-cc.
az ad group create --display-name grp-lz-myapp-prod-operators --mail-nickname grp-lz-myapp-prod-operators -o none
az role assignment create --assignee-object-id $(az ad group show -g grp-lz-myapp-prod-operators --query id -o tsv) \
  --assignee-principal-type Group --role "Landing Zone VM Operator" \
  --scope /subscriptions/$LZ_SUB/resourceGroups/rg-lz-myapp-cc
Try an invalid AssignableScopes and observe the error.
jq '.Name="Bad Role" | .AssignableScopes=["/providers/Microsoft.Management/managementGroups/corp","/providers/Microsoft.Management/managementGroups/online"]' vm-operator.json > bad.json
az role definition create --role-definition @bad.json
(InvalidActionOrNotAction / BadRequest) … only one management group can be specified in AssignableScopes …

Error wording varies by version (the example is a paraphrase). In the portal, you will see "cannot add a second management group."

Verify the management group restriction on DataActions: add "DataActions": ["Microsoft.KeyVault/vaults/secrets/getSecret/action"] to the JSON, then try to assign it at the alz management group. The assignment should fail; assigning it on a subscription should succeed.
Cleanup (optional): after you delete the assignment with az role assignment delete, run az role definition delete --name "Bad Role".

Case 1: NotActions "cancelled out" by another role

Problem: the application team already has Application-Owners (which cannot write VNets), but they still changed the spoke's address space. Investigation showed that their group still had a legacy Contributor assignment on the subscription. Fix: use Resource Graph to find principals that hold several write roles at the same scope, and delete the legacy assignments. Enforce the hard "no VNet changes" requirement with policy (the Deny from hour 2) or with deployment stack denySettings, not only with NotActions.

Case 2: "future permissions" from wildcards

Problem: an operations custom role included Microsoft.Storage/*. A year later, storage added an operation that can export data, and the operations account gained that ability automatically. Fix: for read-only needs, use */read, and list write operations explicitly. Each quarter, compare the differences in az provider operation show.

Case 3: approaching the custom role limit

Problem: each project copied its own "Contributor." After a few years, the tenant is close to 5,000 custom roles. Fix: create roles by function rather than by project, set AssignableScopes to alz so they can be reused, and use Resource Graph to find custom roles with no assignments and delete them. (Note that PIM eligible assignments do not appear in ordinary queries.)

Common errors and fixes

… has permission to perform action 'Microsoft.Authorization/roleDefinitions/write' on scope '…'; however, it does not have permission … on the linked scope(s) …

Cause: you do not have permission to create role definitions on some AssignableScopes, or one of the scopes is invalid.

Fix: get User Access Administrator or Owner on all AssignableScopes (or on their parent management groups); remove invalid scopes.

You cannot add data action permissions when you have a management group as an assignable scope

Cause: portal limitation: a custom role with DataActions cannot be assigned at management group scope.

Fix: change AssignableScopes to a subscription; or keep one management group but assign only on subscriptions under it (the CLI / API can create it).

There are existing role assignments referencing role (code: RoleDefinitionHasAssignments)

Cause: the role is still assigned (including PIM eligible assignments).

az role assignment list --all --role "Landing Zone VM Operator" -o table

Fix: delete all assignments and PIM eligibilities, then delete the role.

Role definition limit exceeded. No more role definitions can be created (code: RoleDefinitionLimitExceeded)

Cause: the tenant already has 5,000 custom roles.

Fix: use Resource Graph to find custom roles with no assignments and delete them; merge the roles that were copied per project.

Policy remediation task failed: the managed identity has no permission (custom roles are not valid)

Cause: the remediation managed identity for DINE / Modify policies supports only built-in role definitions.

Fix: use built-in roles in the policy definition's roleDefinitionIds (hour 2, Module 7).

Command-line exercises
1. List all operation names for Microsoft.Compute/virtualMachines.
az provider operation show --namespace Microsoft.Compute --query "resourceTypes[?name=='virtualMachines'].operations[].name" -o tsv
2. List all custom roles and their AssignableScopes.
az role definition list --custom-role-only true --query "[].{name:roleName, scopes:assignableScopes}" -o json
Scenario analysis
The security team requires that application teams cannot read Key Vault secrets, but can manage the Key Vault resources themselves. How would you design this?

Key Vault with the RBAC permission model: the application teams' Application-Owners role has only control-plane permissions (Actions: *, no DataActions), so it cannot read secrets by default. Data-plane access is granted through the built-in Key Vault Secrets User role, assigned only to the workload's managed identity (Module 7) and scoped to a single vault. Application-Owners' NotActions already excludes deletedVaults/purge/action, which prevents purging a soft-deleted vault. If the team also holds Contributor or other roles, clean those up too, because NotActions is not a deny. If a person needs to read a secret temporarily, use PIM eligibility with approval.

Verified teaching videos

▶
Azure Role-Based Access Control Deep Dive — John Savill's Technical Training
English · covers custom roles, NotActions, and DataActions
▶
Azure AD Administrative Units Overview — John Savill's Technical Training
English · Entra-side least privilege: using administrative units to narrow the scope of Entra roles

No verified video specifically on ALZ custom roles was found, so the storyboard below is provided instead.

Official docs and further reading

Video storyboard (about 90 seconds)

Shot 1 · 0–20s
Visual: a JSON card, with four columns lighting up in turn: Actions, NotActions, DataActions, AssignableScopes.
Narration: A custom role is four lists: what it can do, what it subtracts, what it can do on the data plane, and where it can be assigned.
Shot 2 · 20–45s
Visual: two roles overlap, and NotActions is filled in by the other role's Actions.
Narration: NotActions is not a deny. Multiple roles combine as a union.
Shot 3 · 45–70s
Visual: AssignableScopes tries to list two management groups, and a red cross blocks it. An arrow points to the common parent, alz.
Narration: You can list only one management group, so put the role at alz. Then the whole ALZ can reuse it.
Shot 4 · 70–90s
Visual: cards for the 5 roles in the ALZ library.
Narration: ALZ already provides five roles for subscription owners, application teams, networking, and security. Use them first, then add more as needed.
or score ≥ 70% on the quiz

Module 4 · Privileged Identity Management: just-in-time access and approval

21:00 – 28:00 · No standing Owner: you hold only eligibility. When you need access, you request it, verify, and get approval. It takes effect for a limited time and expires automatically. Confirm the licensing before you start.
7 minLicense: Entra ID P2 or ID GovernancePIM for Groups★★★★★
Learning objectives
  • Distinguish eligible assignments from active assignments. Understand that on activation, PIM creates a role assignment with an end time in ARM, and deletes it when it expires.
  • Configure PIM settings for Azure resource roles: maximum activation duration (1–24 hours), MFA or a Conditional Access authentication context, justification, ticket number, and approvers. Know that settings are per role and per resource, and they do not inherit from a subscription to a resource group.
  • Explain the licensing requirements and what happens when a license expires. Following CAF guidance, use PIM for Groups to manage the high-privilege groups of the platform and the landing zone.
Prerequisite: role assignments from Module 2. Importance: ★★★★★

What: the three object types PIM manages

TypeObjectTypical use in ALZ
Microsoft Entra rolesGlobal Administrator, Privileged Role Administrator, Conditional Access Administrator, and so onFewer than 5 Global Administrators, all as eligible + approval (emergency accounts excepted, Module 5)
Azure resource rolesOwner, Contributor, User Access Administrator, and custom roles on management groups, subscriptions, resource groups, and resourcesPlatform admins: Contributor on platform; Owner on the landing zone subscription for temporary troubleshooting
PIM for GroupsMembership and ownership of security groups (or M365 groups)CAF recommendation: assign Azure roles to a group, then use PIM to manage "who becomes a group member, and when"

Eligible vs active, permanent vs time-limited

EligibleActive
Meaning"Can request." No permissions at all by defaultThe permission is in effect now
How you get the permissionActivate: meet MFA / authentication context requirements, provide a justification, and possibly wait for approvalTakes effect immediately (the admin can require MFA and a justification when creating it)
DurationEligibility can be permanent, or set to expire (for example, after 1 year)Can be permanent or time-limited; an active assignment created by activation always has an end time
Counts toward the 5,000-assignments-per-subscription limit?NoYes
How it looks in ARMroleEligibilitySchedulesAn ordinary roleAssignments (end times are recorded in roleAssignmentSchedules)

How: activation settings (Azure resource roles, configured per role and per resource)

  • Maximum activation duration: 1–24 hours. Platform troubleshooting usually takes 2–4 hours.
  • Require MFA on activation, or a stronger Conditional Access authentication context. Combined with an authentication strength, this requires phishing-resistant MFA and a compliant device. If you want re-verification on every activation, set sign-in frequency to "every time" in the CA policy for that context. Microsoft's note: anyone who can change CA policies can change activation requirements, so treat them as high privilege.
  • Require justification / ticket number: the ticket number is an informational field only; it is not validated against your ticketing system.
  • Require approval: select at least one approver (two recommended). Azure resource roles have no default approvers. Approvers do not need any role, and they cannot approve their own requests.
  • Assignment duration: whether permanent eligibility / permanent active assignments are allowed; notifications before activation and before eligibility expires; Global Administrator and Privileged Role Administrator can renew.
  • Allow minimal-permission activation (preview): a user eligible for Contributor can activate only Reader, but is still bound by the Contributor policy.

Key detail: role settings do not inherit. An approval setting on Owner at the subscription does not automatically apply to Owner on a resource group under it. The CAF pattern is to manage eligibility at the management group or subscription level.

Licensing: who needs it, and what happens when it expires

License (verified 2026-11-18): using PIM and all its settings requires Microsoft Entra ID P2 or Microsoft Entra ID Governance (Entra Suite and Microsoft 365 E7 also include ID Governance capabilities; E5 includes P2). The license does not need to be assigned to specific users, but the count must cover: users with eligible or time-limited assignments (Entra roles, Azure roles, PIM for Groups members and owners), people who can approve activations, and people who take part in access reviews. Microsoft states that new identity governance features will be added only to ID Governance, not to P2.

When the license (or trial) expires: active permanent assignments are unaffected; time-limited active assignments become permanent (they no longer expire automatically!); eligible assignments are deleted; the PIM UI, API, and PowerShell can no longer activate or manage anything; in-progress access reviews end, PIM settings are removed, and emails and alerts stop. In short, when the license lapses, people who need to activate lose access, while permissions that should have expired stay in place. Always monitor license renewal.

When: the CAF-recommended PIM pattern for ALZ

  • Assign high-privilege Azure roles such as Owner and User Access Administrator to a group, then manage group membership with PIM for Groups. This way, Azure roles and Entra roles go through the same activation process.
  • Example: an application admin normally sits in the Application Administrators group (minimal privilege). When they need Owner, they activate their membership in the Application Owners group through PIM.
  • Platform admins access workload landing zones through PIM with approval, which keeps duties separated.
  • Run regular PIM access reviews. Govern automation that needs elevated rights (such as a privileged deployment pipeline) at the same level as people, and prevent application owners from using the pipeline to elevate their own privileges.
Common misconceptions ① "You can use the role right after PIM activation." After the active assignment is written to ARM, old tokens and caches may need to refresh; sign in again if needed. ② "If I set up approval on the subscription, the same role on a resource group also requires approval." Settings do not inherit. ③ "Service principals can activate through PIM too." Workload identities cannot activate themselves (Lighthouse also explicitly does not support service principals for eligible authorization). Pipelines get standing least-privilege assignments (Module 6). ④ "If everyone is eligible, we're covered." Emergency access accounts must be permanently active Global Administrators (Module 5); otherwise, if PIM or MFA fails, nobody can get in.

Sequence diagram: from eligibility to permission, and then reclaiming it

alz-admin1Entra (CA / MFA)PIM serviceApproverAzure Resource Manager ① Request activation (role, 2h duration, justification) ② Require MFA / authentication context Satisfied (FIDO2 / compliant device) ③ Pending-approval notification Approved ④ Create role assignment (endDateTime = +2h) ⑤ Call ARM with the new token (sign in again if needed) ⑥ RBAC decision: allowed ⑦ On expiry: delete the role assignment, return to "eligible only"
Figure 4-1: PIM does not change how RBAC makes its decision. It only creates and deletes an ordinary role assignment at the right times.

Structure diagram: the CAF-recommended "group + PIM" pattern

GroupAzure role assignment (standing)Group membership
grp-alz-platform-readersReader @ alzPermanent member (everyday visibility)
grp-alz-platform-adminsContributor @ platformPIM for Groups eligible member, activates for 4 hours, requires MFA + justification
grp-lz-myapp-prod-breakfixOwner @ sub-lz-corp-myappPIM eligibility, activates for 2 hours, requires approval from the application owner

Core animation: the authorization chain from PIM activation to resource operations

Adjust the switches, click "Next," and observe the object changes that actually happen in Entra and ARM at each step, and the result of the same az group delete request at different stages.

Ready: alz-admin1 has Owner "eligibility" on sub-lz-corp-myapp.
$ az group delete -n rg-test --yes

Core commands: manage PIM (Azure resource roles) with the ARM API

The Azure CLI has no dedicated PIM subcommands. PIM for Azure resource roles is handled through the ARM Microsoft.Authorization scheduling APIs (az rest). Azure PowerShell has matching cmdlets.

API / commandPurpose
PUT {scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{guid} (requestType: AdminAssign)Create eligibility assignment
PUT {scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{guid} (requestType: SelfActivate)Activate eligibility
GET {scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?$filter=asTarget()What eligibilities do I have
GET {scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignmentsView the PIM settings for each role at this scope
New-AzRoleEligibilityScheduleRequest / New-AzRoleAssignmentScheduleRequestPowerShell equivalent
Get-AzRoleEligibilityScheduleInstance -Scope …List eligibilities (ordinary role assignment queries cannot see them)
SCOPE="/subscriptions/$LZ_SUB"
OWNER="$SCOPE/providers/Microsoft.Authorization/roleDefinitions/8e3af657-a8ff-443c-a75c-2fe8c4bcb635"
GID=$(az ad group show -g grp-alz-platform-admins --query id -o tsv)
# 1) Admin: make Owner eligible for grp-alz-platform-admins (1 year)
az rest --method put \
  --url "$SCOPE/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/$(uuidgen)?api-version=2020-10-01" \
  --body "{\"properties\":{\"principalId\":\"$GID\",\"roleDefinitionId\":\"$OWNER\",\"requestType\":\"AdminAssign\",\
  \"justification\":\"ALZ break-fix eligibility\",\"scheduleInfo\":{\"startDateTime\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\
  \"expiration\":{\"type\":\"AfterDuration\",\"duration\":\"P365D\"}}}}"
# 2) After alz-admin1 (a group member) signs in: activate for 2 hours
ME=$(az ad signed-in-user show --query id -o tsv)
az rest --method put \
  --url "$SCOPE/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/$(uuidgen)?api-version=2020-10-01" \
  --body "{\"properties\":{\"principalId\":\"$ME\",\"roleDefinitionId\":\"$OWNER\",\"requestType\":\"SelfActivate\",\
  \"justification\":\"INC-1234 fix diagnostic settings\",\"scheduleInfo\":{\"startDateTime\":null,\
  \"expiration\":{\"type\":\"AfterDuration\",\"duration\":\"PT2H\"}}}}" --query "properties.status"
{ "properties": { "status": "Provisioned", "requestType": "AdminAssign", … } }
"PendingApproval"          # when approval is configured; without approval it is "Provisioned"

How to verify: after activation, az role assignment list --assignee $ME --scope $SCOPE shows Owner; after expiry, it disappears. Common mistake: the eligibility is granted to a group, but the activation request's principalId contains the group ID. For self-activation, use your own object ID (PIM matches the eligibility you get through the group). If you get an error, use PIM for Groups to activate group membership instead. Production use: write eligibility assignments in IaC (subscription vending template); people activate them through the portal or My Access.

# PowerShell equivalent (activation)
New-AzRoleAssignmentScheduleRequest -Name (New-Guid).Guid -Scope "/subscriptions/$LzSub" `
  -PrincipalId $me -RoleDefinitionId $owner -RequestType SelfActivate `
  -Justification "INC-1234" -ScheduleInfoStartDateTime (Get-Date).ToUniversalTime().ToString("o") -ExpirationDuration PT2H -ExpirationType AfterDuration

Lab 4: Change Owner to a PIM eligibility and activate it once (about 8 minutes)

Prerequisite: the sandbox tenant needs Entra ID P2 or ID Governance (a trial is fine). Without a license, complete steps 1 and 5 (a read-only walkthrough), and use the "conditional delegation" from Module 2 instead.
Confirm the license: Entra admin center → Billing → Licenses → Licensed features. Confirm that P2 or ID Governance is shown.
az rest --url "https://graph.microsoft.com/v1.0/subscribedSkus" --query "value[].{sku:skuPartNumber, enabled:prepaidUnits.enabled}" -o table
Sku                     Enabled
----------------------  ---------
AAD_PREMIUM_P2          100
Set PIM rules for Owner on sub-lz-corp-myapp: Entra admin center → ID Governance → Privileged Identity Management → Azure resources → select the subscription → Settings → Owner → Edit: maximum activation 2 hours, require MFA (or the authentication context), require justification, require approval (select your admin account as approver), and eligibility expires after 1 year.
Create the eligibility assignment: run part 1 of the "Commands" tab (or portal "Add assignments" → type "Eligible"). Confirm that an ordinary query cannot see it:
az role assignment list --scope /subscriptions/$LZ_SUB --role Owner -o table      # eligibility is not shown here
az rest --url "/subscriptions/$LZ_SUB/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?api-version=2020-10-01" \
  --query "value[].{principal:properties.principalId, role:properties.expandedProperties.roleDefinition.displayName, end:properties.endDateTime}" -o table
Activate as alz-admin1 (portal: My roles → Azure resources → Activate; or part 2 of the commands). Approve the request under "Approval requests" with the admin account. Then:
az logout; az login --tenant <sandbox-tenant-id>   # alz-admin1
az role assignment list --assignee $(az ad signed-in-user show --query id -o tsv) --all -o table
Principal                          Role   Scope
---------------------------------  -----  -------------------------
alz-admin1@contosolab.onmicrosoft.com  Owner  /subscriptions/1111…
Review the audit: PIM → Azure resources → Resource audit. The Azure Activity Log shows the creation of the role assignment and, after expiry, its deletion. Two hours later, run the previous step again; Owner should be gone.

Case 1: the license trial expires and "temporary" permissions become permanent

Problem: a team turned on PIM during a P2 trial and gave external contractors 30-day time-limited Owner. When the trial expired, those time-limited active assignments became permanent, the eligibility assignments were all deleted, and platform admins could no longer activate anything. Fix: complete procurement during the trial period; monitor license status; export all eligibility and time-limited assignments before expiry. Lesson: PIM security depends on the license staying valid.

Case 2: settings do not inherit, which allows bypassing approval

Problem: Owner on a subscription requires approval, but someone made themselves Owner-eligible on a resource group. The Owner rule on that resource group was still the default (no approval). Fix: set eligibility only at the management group or subscription level; periodically scan lower-level eligibilities with Resource Graph and the PIM API; use Azure Policy or a process to restrict who can create eligibility assignments.

Case 3: PIM for Groups unifies the elevation process for Entra and Azure

Problem: administrators need to elevate both Groups Administrator in Entra and Contributor in Azure, and two separate activations are easy to miss. Fix: following CAF guidance, create a role-assignable group, assign both the Entra role and the Azure role to it, and have people activate group membership once. Limitation: after group membership is activated, the group claim in the token may not update until you sign in again.

Common errors and fixes

Activation succeeded, but the operation still fails with AuthorizationFailed

Cause: old token or ARM cache (up to about 10 minutes); or the activation was made at the wrong scope.

az logout; az login
az role assignment list --assignee <me> --all --query "[].{role:roleDefinitionName, scope:scope}" -o table

Fix: sign in again; confirm that the activated scope covers the target resource.

The role assignment request is pending approval / nobody approves it

Cause: approval is configured, but the approvers are unavailable; Azure resource roles have no default approvers.

Fix: configure at least two approvers (preferably from different teams); keep emergency access accounts for urgent cases instead of lowering the approval requirement.

RoleAssignmentRequestPolicyValidationFailed / ExpirationRule validation failed

Cause: the requested duration exceeds the maximum allowed by that role's PIM settings, or a required justification or ticket is missing.

Fix: check the rules in roleManagementPolicyAssignments, change duration to within the limit (for example, PT2H), and add a justification.

PIM menu disappears / The tenant does not have a valid license

Cause: the P2 / ID Governance license (or trial) has expired. Eligible assignments have been deleted, and time-limited active assignments have become permanent.

Fix: restore the license, then recreate the eligibilities; immediately review all assignments that "became permanent" and delete them.

Cannot delete the last Owner on a subscription (to change it to eligibility only)

Cause: default protection.

Fix: first activate your own Owner eligibility, then delete the standing Owner assignment, then let the activation expire naturally (the method Microsoft documents).

Command-line exercises
1. List all PIM eligibility instances on subscription $LZ_SUB (principal, role, expiry time).
az rest --url "/subscriptions/$LZ_SUB/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?api-version=2020-10-01" --query "value[].{p:properties.principalId, role:properties.expandedProperties.roleDefinition.displayName, end:properties.endDateTime}" -o table
2. Use PowerShell to list the eligibility assignments on a management group.
Get-AzRoleEligibilityScheduleInstance -Scope "/providers/Microsoft.Management/managementGroups/platform"
Scenario analysis
An audit finds that six platform team members are standing Owners on the alz management group. Design a remediation plan that does not disrupt daily operations and does not increase the risk of lockout.

① First confirm the license (P2 / ID Governance must cover these six people and the approvers). ② Create grp-alz-platform-readers (Reader at alz, standing) and grp-alz-platform-admins (Contributor at platform, PIM for Groups eligibility). Owner exists only as a PIM eligibility on alz, activated for 2 hours with phishing-resistant MFA and cross-team approval. ③ Keep two emergency access accounts (permanently active Global Administrator, which can elevate access) as a last resort. ④ After you activate your own Owner eligibility once, remove the standing Owners one by one. ⑤ Turn on alerts for PIM activation and quarterly access reviews. ⑥ The platform pipeline identity is unaffected (workload identities do not go through PIM; see Module 6).

Verified teaching videos

▶
Azure AD Privileged Identity Management (PIM) - AZ-500, SC-300 Deep Dive Topic — John Savill's Technical Training
English · eligibility and activation, approval, PIM for Groups (the product has since been renamed Entra)
▶
Azure Master Class v3 - Part 2 - Identity — John Savill's Technical Training
English · a full identity course, including a PIM chapter

Official docs and further reading

Video storyboard (about 90 seconds)

Shot 1 · 0–20s
Visual: a gray key labeled "Eligible".
Narration: In PIM, you normally hold only eligibility, not permissions.
Shot 2 · 20–50s
Visual: request → FIDO2 → the approver nods → a role assignment with a countdown appears in ARM.
Narration: When you activate, you verify your identity, state your justification, and wait for approval. Only then does PIM create a time-limited role assignment in ARM.
Shot 3 · 50–70s
Visual: the countdown reaches zero, the role assignment disappears, and the request turns red.
Narration: It expires and is reclaimed automatically. The RBAC decision itself has not changed. What changes is how long that assignment exists.
Shot 4 · 70–90s
Visual: the license icon turns gray, the eligibility key disappears, and the time-limited key becomes permanent.
Narration: Don't forget licensing. If P2 or ID Governance expires, eligibilities are deleted, and time-limited assignments become permanent.
or score ≥ 70% on the quiz

Module 5 · Emergency access accounts and Conditional Access

28:00 – 35:00 · The tighter you lock down permissions, the more you need a spare key in the safe. Azure also now enforces MFA on all management operations, so automation that runs on user accounts has to move off them.
7 minMandatory MFA phase 1: from 2024-10 · phase 2: from 2025-10-01Conditional Access: Entra ID P1★★★★★
Learning objectives
  • Set up and maintain at least two emergency access accounts according to the official checklist: cloud-only, on the *.onmicrosoft.com domain, permanently active Global Administrator, FIDO2 passkey or certificate-based authentication, excluded from blocking Conditional Access policies, alerted on every sign-in, and tested at least every 90 days.
  • Design Conditional Access for Azure administrators: phishing-resistant MFA (authentication strength), report-only mode first, protected actions, and the PIM authentication context.
  • Explain the two phases of Azure mandatory MFA, the clients and operations it covers, the postponement options, and its impact on automation: managed identities and service principals are not affected, but automation that uses a user account as a service account will fail.
Prerequisite: Module 4. Importance: ★★★★★ (locking yourself out of a tenant is one of the hardest incidents to recover from)

What: emergency access (break-glass) accounts

Official use cases: a federated identity provider is down; all of an admin's MFA devices are unavailable; the last Global Administrator leaves the company; a natural disaster cuts mobile networks; or all Global Administrators and Privileged Role Administrators are PIM-eligible and require approval, but there is no approver, so the tenant is effectively locked.

Requirement (official security guardrails checklist)Reason
At least 2 accountsRedundancy
Cloud-only accounts on the *.onmicrosoft.com domain, not federated, not syncedDoes not depend on on-premises AD, AD FS, or other systems that may fail
Phishing-resistant authentication: passkeys (FIDO2, recommended) or certificate-based authentication, and different methods from the day-to-day admin accountsStill subject to Azure mandatory MFA; avoid having one failure affect both
Permanently active Global Administrator in PIM (not eligibility)Still gets in when PIM or approval fails
Excluded from CA policies that block or restrict sign-in (report-only policies do not need the exclusion)Prevents a CA misconfiguration from locking everyone out
Credentials and devices do not expire and are not cleaned up automatically; stored in a separate, secure, fire-protected locationMust be available when needed
Alert on every sign-in, and do a post-incident reviewThey are the most valuable attack targets
Test at least every 90 days (and after staff changes)Verify that sign-in still works and that alerts still fire
Use a dedicated secure workstation (PAW)Prevents credentials from leaking onto untrusted devices

A common approach is to create a security group (such as grp-alz-emergency-access), put both accounts in it, and exclude this group from every blocking CA policy. Note: Azure mandatory MFA applies to emergency accounts too, so "excluded from CA" does not mean "no MFA." They must have FIDO2 or certificate credentials.

Why: Azure mandatory MFA changes the rules for automation

PhaseStart dateScopeOperations that require MFA
Phase 1Starting October 2024, rolled out in stages (Microsoft 365 admin center from February 2025)Azure portal, Microsoft Entra admin center, Intune admin centerAny create, read, update, or delete (CRUD)
Phase 2Rolled out in stages starting 2025-10-01Azure CLI, Azure PowerShell, Azure mobile app, IaC tools, REST API control plane, Azure SDKs: every request sent to management.azure.comCreate, update, delete (read operations are not required)
  • Not affected: workload identities, meaning managed identities and service principals (including service principals with federated credentials).
  • Affected: all user accounts, including student accounts, emergency accounts, admins with active or eligible roles, and B2B guests (MFA can be performed by the resource tenant, or trusted from the guest's home tenant through cross-tenant access settings). Test tenants are not exempt either.
  • "User account as service account": accounts that sign in with a username and password in scripts, Terraform, or scheduled tasks will fail on write operations. Microsoft recommends migrating to workload identities (managed identities or service principals). The ROPC (resource owner password credentials) flow is incompatible with MFA.
  • Postponement: phase 1 can be postponed to 2025-09-30; phase 2 can be postponed to 2026-07-01 (aka.ms/postponePhase2MFA, requires Global Administrator and first elevating access). As of this course's verification date (2026-11-18), both postponement windows have ended. Once phase 2 has started, it can be lifted temporarily only through a support request.
  • No opt-out. Enforced only in the public cloud; sovereign clouds such as Azure Government are not yet included. Microsoft Graph API requests are generally out of scope; only requests to management.azure.com are in scope.
  • Client recommendation: Azure CLI 2.76+ and Azure PowerShell 14.3+, for clear error messages and the --claims-challenge prompt.

How: Conditional Access baseline (ALZ administrators)

PolicyTargetGrant controlExclusions
CA01 Admin phishing-resistant MFAUsers with privileged Entra roles; apps: Windows Azure Service Management API and Microsoft Admin PortalsAuthentication strength: phishing-resistant MFAgrp-alz-emergency-access
CA02 MFA for all usersAll users, all resourcesRequire MFAEmergency access group; workload identities are not in the "users" scope
CA03 Block legacy authenticationAll usersBlockEmergency access group
CA04 PIM activation contextAuthentication context c1 (referenced by PIM settings)Phishing-resistant MFA + compliant device + sign-in frequency "every time"—
Protected actionsSensitive operations such as changing Conditional Access policies and cross-tenant access settingsThe specified authentication context—

Roll out new policies in report-only mode first, and check the "report-only" results in the sign-in logs before you enforce them. Without a P1 license, use security defaults. You can also use the built-in Azure Policy definition for "self-enforcing" MFA (Audit first, then Deny) to assess the phase 2 impact. Conditional Access for workload identities requires the Workload Identities license.

When: deciding how to migrate automation identities

Current stateAfter phase 2Migrate to
Pipeline uses a service principal + secretNot affected by MFA, but the risk of a leaked secret remainsWorkload identity federation (Module 6)
Managed identity in VMs / automation accounts / FunctionsNot affectedKeep (Module 7)
az login -u svc-deploy@… -p … in a scriptWrite operations fail (MFA required)Managed identity, or a service principal with federated credentials
Terraform using an individual's az login sessionInteractive sign-in with MFA completedMove production pipelines to workload identities
Common misconceptions ① "Excluding emergency accounts from CA means they don't need MFA." Azure mandatory MFA does not look at CA exclusions, so emergency accounts must have FIDO2 or certificate credentials. ② "Read-only scripts are not affected, so we're fine." Phase 2 requires MFA only for create, update, and delete, but the portal (phase 1) requires it for reads too. ③ "Excluding a service account in Conditional Access lets it bypass MFA." Mandatory enforcement is not affected by CA exclusions. ④ "Emergency accounts should go through PIM approval too." Official guidance explicitly requires permanently active assignments.

Decision diagram: what happens on one sign-in or one ARM write request

Identity type?User / workload Managed identity / service principalMandatory MFA does not apply User (including emergency accounts and guests)Evaluate Conditional Access first Does a CA policy match?Excluded group / report-only, not blocked Azure mandatory MFAPortal: all operationsCLI / IaC / API: write operations Token contains MFA claim→ ARM RBAC (Module 2) MFA completed Write request without MFA → RequestDisallowedByPolicy“Users must use MFA for Create/Update operations” Note: CA exclusions do not affect system enforcement; emergency accounts need FIDO2 or certificates
Figure 5-1: Conditional Access is a policy you configure; mandatory MFA is a system requirement that Azure enforces on the ARM side. The two stack.

Timeline: mandatory MFA

TimeEvent
From 2024-10Phase 1 rolled out in stages: Azure portal, Entra admin center, Intune admin center
From 2025-02Microsoft 365 admin center begins enforcement
2025-09-30Latest date phase 1 can be postponed to
From 2025-10-01Phase 2 rolled out in stages: write operations for CLI, PowerShell, mobile apps, IaC, REST control plane, and SDKs
2026-07-01Latest date phase 2 can be postponed to (passed)

Evaluator: "Will this operation be blocked?"

Choose an identity, client, operation, and CA configuration. The evaluator reasons through the official rules: workload identities are outside the enforcement scope; the portal requires MFA for all operations; CLI / PowerShell / IaC / REST require it only for write operations; CA exclusions do not affect system enforcement.

After you select a combination, click "Evaluate."
Waiting for evaluation…

Core commands: emergency accounts, CA policies, alerts

Command / APIPurpose
az ad user create --user-principal-name bg-admin01@<tenant>.onmicrosoft.com …Create a cloud-only emergency account
POST https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignmentsPermanently assign Global Administrator (template ID 62e90394-69f5-4237-9190-012177145e10)
POST https://graph.microsoft.com/v1.0/identity/conditionalAccess/policiesCreate a CA policy (state: enabledForReportingButNotEnforced means report-only)
GET …/identity/conditionalAccess/authenticationStrength/policiesView authentication strengths (built-in "phishing-resistant MFA")
SigninLogs | where UserId in (…)KQL for alerting on emergency account sign-ins
az login --tenant … --scope "https://management.core.windows.net//.default" --claims-challenge "<token>"MFA remediation sign-in prompt for CLI 2.76+
DOMAIN=$(az rest --url https://graph.microsoft.com/v1.0/domains --query "value[?isInitial].id" -o tsv)  # *.onmicrosoft.com
for n in 01 02; do
  az ad user create --display-name "Emergency Access $n" --user-principal-name bg-admin$n@$DOMAIN \
    --password "$(openssl rand -base64 24)" -o none
  BGID=$(az ad user show --id bg-admin$n@$DOMAIN --query id -o tsv)
  az ad group member add --group grp-alz-emergency-access --member-id $BGID
  az rest --method post --url https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments \
    --body "{\"principalId\":\"$BGID\",\"roleDefinitionId\":\"62e90394-69f5-4237-9190-012177145e10\",\"directoryScopeId\":\"/\"}" -o none
done
# CA01: admin phishing-resistant MFA (report-only)
EXCL=$(az ad group show -g grp-alz-emergency-access --query id -o tsv)
cat > ca01.json <<EOF
{ "displayName": "CA01 - Admins - Phishing-resistant MFA (report-only)",
  "state": "enabledForReportingButNotEnforced",
  "conditions": {
    "users": { "includeRoles": ["62e90394-69f5-4237-9190-012177145e10","e8611ab8-c189-46e8-94e1-60213ab1f814"],
               "excludeGroups": ["$EXCL"] },
    "applications": { "includeApplications": ["797f4846-ba00-4fd7-ba43-dac1f8f63013"] },
    "clientAppTypes": ["all"] },
  "grantControls": { "operator": "AND", "authenticationStrength": { "id": "00000000-0000-0000-0000-000000000004" } } }
EOF
az rest --method post --url https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies --body @ca01.json --query "{id:id, state:state}"
{ "id": "3f1c…", "state": "enabledForReportingButNotEnforced" }

ID notes: 62e90394-… is the role template ID for Global Administrator, and e8611ab8-… is the one for Privileged Role Administrator. 797f4846-… is Windows Azure Service Management API, and …0004 is the built-in authentication strength "Phishing-resistant MFA". Check these IDs against Graph before you submit; the official documentation is the reference for IDs. Calling the CA API requires the Policy.ReadWrite.ConditionalAccess permission. The default Azure CLI token may not include it, so you can do this in Graph Explorer or the portal instead. How to verify: the "report-only" view in the sign-in logs shows CA01's expected result. Common mistake: enabling the policy without first excluding the emergency access group.

Lab 5: two emergency accounts + report-only CA + sign-in alerts (about 10 minutes)

Create bg-admin01 / bg-admin02 (part 1 of the "Commands" tab). In the portal, register a separate FIDO2 security key for each account (Authentication methods → Passkey (FIDO2) must be enabled in the policy first). Store the keys separately. Use the password only for the initial registration.
Confirm they are permanent active assignments: PIM → Microsoft Entra roles → Global Administrator → Assignments → on the "Active" tab, the end time for both accounts should read "Permanent."
Create CA01 (report-only) and check:
az rest --url https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies \
  --query "value[].{name:displayName, state:state, excluded:conditions.users.excludeGroups}" -o json

Without a P1 license, skip this step and instead confirm that "security defaults" is enabled.

Sign-in alerts: make sure hour 1 already sent the Entra sign-in logs to law-alz-mgmt-cc through diagnostic settings, then create a log alert (severity 0, threshold > 0):
SigninLogs
| where UserPrincipalName startswith "bg-admin"
| project TimeGenerated, UserPrincipalName, IPAddress, AppDisplayName, ResultType, AuthenticationRequirement
Test: sign in to the Azure portal as bg-admin01 with FIDO2 in a PAW or a private window, and confirm the alert fires within a few minutes. Record the test date (the next test is due within 90 days).
Check for "user accounts used as service accounts": in the Entra sign-in logs, filter for non-interactive sign-ins where the app is Azure CLI or PowerShell and the authentication requirement is "single-factor" for users. These are the automations that need to move to workload identities.

Case 1: a CA policy misconfiguration locks out all administrators

Problem: an admin created a policy requiring "all users to use compliant devices," turned it on directly, excluded no one, and the admin's laptop happened to be non-compliant. Fix: sign in with an emergency account (already excluded from the policy) and disable the policy. Improvement: roll out all new policies in report-only mode first; make excluding the emergency access group part of the policy template; treat changes to CA as protected actions.

Case 2: overnight jobs all fail after phase 2 starts

Problem: a script on an operations VM ran az login with the svc-ops@contoso.com username and password, then created snapshots. After phase 2 took effect, write operations failed with RequestDisallowedByPolicy … MFA is required. Fix: enable a managed identity on the VM (Module 7), assign Disk Snapshot Contributor, and change the script to az login --identity; then delete the svc-ops account and reclaim its license.

Case 3: an emergency account is used quietly

Problem: an engineer used an emergency account for day-to-day changes because it was convenient. Fix: run a post-incident review when the sign-in alert fires; rotate the credentials; write the rules for emergency account use into policy (two people present at all times, and a mandatory review afterward).

Common errors and fixes

(RequestDisallowedByPolicy) Resource was disallowed by policy. … Users must use MFA for Create/Update operations.

Cause: phase 2 mandatory MFA: the current token has no MFA claim, and the operation is a write.

az version --query '"azure-cli"'      # recommended ≥ 2.76
az logout
az login --tenant "<tenant-id>" --scope "https://management.core.windows.net//.default" --claims-challenge "<claims-challenge-token>"

Fix: Interactive users: complete MFA at sign-in (ideally enforced by CA at sign-in). Automation: switch to managed identities, or to service principals with federated credentials.

Due to a configuration change made by your administrator … you must enroll in multi-factor authentication.

Cause: an older CLI (≤ 2.75) prompts for the same situation, and the account has not registered an MFA method yet.

Fix: upgrade the CLI; register MFA for the account (automation accounts should be migrated to workload identities instead).

Emergency account sign-in blocked: AADSTS53003 Access has been blocked by Conditional Access policies

Cause: a blocking policy does not exclude the emergency access group.

Fix: use the second emergency account (if it is blocked too, contact Microsoft Support). After the fix, add "emergency access group is excluded" to the policy review pipeline.

ROPC / UsernamePasswordCredential throws an exception (AADSTS50076 and other errors that require MFA)

Cause: the resource owner password credential flow is incompatible with MFA; the MSAL / Azure Identity libraries in each language have already marked it as deprecated.

Fix: use ManagedIdentityCredential, WorkloadIdentityCredential, or a service principal with certificate or federated credentials; delete the environment variables AZURE_USERNAME and AZURE_PASSWORD.

Command-line exercises
1. List the name, state, and excluded groups of all CA policies.
az rest --url https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies --query "value[].{name:displayName, state:state, excl:conditions.users.excludeGroups}" -o json
2. Write the KQL that queries emergency account sign-ins.
SigninLogs | where UserPrincipalName startswith "bg-admin" | project TimeGenerated, UserPrincipalName, IPAddress, ResultType
Scenario analysis
You take over a tenant. The only Global Administrator is the IT manager's personal account (federated to on-premises AD FS). All admins are PIM-eligible and require that manager's approval. The Terraform pipeline uses a user account with a password. List the risks and the order of remediation.

Risks: an AD FS outage or the manager leaving locks out the entire tenant; a single approver is a single point of failure; the pipeline's write operations fail after phase 2 mandatory MFA, and the password-based account carries a high risk of leaking. Order: ① immediately create two cloud-only emergency accounts on *.onmicrosoft.com with permanently active Global Administrator, register FIDO2, exclude them from blocking CA policies, configure sign-in alerts, and test them; ② at least two PIM approvers, from different teams; ③ change admin accounts to separate cloud-only admin accounts; ④ move the pipeline to workload identity federation (Module 6) and delete the user-type service account; ⑤ roll out the CA baseline in report-only mode before enforcing; ⑥ test the emergency accounts every 90 days.

Verified teaching videos

▶
Azure AD Conditional Access Overview — John Savill's Technical Training
English · Conditional Access conditions, grant controls, and evaluation
▶
Stronger Azure AD Authentication — John Savill's Technical Training
English · authentication strengths and phishing-resistant MFA
▶
Using Conditional Access with Authentication Flows — John Savill's Technical Training
English · using CA to control authentication flows such as device code

No verified video specifically covering the two phases of Azure mandatory MFA was found. Please refer to the official documentation.

Official docs and further reading

Video storyboard (about 90 seconds)

Shot 1 · 0–20s
Visual: two FIDO2 keys in a safe, labeled bg-admin01 and bg-admin02.
Narration: Every tenant needs at least two cloud-only emergency accounts, with permanent Global Administrator, signing in with FIDO2.
Shot 2 · 20–45s
Visual: a list of CA policies, each with "Exclude: emergency access group," and a new policy showing "Report-only."
Narration: Every blocking policy excludes the emergency group. New policies go to report-only first.
Shot 3 · 45–75s
Visual: a timeline with the 2024-10 portal and the 2025-10-01 CLI and IaC; a script with a password turns red while the managed identity stays green.
Narration: Azure mandatory MFA phase 2 covers write operations from the CLI, PowerShell, and IaC. Managed identities and service principals are not affected. User-type service accounts will fail.
Shot 4 · 75–90s
Visual: an alert bell rings, and the calendar marks a 90-day test.
Narration: Every emergency sign-in triggers an alert, and you test every 90 days.
or score ≥ 70% on the quiz

Module 6 · Deployment identities: workload identity federation (GitHub / Azure Pipelines)

35:00 – 42:00 · The step-by-step OIDC setup was covered in the CI course. This module answers the ALZ design questions: how many identities the platform and application pipelines each need, what permissions each one gets, and how to write the federated credential subject so that no other branch can “borrow” it
7 minNo secrets · Not affected by enforced MFAUp to 20 federated credentials per identity★★★★★
Learning objectives
  • Explain the real token exchange: the CI platform issues an OIDC token → Entra matches the federated credential exactly on issuer + subject + audience → Entra issues an ARM access token → RBAC makes the decision.
  • Following the ALZ IaC accelerator, split the platform pipeline identities into plan (Reader at the intermediate root + Storage Blob Data Contributor on the state container) and apply (Owner at the intermediate root + state container). Only a protected environment may use the apply identity.
  • Create a separate deployment identity for each application landing zone and each environment. Know the hard limits of federated credentials (20 per identity, no wildcards, propagation delay, concurrent creation conflicts on UAMIs) and the scope of “flexible federated identity credentials” (preview).
Prerequisites: GitHub hour 3, Module 2: OIDC federated identity or Azure DevOps hour 3, Module 2: Service connections and workload identity federation (this module does not repeat the workflow or service connection setup steps). Importance: ★★★★★

What: what workload identity federation does

On the Entra app registration or on a user-assigned managed identity (UAMI), you add a “federated identity credential” (FIC). It declares that you trust tokens issued by a given external issuer, with a given subject and a given audience. When the pipeline runs:

  1. The CI platform issues a short-lived OIDC token (JWT) for this run. For GitHub: iss = https://token.actions.githubusercontent.com, and sub looks like repo:<org>/<repo>:environment:<env> or …:ref:refs/heads/main or …:pull_request. For the issuer and subject formats of Azure DevOps service connections, see hour 3 of the ADO course.
  2. The sign-in steps (azure/login, AzureCLI@2, Terraform's use_oidc) send this JWT as a client_assertion to the Entra token endpoint.
  3. Entra looks in the identity's FIC for a record where issuer and subject both match exactly and the audience includes api://AzureADTokenExchange. It then validates the signature (officially, only issuers that sign with RS256 are tested).
  4. On a match, Entra issues a token for management.azure.com. From there, the RBAC decision from Module 2 applies.

Result: no long-lived secrets in the repository; the token is valid only for this run; and workload identities are not affected by Azure enforced MFA (Module 5).

Why: why ALZ splits identities

  • Separate plan and apply: the plan on a PR can be triggered by any contributor, so it must not have write permissions. Apply runs only after merge, in an environment that has been approved.
  • Separate platform and application: the platform apply identity has Owner at the intermediate root. It can change every policy and role, so it must be one of the most protected identities in the tenant. Application pipelines must never reuse it.
  • Separate environments: the CAF explicitly says not to share managed identities or service principals between dev/test and production.
  • Prevent self-escalation: the CAF warns that automation for workload teams should use role assignments that stop application owners from raising their own permissions through the pipeline (for example, the pipeline identity does not include Microsoft.Authorization/*/write, or it uses only a conditional RBAC Administrator).

How: ALZ deployment identity design (the same split as the accelerator)

IdentityTypeRole (scope)Federated credential subject (GitHub example)
id-alz-platform-planUAMI (rg-alz-mgmt-cc or an identity resource group)Reader @ alz; Storage Blob Data Contributor @ state containerrepo:contoso/alz-platform:pull_request, …:environment:alz-plan
id-alz-platform-applyUAMIOwner @ alz; Storage Blob Data Contributor @ state containerrepo:contoso/alz-platform:environment:alz-apply (the environment requires reviewers)
id-lz-myapp-prod-deployUAMI (in sub-lz-corp-myapp)Application-Owners @ sub-lz-corp-myapp (or Contributor @ rg-lz-myapp-cc)repo:contoso/myapp:environment:prod
id-lz-myapp-dev-deployUAMI (dev subscription)Same as above, dev subscription onlyrepo:contoso/myapp:environment:dev

The ALZ IaC accelerator (Terraform) bootstrap creates exactly these two UAMIs. The plan identity gets Reader at the intermediate root and Storage Blob Data Contributor on the state container. The apply identity gets Owner at the intermediate root and the same permission on the state container. (The Bicep version's What-If identity gets Reader, plus a custom role that contains only deployments/whatIf/action and deployments/validate/action.) The deployment identity for an application landing zone is usually created by the subscription vending module when the subscription is created.

Hard rules for federated credentials (official notes)

RuleImpact
Each application or UAMI supports up to 20 FICsDo not create one FIC per branch or per PR. Use the environment as the subject.
The issuer + subject combination must be unique on the same identity. No property supports wildcards.The subject must match the sub in the token exactly. If it is wrong, creation does not fail; the exchange fails later.
The audience can have only one value. api://AzureADTokenExchange is recommended.If you use a custom audience, both sides must match.
Propagation time after creating or changingUsing it right away can fail with AADSTS70021: No matching federated identity record found for presented assertion. Wait, and add retries.
Creating several FICs concurrently on the same UAMI returns 409 ConflictIn IaC, create them sequentially (ARM mode: serial / dependsOn; azurerm ≥ 3.40.0 already does this)
UAMIs in some regions (the docs list Malaysia South) do not support FICs yetThis course uses canadacentral, which is not affected.
You can use Azure Policy to deny creating Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentialsThe platform team can use this to allow only the vending process to create federated credentials.

Flexible federated identity credentials (preview): on an app registration, claimsMatchingExpression (mutually exclusive with subject) allows restricted expression matching, for example matching all branches of a repository. For GitHub, the guidance requires matching both sub and the immutable repository_id / repository_owner_id. Not supported for managed identities yet. Do not use this preview feature for the platform apply identity.

When: UAMI or app registration?

User-assigned managed identity (UAMI)App registration + service principal
CreatorAnyone with write permission on the resource group (an ARM resource). The platform pipeline or the vending process can create it.Needs permission to create apps in Entra (can be turned off by “Users can register applications”)
LifecycleFollows the resource group; deleting the resource group deletes the identityIndependent of Azure subscriptions
Federated credentialsSupported (flexible FIC preview not supported)Supported (including the flexible FIC preview)
Best forALZ platform / landing zone deployment identity (accelerator default)Scenarios that need Graph application permissions, cross-tenant access (multi-tenant apps), and similar cases
Common misconceptions ① “Using ref:refs/heads/main as the subject is secure enough.” Anyone who can push to main gets that identity. Bind apply to an environment that requires approval. ② “Use one identity for dev and prod, and separate them with RBAC.” The permissions of one identity are the union of all its roles, so the dev pipeline can change prod too. ③ “Once the federated credential is created, you can use it immediately.” There is a propagation delay. ④ “The platform apply identity can be shared with application teams to save setup work.” It has Owner at the intermediate root.

Diagram: token exchange and ALZ identity layout

GitHub Actions runenvironment: alz-applypermissions:id-token: write ① OIDC JWTiss: token.actions.githubusercontent.comsub: repo:contoso/alz-platform:environment:alz-applyaud: api://AzureADTokenExchange ② Entra token endpointclient_id = id-alz-platform-applyclient_assertion = JWTMatch FIC: exact iss + sub ③ ARM access tokenaud: management.azure.com→ RBAC: Owner @ alzNot affected by enforced MFA ALZ identity layout Platform repo alz-platformPR → id-alz-platform-plan (Reader @ alz)environment alz-apply (approval)→ id-alz-platform-apply (Owner @ alz)Both: Storage Blob Data Contributor on the state container Application repo myappenvironment dev → id-lz-myapp-dev-deployenvironment prod (approval)→ id-lz-myapp-prod-deployApplication-Owners @ its own subscription Do not do thisOne identity shared by dev and prodApply bound to ref:refs/heads/main with no approvalApplication pipeline reusing the platform apply identityUser account + password running the pipeline
Figure 6-1 Entra only checks whether the issuer, subject, and audience exactly match the federated credential. The security boundary is formed jointly by the subject and the CI platform's environment protection.

Core animation: OIDC token exchange (including the failure path)

Choose the trigger, the federated credential subject configured on the identity, and how long ago the FIC was created. Then step through the token contents and Entra's matching process.

Ready.
$ azure/login@v2 (client-id: id-alz-platform-apply)

Core commands: create deployment identities, federated credentials, and roles

CommandPurpose
az identity create -g RG -n NAME -l canadacentralCreate a UAMI (outputs clientId and principalId)
az identity federated-credential create --identity-name NAME -g RG -n FIC --issuer … --subject … --audiences api://AzureADTokenExchangeAdd a federated credential
az identity federated-credential list --identity-name NAME -g RG -o tableList (no more than 20)
az ad app federated-credential create --id APPID --parameters @fic.jsonFederated credentials on the app registration
az role assignment create --assignee-object-id PRINCIPALID --assignee-principal-type ServicePrincipal …Grant roles to the identity (avoids replication lag)
RG=rg-alz-mgmt-cc; ORG=contoso; REPO=alz-platform
ALZ_MG=/providers/Microsoft.Management/managementGroups/alz
for role in plan apply; do
  az identity create -g $RG -n id-alz-platform-$role -l canadacentral \
    --tags env=prod owner=platform costCenter=cc-0001 workload=alz-iac -o none
done
# Federated credentials: create them one at a time (concurrent creation on the same UAMI returns 409)
az identity federated-credential create -g $RG --identity-name id-alz-platform-plan -n gh-pr \
  --issuer https://token.actions.githubusercontent.com --subject "repo:$ORG/$REPO:pull_request" \
  --audiences api://AzureADTokenExchange
az identity federated-credential create -g $RG --identity-name id-alz-platform-apply -n gh-env-alz-apply \
  --issuer https://token.actions.githubusercontent.com --subject "repo:$ORG/$REPO:environment:alz-apply" \
  --audiences api://AzureADTokenExchange
# Roles: plan = Reader, apply = Owner (intermediate root)
pid() { az identity show -g $RG -n $1 --query principalId -o tsv; }
az role assignment create --assignee-object-id $(pid id-alz-platform-plan)  --assignee-principal-type ServicePrincipal --role Reader --scope $ALZ_MG
az role assignment create --assignee-object-id $(pid id-alz-platform-apply) --assignee-principal-type ServicePrincipal --role Owner  --scope $ALZ_MG
az identity federated-credential list -g $RG --identity-name id-alz-platform-apply --query "[].{name:name, subject:subject}" -o table
Name              Subject
----------------  ------------------------------------------------
gh-env-alz-apply  repo:contoso/alz-platform:environment:alz-apply

For the Storage Blob Data Contributor assignment on the state store, see the remote state section of the Terraform course. For permissions: id-token: write in the workflow file, the azure/login parameters, and creating the Azure DevOps service connection, see GitHub hour 3 / ADO hour 3. How to verify: run plan on a PR and confirm it succeeds; try a write operation and confirm it returns AuthorizationFailed; run apply in the alz-apply environment and confirm it succeeds. Common error: the case of the organization or repository name, or the environment name, in the subject does not match the actual value.

Lab 6: Set up deployment identities for the platform and myapp (about 8 minutes)

Run the script on the “Commands” tab to create id-alz-platform-plan / -apply. With a single subscription, place them in rg-alz-mgmt-cc as well.
Create a deployment identity for the myapp production environment (in the application landing zone subscription)
az identity create -g rg-lz-myapp-cc -n id-lz-myapp-prod-deploy -l canadacentral \
  --tags env=prod owner=app-team costCenter=cc-1001 workload=myapp -o none
az identity federated-credential create -g rg-lz-myapp-cc --identity-name id-lz-myapp-prod-deploy -n gh-env-prod \
  --issuer https://token.actions.githubusercontent.com --subject "repo:contoso/myapp:environment:prod" \
  --audiences api://AzureADTokenExchange
az role assignment create --assignee-object-id $(az identity show -g rg-lz-myapp-cc -n id-lz-myapp-prod-deploy --query principalId -o tsv) \
  --assignee-principal-type ServicePrincipal --role $APPOWN --scope /subscriptions/$LZ_SUB

$APPOWN comes from Module 2 (the role ID of Application-Owners). With a single subscription, narrow the scope to rg-lz-myapp-cc.

Verify isolation: list the role assignments of both identities. Confirm that the myapp identity has no roles on alz or platform, and that the platform plan identity has no write roles.
for n in id-alz-platform-plan id-alz-platform-apply; do
  az role assignment list --assignee $(az identity show -g rg-alz-mgmt-cc -n $n --query principalId -o tsv) --all \
    --query "[].{id:'$n', role:roleDefinitionName, scope:scope}" -o table; done
(Optional) Run it in GitHub: in the myapp repository, create the environment prod and set required reviewers. Following the GitHub hour 3 workflow, replace client-id with the clientId of id-lz-myapp-prod-deploy. Then deliberately sign in from a job that has no environment and observe AADSTS700213.

Case 1: any branch can deploy to production

Problem: the FIC subject of the production identity is repo:contoso/myapp:ref:refs/heads/main, and main has no branch protection. A developer pushed experimental code directly and deployed it to production. Fix: change the subject to environment:prod, set required reviewers and a deployment branch restriction on the environment, and turn on branch protection for main.

Case 2: the platform apply identity reused by an application pipeline

Problem: to “maintain one fewer identity,” the application team's pipeline also used id-alz-platform-apply. One mistaken operation deleted a policy assignment on corp. Fix: the application landing zone gets its own identity from the vending process. The FIC on the platform apply identity allows only the alz-apply environment of the platform repository. Use Azure Policy to deny creating FICs outside the platform identity resource group.

Case 3: intermittent AADSTS70021 in a pipeline

Problem: the vending process created the FIC and then immediately triggered the first deployment. “No matching federated identity record found” appeared now and then. Fix: wait for propagation, as the official guidance recommends, and add retries to the token request. In IaC, create the FICs on the same UAMI sequentially to avoid 409.

Common errors and fixes

AADSTS700213: No matching federated identity record found for presented assertion subject '…'

Cause: the sub in the token does not exactly match the subject of any FIC (environment name, branch, PR, repository rename, or casing).

az identity federated-credential list -g <rg> --identity-name <id> --query "[].subject" -o tsv
# Print the actual sub inside the workflow (prints the claim only, never the token itself)
curl -sH "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | jq -r .value | cut -d. -f2 | base64 -d 2>/dev/null | jq .sub

Fix: make the FIC subject match the actual sub exactly. Use an environment for apply-type tasks.

AADSTS70021: No matching federated identity record found for presented assertion.

Cause: a newly created or changed FIC has not propagated yet, or the issuer was typed wrong.

Fix: wait a few minutes and retry. Check the issuer (for GitHub it is https://token.actions.githubusercontent.com; watch for a trailing slash).

AADSTS700212: No matching federated identity record found for presented assertion audience

Cause: the aud in the token does not match the audience of the FIC.

Fix: use api://AzureADTokenExchange on both sides.

Conflict (409) when creating federated credentials / more than 20 federated credentials

Cause: concurrent creation on the same UAMI, or the count has reached the limit.

Fix: create them sequentially. Merge subjects using environments, or split them across several identities (one identity per environment is already the recommended practice).

Sign-in succeeds but AuthorizationFailed

Cause: the identity has no role at the target scope, or the role was just assigned and has not taken effect yet.

Fix: check the assignments as in Module 2. When assigning to a new identity, use --assignee-principal-type ServicePrincipal.

Command-line exercise
1. For the UAMI id-lz-myapp-dev-deploy, add a federated credential for the GitHub environment dev.
az identity federated-credential create -g rg-lz-myapp-cc --identity-name id-lz-myapp-dev-deploy -n gh-env-dev --issuer https://token.actions.githubusercontent.com --subject "repo:contoso/myapp:environment:dev" --audiences api://AzureADTokenExchange
2. List all federated credential subjects of id-alz-platform-apply.
az identity federated-credential list -g rg-alz-mgmt-cc --identity-name id-alz-platform-apply --query "[].subject" -o tsv
Scenario analysis question
The platform team wants “one identity for everything”: one app registration, the secret stored in GitHub Secrets, Owner @ alz, shared by all platform and application repositories. Propose an alternative design.

Split it into a platform plan identity (Reader @ alz + state container) and a platform apply identity (Owner @ alz + state container), two UAMIs that use federated credentials. Bind plan to PRs, and bind apply to the approved alz-apply environment. Create one UAMI per application landing zone and per environment through the vending process. Each one holds only Application-Owners on its own subscription (or narrower roles) and cannot grant access. Delete the secret from the old app registration. Use Azure Policy to restrict where FICs can be created, and use access reviews to check high-privilege identities regularly. Workload identities do not go through PIM, so control them with least privilege, environment approval, and auditing.

Verified teaching videos

▶
Why use workload identity federation? — Microsoft Developer
English · Why use federated credentials instead of secrets
▶
GitHub Azure AD OIDC Authentication — John Savill's Technical Training
English · GitHub OIDC tokens and subject matching
▶
Azure DevOps Workload Identity Federation with Azure Overview. NO MORE SECRETS! — John Savill's Technical Training
English · Federated identity for Azure Pipelines service connections

Official docs and further reading

Video storyboard (about 90 seconds)

Shot 1 · 0–20s
Visual: a GitHub runner holds up a JWT with iss, sub, and aud on it.
Narration: on every run, the CI platform issues an ID card that belongs only to that run.
Shot 2 · 20–45s
Visual: Entra checks the JWT against the federated credential, character by character. When the subject matches, a green light turns on.
Narration: Entra does one thing: it checks whether the issuer, subject, and audience exactly match the federated credential.
Shot 3 · 45–70s
Visual: the plan identity gets only a magnifying glass (Reader). The apply identity gets the key (Owner) behind an approval gate.
Narration: ALZ separates plan from apply. A PR can only look. Only an approved environment can make changes.
Shot 4 · 70–90s
Visual: separate dev and prod identities, each connected only to its own subscription.
Narration: one identity per landing zone and per environment. Never share them.
Or score ≥ 70% on the quiz

Module 7 · Managed identities and Azure Lighthouse

42:00 – 50:00 · Accessing Azure from a workload needs no password: the platform manages the credentials of managed identities. Cross-tenant operations need no guest accounts: Lighthouse projects the other party's subscriptions into your tenant
8 minIMDS 169.254.169.254Lighthouse: built-in roles only, Owner not supported★★★★☆
Learning objectives
  • Tell system-assigned and user-assigned managed identities apart. Know the three typical uses in ALZ: a workload (myapp reading Key Vault), DINE / Modify policy remediation, and deployment identities (Module 6).
  • Describe how a workload gets a token from IMDS inside a VM or container, and why granting a managed identity permissions through a group can take hours to take effect.
  • Explain the authorization model and limits of Azure Lighthouse: only built-in roles are supported; Owner and roles with DataActions are not; User Access Administrator is used only to assign roles to managed identities; and eligible authorizations require the Entra ID Governance license in the managing tenant.
Prerequisites: Modules 2 and 6. Importance: ★★★★☆

What: two kinds of managed identity

System-assignedUser-assigned (UAMI)
LifecycleTied to a resource: deleting the resource deletes the identityA standalone Azure resource (Microsoft.ManagedIdentity/userAssignedIdentities)
CountOne per resourceOne UAMI can attach to several resources; one resource can have several UAMIs
Pre-authorizationThe principal exists only after the resource is created, so authorization has to come afterwardYou can create the identity and authorize it first, then deploy resources (suits IaC and vending)
Federated credentialsNot supportedSupported (Module 6)
Typical ALZ useManaged identities for policy assignments (DINE / Modify)Deployment identities, workload identities, and scenarios that need pre-authorization

How: how a workload gets a token

  1. Code (or az login --identity, or ManagedIdentityCredential in the Azure Identity library) sends a request to the IMDS endpoint on the local machine, http://169.254.169.254/metadata/identity/oauth2/token. The request carries the header Metadata: true, a resource (such as https://vault.azure.net), and the UAMI's client_id (required when there is more than one identity). App Service, Container Apps, and Functions use a local endpoint provided by the platform (IDENTITY_ENDPOINT).
  2. Azure, on the resource's behalf, gets a token from Entra. The platform manages and rotates the credentials, and you cannot see them.
  3. The code uses the token to access Key Vault, Storage, or ARM. The target service decides using RBAC (data-plane roles).

Watch out for caching: the managed identity back end caches tokens per resource URI for about 24 hours. So after you add a managed identity to a group, or change the roles of that group, it can take hours to take effect. Official guidance is to assign roles to the managed identity directly.

The three kinds of managed identity in ALZ

PurposeExampleKey point
Workloadmyapp (on Container Apps or a VM) uses id-myapp-cc to read the Redis connection string in kv-myapp-cc-<suffix>Key Vault Secrets User @ a single vault. The platform team pre-creates the UAMI during vending (CAF: landing zone delivery should include the managed identities it needs)
Policy remediationThe hour 2 DINE policies (diagnostic settings, private DNS records)Remediation needs a managed identity to make the changes. When you assign the policy in the portal, the system-assigned identity is authorized automatically. With IaC, you create the role assignments yourself. Only built-in roles can be used. Roles are assigned directly to the identity, not through a group.
Deploymentid-alz-platform-apply, id-lz-myapp-prod-deployUAMI + federated credentials (Module 6)

What: Azure Lighthouse

Lighthouse lets users, groups, or service principals in the managing tenant work directly on subscriptions or resource groups in the customer (managed) tenant, without creating guest accounts in the customer tenant. Two kinds of resource are created in the customer tenant: Microsoft.ManagedServices/registrationDefinitions (what is authorized: who, and which built-in role) and registrationAssignments (where it applies: which subscription or resource group). In the portal under “My customers,” the managing side sees the projected resources, and ARM requests are checked in the customer tenant against these authorizations.

Rules (official)Description
Supports only Azure built-in rolesCustom roles and the classic administrator roles are not supported
Owner is not supportedRoles that include DataActions are not supported either, nor are roles with operations such as Microsoft.Authorization/*, roleAssignments/write, or locks/write
User Access Administrator is only for assigning roles to managed identities in the customer tenantYou must also declare which roles can be assigned (delegatedRoleDefinitionIds), which is used to deploy DINE remediation in the customer tenant
Authorized principals can be security groups or service principalsThe group type must be “Security.” Adding or removing members does not require updating the delegation.
Include the Managed Services Registration Assignment Delete RoleOtherwise only users in the customer tenant can revoke the delegation
Eligible authorizations (just-in-time) require the managing tenant to have the Entra ID Governance license, which supports PIMActivation duration from 30 minutes to 8 hours; up to 10 approvers; service principals are not supported; the same principal also needs a standing Reader-type authorization to be elevated in the portal
Watch out for “indirect data access”Roles without DataActions can still reach data through operations such as listKeys (for example, Virtual Machine Contributor)

When: when to use Lighthouse in ALZ

  • Several tenants kept after an acquisition: the parent company's platform or security team gets read-only and limited operational access on the ALZ in each tenant. (The CAF multi-tenant guidance recommends Lighthouse to simplify cross-tenant management.)
  • A managed service provider (MSP) that manages its customers' landing zones.
  • Centralized security operations: view Defender for Cloud and Sentinel across tenants (these also need their own product configuration).
  • Not a good fit: scenarios that need Owner or authorization management, and scenarios that need data-plane roles. Handle these inside the customer tenant (for example, the customer tenant's own PIM groups).
Common misconceptions ① “System-assigned identities are more secure, so use them everywhere.” System-assigned identities cannot be pre-authorized, cannot use federated credentials, and cannot be shared across resources. Choose by scenario. ② “Adding managed identities to a group is the easiest way to grant access.” Token caching means changes can take hours to apply. ③ “Lighthouse can give an MSP Owner.” Owner is not supported. When authorization management is needed, the only option is the restricted User Access Administrator (for managed identities only). ④ “Lighthouse authorizations can be narrowed with a custom role.” Only built-in roles can be used.

Diagram: getting a token with a managed identity, and the Lighthouse projection

myapp container / VMUAMI id-myapp-ccManagedIdentityCredential IMDS / local endpoint169.254.169.254Metadata: true Microsoft EntraPlatform-managed credentialToken cache about 24 hours kv-myapp-cc-<suffix>RBAC: Key Vault Secrets User→ returns redis-connection Managing tenant (the parent company's platform team)grp-lh-fabrikam-readers → Readergrp-lh-fabrikam-ops → Contributor (eligible, approval required)grp-lh-fabrikam-policy → UAA (only for assigning roles to managed identities, such asLog Analytics Contributor, etc.)+ Registration Assignment Delete Role Customer tenant (Fabrikam's ALZ)registrationDefinition: authorization listregistrationAssignment: sub-fab-corp-app1The request is checked in the customer tenant's ARMThe activity log records the managing callerThe customer can remove the delegation at any time Projection
Figure 7-1 Top: the managed identity has no credentials you can see. Bottom: Lighthouse creates no guest accounts; the authorizations exist as resources in the customer tenant.

Two-scenario animation: IMDS token / Lighthouse request check

Switch scenarios, then play step by step. In the Lighthouse scenario you can choose the requested role and see which authorizations get denied when the delegation is deployed.

Choose a scenario.

Core commands: managed identities and Lighthouse

CommandPurpose
az identity create -g rg-lz-myapp-cc -n id-myapp-ccCreate a workload UAMI
az vm identity assign -g … -n … --identities <uami-id> / az containerapp identity assign …Attach the UAMI to a resource
az login --identity --client-id <clientId>Sign in to the CLI inside the resource with its managed identity (newer CLI versions also accept the older --username syntax; check az login -h for the current form)
curl -H Metadata:true "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=…&client_id=…"Call IMDS directly
az deployment sub create -l canadacentral -f subscription.json -p @subscription.parameters.jsonDeploy a Lighthouse delegation in the customer tenant
az managedservices assignment list / az managedservices definition listView delegations (customer tenant side)
az identity create -g rg-lz-myapp-cc -n id-myapp-cc -l canadacentral \
  --tags env=prod owner=app-team costCenter=cc-1001 workload=myapp -o none
KV=kv-myapp-cc-$RANDOM
az keyvault create -g rg-lz-myapp-cc -n $KV -l canadacentral --enable-rbac-authorization true \
  --tags env=prod owner=app-team costCenter=cc-1001 workload=myapp -o none
az role assignment create --assignee-object-id $(az identity show -g rg-lz-myapp-cc -n id-myapp-cc --query principalId -o tsv) \
  --assignee-principal-type ServicePrincipal --role "Key Vault Secrets User" \
  --scope $(az keyvault show -n $KV --query id -o tsv)
# Inside the VM / container that has this UAMI attached:
CID=$(az identity show -g rg-lz-myapp-cc -n id-myapp-cc --query clientId -o tsv)   # look this up on the local machine, then pass it in
curl -s -H Metadata:true "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://vault.azure.net&client_id=$CID" | jq -r '.expires_on, .resource'
1795003200
https://vault.azure.net

Key Vault names must be globally unique (3–24 characters), so add a random suffix. The hour 2 policies may require the Key Vault to disable public network access or enable purge protection, so add parameters to match your policies. How to verify: inside the VM with the UAMI attached, run az login --identity --client-id $CID; then az keyvault secret show should succeed. Against a vault you are not authorized for, you should get 403.

Lighthouse parameter file (excerpt)

{
  "mspOfferName": { "value": "Contoso Platform Ops for Fabrikam" },
  "managedByTenantId": { "value": "<contoso-tenant-id>" },
  "authorizations": { "value": [
    { "principalId": "<grp-lh-fabrikam-readers>", "principalIdDisplayName": "Platform readers",
      "roleDefinitionId": "acdd72a7-3385-48ef-bd42-f606fba81ae7" },
    { "principalId": "<grp-lh-fabrikam-readers>", "principalIdDisplayName": "Remove delegation",
      "roleDefinitionId": "91c1777a-f3dc-4fae-b103-61d183457e46" }
  ]},
  "eligibleAuthorizations": { "value": [
    { "principalId": "<grp-lh-fabrikam-ops>", "principalIdDisplayName": "Ops JIT",
      "roleDefinitionId": "b24988ac-6180-42a0-ab88-20f7382dd24c",
      "justInTimeAccessPolicy": { "multiFactorAuthProvider": "Azure", "maximumActivationDuration": "PT4H",
        "managedByTenantApprovers": [ { "principalId": "<grp-lh-approvers>", "principalIdDisplayName": "Approvers" } ] } }
  ]}
}

acdd72a7… is Reader, b24988ac… is Contributor, and 91c1777a… is Managed Services Registration Assignment Delete Role (verify with az role definition list --name "…"). The template comes from the eligible authorizations folder of the official Azure-Lighthouse-samples.

Lab 7: myapp reads a secret with a managed identity + Lighthouse template walkthrough (about 8 minutes)

Run the managed identity part of the “Commands” tab, and write a secret (as yourself; requires Key Vault Secrets Officer):
az role assignment create --assignee $(az ad signed-in-user show --query id -o tsv) --role "Key Vault Secrets Officer" --scope $(az keyvault show -n $KV --query id -o tsv)
az keyvault secret set --vault-name $KV -n redis-connection --value "redis://redis-myapp:6379" -o none
(Optional, incurs cost) Verify IMDS on a test VM: create a Standard_B1s VM with no public IP and attach the UAMI. Then run the IMDS request through az vm run-command invoke. No SSH is needed:
az vm create -g rg-lz-myapp-cc -n vm-mitest-cc --image Ubuntu2404 --size Standard_B1s --public-ip-address "" \
  --assign-identity $(az identity show -g rg-lz-myapp-cc -n id-myapp-cc --query id -o tsv) --generate-ssh-keys \
  --tags env=prod owner=app-team costCenter=cc-1001 workload=myapp -o none
az vm run-command invoke -g rg-lz-myapp-cc -n vm-mitest-cc --command-id RunShellScript \
  --scripts "curl -s -H Metadata:true 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://vault.azure.net&client_id=$CID' | cut -c1-60"

B1s is billed hourly (plus the disk). Right after the lab, run az vm delete -g rg-lz-myapp-cc -n vm-mitest-cc --yes and delete the disk and NIC. The hour 4 networking course also uses test VMs with no public IP.

Lighthouse walkthrough (read-only): download the official eligible authorizations template and fill in its parameters following the “Commands” tab. If you have only one tenant, do not deploy it, since delegating your own tenant to yourself serves no purpose. Use az deployment sub validate to check the template, and try changing Reader to Owner to see the validation error.
az deployment sub validate -l canadacentral -f subscription-managing-tenant-approvers.json -p @lh.parameters.json
Cleanup: delete the test VM. Keep the Key Vault until the capstone lab (soft delete keeps it for a while, and the name cannot be reused right away).

Case 1: a managed identity authorized through a group “took a day to take effect”

Problem: the platform team added 20 managed identities to one group, then gave the group Key Vault Secrets User. After deployment, the app got 403 for several hours. Cause: the managed identity back end caches tokens for about 24 hours. Fix: assign roles directly to the managed identities. If the number of assignments is a concern, consolidate identities per vault (one UAMI shared by one application).

Case 2: DINE policy remediation failed

Problem: the DINE policy that deploys diagnostic settings was assigned with IaC, and the remediation task kept failing. Cause: IaC created only the system-assigned identity of the policy assignment, not the built-in role assignments it needs (the portal does this automatically; IaC does not). Fix: create the role assignments from the roleDefinitionIds in the policy definition, with a scope that covers the remediation targets (hour 2). The ALZ Terraform and Bicep modules already handle this.

Case 3: the MSP asks for Owner

Problem: the managed service provider wants Owner on the customer's subscription so it can “deploy policies.” Fix: Lighthouse does not support Owner. Instead, use Contributor as an eligible authorization (JIT + approval), a restricted User Access Administrator (can assign only specified roles to managed identities, for DINE remediation), and the Registration Assignment Delete Role. Changes that need higher privileges are made by the customer's own platform team.

Common errors and fixes

ManagedIdentityCredential authentication unavailable / Identity not found (IMDS returns 400)

Cause: the resource does not have the managed identity attached; there is more than one UAMI and no client_id is specified; or the container cannot reach IMDS.

az vm identity show -g rg-lz-myapp-cc -n vm-mitest-cc -o json
az containerapp identity show -g rg-lz-myapp-cc -n <app> -o json

Fix: attach the UAMI and specify the client ID in the code or the CLI.

(Forbidden) Caller is not authorized to perform action on resource … Action: 'Microsoft.KeyVault/vaults/secrets/getSecret/action'

Cause: the managed identity has no data-plane role, the vault uses the access policy model instead of RBAC, or the permission was just granted through a group.

Fix: confirm enableRbacAuthorization=true, then assign Key Vault Secrets User directly at the vault scope.

Lighthouse deployment failed: The role definition … is not supported / Owner is not supported

Cause: the authorization uses Owner, a custom role, a role with DataActions, or a role with Microsoft.Authorization write operations.

Fix: switch to a supported built-in role. When you need to authorize managed identities, use User Access Administrator + delegatedRoleDefinitionIds.

Managing-side users cannot see the delegation under “My customers,” or cannot activate an eligible role

Cause: the standing Reader-type authorization is missing; the managing tenant lacks the ID Governance license for eligible authorizations; or the group type is not “Security.”

Fix: add a Reader authorization for the same principal; confirm the license; rebuild the group as a security group and update the delegation.

Command-line exercise
1. On the VM with the UAMI attached (client ID $CID), sign in with the managed identity from the CLI and read the secret redis-connection.
az login --identity --client-id $CID
az keyvault secret show --vault-name $KV -n redis-connection --query value -o tsv
2. List all Lighthouse delegations in the customer tenant.
az managedservices assignment list --include-definition true -o table
Scenario analysis question
The parent company wants to monitor the ALZ in three subsidiary tenants (each a separate tenant). Requirements: the parent's SOC has read-only access, the platform team occasionally needs to change diagnostic settings, and each subsidiary can revoke access at any time. How would you design this?

Deploy Lighthouse delegations at subscription level in each subsidiary's tenant, covering the platform subscription and the landing zone subscriptions. The SOC security group gets Reader and Security Reader. The platform team group gets an eligible authorization for Monitoring Contributor (JIT, 4 hours, with approvers from the parent company; the parent company's tenant needs the ID Governance license), plus standing Reader. If DINE remediation must run in the subsidiary's tenant, add User Access Administrator and use delegatedRoleDefinitionIds to limit it to assigning monitoring-related built-in roles to managed identities. Add the Registration Assignment Delete Role. A subsidiary can remove the delegation at any time under “Service providers,” and all actions are recorded in the subsidiary's activity log. Note that Lighthouse does not support Owner or custom roles.

Verified teaching videos

▶
Microsoft Azure Managed Identity Deep Dive — John Savill's Technical Training
English · System-assigned vs. user-assigned, IMDS, token caching
▶
Azure Lighthouse: A unified control plane for managing Azure at scale — Microsoft Azure (Azure Friday)
English · The Lighthouse delegation model and the cross-tenant view

Official docs and further reading

Video storyboard (about 90 seconds)

Shot 1 · 0–25s
Visual: a container raises its hand to 169.254.169.254 and gets back a token, which opens the Key Vault door.
Narration: the platform manages the managed identity's credentials. The workload only asks the local endpoint for a token.
Shot 2 · 25–45s
Visual: a managed identity is dragged into a group, and the clock runs for 24 hours before a green light comes on.
Narration: tokens are cached. To grant access to a managed identity, assign the role directly.
Shot 3 · 45–75s
Visual: two tenants. An “authorization list” appears in the customer tenant, and a managing-side user works on the customer's subscription through it.
Narration: Lighthouse stores the authorizations as resources in the customer tenant. The managing side needs no guest accounts.
Shot 4 · 75–90s
Visual: the Owner card is crossed out. The built-in role cards pass.
Narration: only built-in roles are supported, not Owner. For temporary elevation, use an eligible authorization.
Or score ≥ 70% on the quiz

Module 8 · Identity review and troubleshooting

50:00 – 60:00 · An identity baseline is not a one-time job. Use Resource Graph to take inventory, access reviews to clean up, and log alerts to catch drift. When authorization fails, use a troubleshooting tree to find out within two minutes whether the cause is RBAC, Policy, MFA, or the token
10 minauthorizationresourcesAccess reviews: P2 / ID Governance★★★★☆
Learning objectives
  • Use the authorizationresources table in Azure Resource Graph to inventory high-privilege assignments, assignments made directly to users, guest assignments, orphaned assignments that show “Identity not found,” and elevated access at the root scope.
  • Set up continuous governance: access reviews for PIM and groups, alerts on role assignment changes, break-glass account drills, and license monitoring.
  • Use the troubleshooting tree to tell apart AuthorizationFailed (RBAC), RequestDisallowedByPolicy (Policy or enforced MFA), AADSTS… (Entra token), and cache delay.
Prerequisites: Modules 1–7. Importance: ★★★★☆

What: eight questions an identity review should answer

#QuestionData sourceTarget
1Who has Owner, User Access Administrator, or RBAC Administrator on alz / platform / subscriptions?Resource GraphOnly PIM eligibility or the platform apply identity
2Are any roles assigned directly to individual users?Resource Graph (principalType = User)Change them all to groups
3What roles do guests have on Azure?Graph (userType = Guest) + Resource GraphHas an owner and an expiry date
4Is there still elevated access at the root scope /?az role assignment list --scope /, the banner on the Entra properties pageEmpty
5Are there assignments that point to deleted principals?The portal shows Identity not found / principalName is empty in the CLIDelete
6Are all federated credentials on the deployment identities bound to protected environments?az identity federated-credential listapply / prod: environment-bound only
7Are the most recent break-glass account drill and sign-in alerts normal?SigninLogs, drill records≤ 90 days
8Are the PIM / ID Governance licenses valid, and is the count sufficient?Entra licenses page, subscribedSkusAlert 30 days before expiry

How: the mechanisms of continuous governance

  • Access reviews: run periodic reviews of PIM roles, PIM for Groups, and privileged groups (as the CAF recommends). Entra ID P2 provides access reviews that have been generally available for some time. Newer capabilities, such as reviews for PIM for Groups, machine-learning recommendations, and inactive-user scoping, require ID Governance.
  • Alerts: the Azure Activity Log for Microsoft.Authorization/roleAssignments/write (at management group and subscription level), and, in the Entra audit log, PIM activations and “Azure RBAC (Elevated Access)” events. Microsoft Sentinel has an “Azure RBAC (Elevate Access)” analytics rule template.
  • Identity as code: keep role assignments, custom roles, PIM eligibility, and federated credentials in the platform IaC wherever possible, and review changes through PRs. Find manual changes with a Resource Graph drift report.
  • Capacity: 5000 role assignments per subscription, 500 per management group, 5000 custom roles per tenant, and 20 federated credentials per identity. Show the utilization of each in the report.

Four root causes of authorization failure

SymptomSourceTypical causesGo back to
AuthorizationFailed (403)ARM RBACNo assignment, wrong scope, NotActions, condition not met, PIM not activatedModules 2, 3, 4
RequestDisallowedByPolicyAzure Policy or enforced MFADeny policy; “Users must use MFA for Create/Update operations”Hour 2, Module 5
AADSTS…Entra token issuanceCA block (53003), MFA required (50076), federated credential mismatch (700213 / 700212 / 70021)Modules 5, 6
401 / a newly added permission does not take effectCacheARM cache about 10 minutes; managed identities granted through a group can take hoursModules 2, 7
Common misconceptions ① “When you see RequestDisallowedByPolicy, go check RBAC.” That is a denial from Policy or enforced MFA; RBAC has already passed. ② “Resource Graph shows every authorization.” A standard query does not show PIM eligible assignments (use the PIM API or PowerShell), and it returns only the assignments you have permission to read. ③ “Access reviews are just a formality.” Combined with the setting “remove if reviewers do not respond,” they are the main way to clean up permissions.

Review loop

InventoryResource GraphPIM API Find risksStanding Owner / direct user assignmentOrphaned assignment / root elevation Fix (IaC)Change assignments through a PRSwitch to PIM / groups ReviewAccess reviewBreak-glass account drill MonitorActivity logAudit log Repeat every quarter / after each major change
Figure 8-1 The identity baseline is maintained by a loop: inventory → risks → IaC fix → review → monitor

Interactive: identity review scorecard

Check off the items for your environment (or this course's sandbox). The scorecard calculates a score weighted by risk and lists the priority fixes. Results are saved in this browser.

Check off what you have already done.
Priority fixes: …

Core commands: inventory and audit

CommandPurpose
az graph query -q "authorizationresources | …" --management-groups alzList role assignments under alz (including at management group level)
az role assignment list --scope / -o tableAssignments at the root scope (elevated access)
az role assignment list --all --query "[?principalName=='']"Suspected orphaned assignments
az monitor activity-log list --offset 7d --query "[?authorization.action=='Microsoft.Authorization/roleAssignments/write']"Role assignment changes in the last 7 days (subscription level)
az rest --url "https://graph.microsoft.com/v1.0/users?\$filter=userType eq 'Guest'"List guests
az graph query --management-groups alz --first 1000 -q "
authorizationresources
| where type =~ 'microsoft.authorization/roleassignments'
| extend rdId = tolower(tostring(properties.roleDefinitionId)), principalType = tostring(properties.principalType),
         principalId = tostring(properties.principalId), scope = tostring(properties.scope)
| join kind=leftouter (authorizationresources
    | where type =~ 'microsoft.authorization/roledefinitions'
    | project rdId = tolower(id), roleName = tostring(properties.roleName)) on rdId
| where roleName in ('Owner','User Access Administrator','Role Based Access Control Administrator') or principalType == 'User'
| project scope, roleName, principalType, principalId
| order by roleName asc" --query "data" -o table
Scope                                                  RoleName                   PrincipalType     PrincipalId
-----------------------------------------------------  -------------------------  ----------------  ------------
/providers/Microsoft.Management/managementGroups/alz   Owner                      ServicePrincipal  7c1e…   ← id-alz-platform-apply (expected)
/subscriptions/1111…                                   Owner                      User              4b2a…   ← standing personal Owner (risk)
/subscriptions/1111…                                   Role Based Access Control Administrator  Group  9d0f…  ← conditional? Needs checking
/                                                      User Access Administrator  User              0a9c…   ← elevated access not revoked

How to verify: resolve each principalId to a name with az ad sp show --id / az ad user show --id / az ad group show -g. For conditional assignments, check the properties.condition field. Common error: using az role assignment list without --all, which misses other subscriptions.

Lab 8: generate an identity review report and fix five kinds of risk (about 10 minutes)

Run the Resource Graph query on the “Commands” tab and export it to JSON: at the end of the command, change it to -o json > ra-report.json.
Add PIM eligibility (Resource Graph cannot see it):
az rest --url "/subscriptions/$LZ_SUB/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?api-version=2020-10-01" \
  --query "value[].{principal:properties.principalId, role:properties.expandedProperties.roleDefinition.displayName, end:properties.endDateTime}" -o table
Check federated credentials:
for id in $(az identity list --query "[].id" -o tsv); do
  az identity federated-credential list --ids $id 2>/dev/null --query "[].{subject:subject}" -o tsv | sed "s#^#$(basename $id): #"
done

If the subcommand does not accept --ids, use -g and --identity-name instead (parse them from the id). The subject of the apply / prod identities should not contain ref:refs/heads/.

Fix the risks this lab created: ① revoke the elevated access at the root scope; ② if roles are assigned directly to a user (for example, the standing Owner from before Lab 4), switch them to groups or PIM; ③ delete test roles such as “Bad Role”; ④ confirm that the assignment for grp-lz-myapp-prod-access-admins has a condition; ⑤ record the date of the last break-glass drill.
az role assignment delete --assignee $(az ad signed-in-user show --query id -o tsv) --role "User Access Administrator" --scope "/"
az role assignment list --scope "/" -o table     # should be empty
Set up alerts (subscription-level Activity Log alerts. Management group-level changes must be routed to law-alz-mgmt-cc through Entra / diagnostic settings first, then covered with log alerts):
az monitor activity-log alert create -g rg-alz-mgmt-cc -n ala-roleassignment-write \
  --scopes /subscriptions/$LZ_SUB --condition category=Administrative and operationName=Microsoft.Authorization/roleAssignments/write \
  --description "Role assignment created in landing zone" -o none

An alert sends notifications only when it is linked to an action group. See the management subscription resources in hour 1.

Go to the “Troubleshooting” tab and use the troubleshooting tree to walk through the errors you ran into in this lab.

Case 1: a departed employee's Owner role is still there

Problem: an employee left and their account was deleted, but the Owner assignment on a subscription still shows “Identity not found.” A service principal created from their personal account still has Contributor. Fix: delete orphaned assignments during the quarterly inventory. Add service principals to the owner field and to access reviews. After moving to groups + PIM, a departure only requires removing the person from the group.

Case 2: elevated access at the root scope was never revoked

Problem: two years ago an administrator raised their access to troubleshoot, and they still have User Access Administrator at the root scope. Fix: the banner on the Entra properties page and “Manage users with elevated access” can be used to remove them in bulk. The Sentinel “Azure RBAC (Elevate Access)” rule detects new elevation events. The CAF recommends keeping this switch set to “No” when it is not needed.

Case 3: “RequestDisallowedByPolicy” misdiagnosed as a permissions problem

Problem: to fix RequestDisallowedByPolicy, the operations team added Owner to an automation account, but the problem remained. Cause: the account is a user-type service account, and Azure enforced MFA blocked it (the error message says MFA is required). Fix: revoke the extra Owner and move to a managed identity.

Interactive troubleshooting tree: authorization / sign-in failures

Start from the symptom you see and narrow it down step by step. Each leaf gives a diagnostic command and a fix.

Quick reference: common errors

Get-AzRoleAssignment still shows a deleted assignment

Cause: PowerShell uses a cache when listing assignments, refreshed about every 10 minutes.

Fix: list by scope, then filter: Get-AzRoleAssignment -Scope /subscriptions/$subId | Where-Object ObjectId -eq $id.

Insufficient privileges to complete the operation (service principal running az role assignment create)

Cause: the CLI tries to look up the assignee in Entra, but the service principal has no directory read permission.

Fix: use --assignee-object-id + --assignee-principal-type to skip the directory lookup.

Command-line exercise
1. List all role assignments at the root scope /.
az role assignment list --scope "/" -o table
2. Use Resource Graph to count role assignments per subscription (check against the 5000 limit).
az graph query -q "authorizationresources | where type =~ 'microsoft.authorization/roleassignments' | where id startswith '/subscriptions' | extend sub = tostring(split(id,'/')[2]) | summarize n=count() by sub | order by n desc"
Scenario analysis question
myapp's pipeline suddenly reports RequestDisallowedByPolicy, and the team asks to “add Owner to the pipeline.” How do you investigate?

First read the error details. If they include a policy assignment ID and a definition name (such as one that denies public IPs), it is an Azure Policy from hour 2: change the template or request an exemption. Adding permissions does not help. If it says “MFA is required / Users must use MFA for Create/Update operations,” the pipeline is actually using a user account (someone may have switched the service connection to personal credentials). Migrate it to a UAMI with federated credentials, as in Module 5. Only AuthorizationFailed is an RBAC problem, and then you should add the narrowest role needed, not Owner.

Verified teaching videos

▶
Azure Master Class v3 - Part 2 - Identity — John Savill's Technical Training
English · Identity overview review: tenants, authentication, PIM, governance
▶
Workload Identity Protection with Azure AD Identity Protection — John Savill's Technical Training
English · Monitoring workload identity risk

Official docs and further reading

Video storyboard (about 90 seconds)

Shot 1 · 0–20s
Visual: the results of a Resource Graph query, with four rows boxed in red.
Narration: run an inventory every quarter. Look for standing Owner, personal assignments, orphaned assignments, and root-scope elevation.
Shot 2 · 20–45s
Visual: four error codes sorted into four buckets: RBAC, Policy/MFA, token, and cache.
Narration: when authorization fails, check the error code first. It tells you which layer the problem is in.
Shot 3 · 45–70s
Visual: an access review email, where the reviewer clicks “Remove.”
Narration: access reviews give permissions an expiry date, instead of letting them pile up forever.
Shot 4 · 70–90s
Visual: the loop arrow returns to inventory.
Narration: inventory, fix, review, monitor, and repeat. That is how the identity baseline avoids drifting.
Or score ≥ 70% on the quiz

Command cheat sheet

Entra ID · Azure RBAC · PIM · Conditional Access · workload identity federation · managed identities · Lighthouse — every code block can be copied with one click
After-class reference

Tenants and management groups

az account show --query "{sub:name, tenant:tenantId, home:homeTenantId}"
az account tenant list -o table
az account management-group show -n alz -e -r
az rest --method post --url "/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"
az role assignment delete --assignee <me> --role "User Access Administrator" --scope "/"

Role assignments

az role assignment create --assignee-object-id <oid> --assignee-principal-type Group \
  --role <role> --scope <scope>
az role assignment list --assignee <id> --all --include-inherited -o table
az role assignment list --scope <scope> --include-inherited -o table
az role assignment create … --condition "<abac>" --condition-version "2.0"
# Owner 8e3af657…  Contributor b24988ac…  Reader acdd72a7…
# UAA 18d7d88d…  RBAC Admin f58310d9…  AcrPull 7f951dda…

Custom roles

az provider operation show --namespace Microsoft.Compute \
  --query "resourceTypes[?name=='virtualMachines'].operations[].name"
az role definition create --role-definition @role.json
az role definition update --role-definition @role.json   # includes Id
az role definition list --custom-role-only true --query "[].{n:roleName, s:assignableScopes}"
# Limits: 5000 per tenant; AssignableScopes can contain only 1 MG, not "/", and no wildcards; DataActions cannot be assigned at MG scope

PIM (Azure resource roles)

S=/subscriptions/<sub>; API=api-version=2020-10-01
az rest -m put --url "$S/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/$(uuidgen)?$API" --body @eligible.json   # AdminAssign
az rest -m put --url "$S/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/$(uuidgen)?$API" --body @activate.json    # SelfActivate, PT2H
az rest --url "$S/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?$API"
# License: Entra ID P2 or ID Governance; activation 1–24h; settings are not inherited

Break-glass accounts and Conditional Access

az ad user create --user-principal-name bg-admin01@<tenant>.onmicrosoft.com --display-name "Emergency Access 01" --password <pwd>
az rest -m post --url https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments \
  --body '{"principalId":"<oid>","roleDefinitionId":"62e90394-69f5-4237-9190-012177145e10","directoryScopeId":"/"}'
az rest --url https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies --query "value[].{n:displayName,s:state}"
# Set CA policies to enabledForReportingButNotEnforced first; exclude grp-alz-emergency-access
# Enforced MFA: phase 1 portal from 2024-10; phase 2 CLI/PS/IaC/REST write operations from 2025-10-01

Deployment identity (federated credential)

az identity create -g <rg> -n id-alz-platform-apply -l canadacentral
az identity federated-credential create -g <rg> --identity-name id-alz-platform-apply -n gh-env \
  --issuer https://token.actions.githubusercontent.com \
  --subject "repo:<org>/<repo>:environment:alz-apply" --audiences api://AzureADTokenExchange
az identity federated-credential list -g <rg> --identity-name <id> -o table
# Up to 20 per identity; no wildcards; propagation delay → AADSTS70021; subject mismatch → AADSTS700213

Managed identity

az vm identity assign -g <rg> -n <vm> --identities <uami-resource-id>
az login --identity --client-id <clientId>
curl -H Metadata:true "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://vault.azure.net&client_id=<clientId>"
# Assign roles directly to the managed identity (group-based grants can take hours to take effect)

Lighthouse and review

az deployment sub create -l canadacentral -f subscription.json -p @subscription.parameters.json
az managedservices assignment list --include-definition true -o table
az graph query --management-groups alz -q "authorizationresources | where type =~ 'microsoft.authorization/roleassignments' | summarize count() by tostring(properties.principalType)"
# Lighthouse: built-in roles only; no Owner; no roles with DataActions; eligibility grants require ID Governance in the managing tenant

Error code quick reference

ErrorLayerWhat to do first
AuthorizationFailedRBACaz role assignment list --assignee … --all --include-inherited
… or an ABAC condition not fulfilled …RBAC conditionsCheck the condition on the delegate's assignment
RequestDisallowedByPolicy … MFA is requiredEnforced MFAAdd MFA for interactive users; move automation to workload identities
RequestDisallowedByPolicy (includes the policy assignment name)Azure PolicySee hour 2
AADSTS53003Conditional AccessSign-in logs → Conditional Access tab
AADSTS700213 / 700212 / 70021Federated credentialCheck subject / audience; wait for propagation
PrincipalNotFoundReplication delaySpecify principalType
RoleDefinitionHasAssignmentsCustom roleDelete the assignment first (including PIM eligibility)

Capstone lab + final quiz

Deliver a complete identity baseline for the new application Landing Zone sub-lz-corp-myapp, and prove that the platform boundary has not been breached
After class ≈ 45 minutesCovers all modules
Run only in a sandbox tenant. The capstone lab changes CA policies, PIM settings, and root-scope assignments. Do not run it in a production tenant.
ScenarioThe myapp team has received a new subscription under corp. Security review requires: ① the team can manage resources on its own, but cannot change networking or grant access to anyone; it can only assign allowlisted roles to groups or service principals; ② high-privilege production access is only activated through PIM, with approval; ③ production deployments may come only from the prod environment of the myapp repository, with no secrets; ④ the application reads Key Vault secrets through a managed identity; ⑤ the tenant has two working emergency accounts, and the CA baseline is already live; ⑥ platform and application identities are fully isolated; ⑦ an identity review report can be produced. If you have only one subscription, replace the subscription scope with rg-lz-myapp-cc.
Groups and roles (Modules 2, 3): grp-lz-myapp-prod-owners → Application-Owners @ subscription; grp-lz-myapp-prod-access-admins → RBAC Administrator + conditions (Reader / AcrPull / Key Vault Secrets User, Group and ServicePrincipal only, write and delete branches); grp-lz-myapp-prod-operators → Landing Zone VM Operator @ rg-lz-myapp-cc.
az role assignment list --scope /subscriptions/$LZ_SUB --include-inherited \
  --query "[].{who:principalName, role:roleDefinitionName, cond:condition!=null}" -o table
PIM (Module 4): create grp-lz-myapp-prod-breakfix and give it eligibility for Owner on the subscription: activation for 2 hours, phishing-resistant MFA (authentication context), a justification is required, and two approvers (application owner + platform on-call). If you don't have the license, record it as a “read-only walkthrough.”
Deployment identity (Module 6): id-lz-myapp-prod-deploy (UAMI) + federated credential repo:contoso/myapp:environment:prod + Application-Owners @ subscription; set required reviewers on the GitHub environment prod.
az identity federated-credential list -g rg-lz-myapp-cc --identity-name id-lz-myapp-prod-deploy --query "[].subject" -o tsv
Workload identity (Module 7): id-myapp-cc → Key Vault Secrets User @ kv-myapp-cc-<suffix> (assigned directly, not through a group).
Emergency access and CA (Module 5): bg-admin01 / 02 are permanently active Global Administrators, use FIDO2, and are members of grp-alz-emergency-access; CA01 is report-only → observe for one week → enable; the SigninLogs alert has fired once during a drill.
Isolation checks (Modules 2, 6): as app-dev1, try to change a policy assignment on corp, assign Owner to yourself, and create a VNet. All three should fail. The myapp deployment identity has no roles on alz or platform.
az policy assignment delete --name Deny-Public-IP-On-NIC --scope /providers/Microsoft.Management/managementGroups/corp   # Expect AuthorizationFailed
Review report (Module 8): run a Resource Graph inventory and a PIM eligibility query, and export JSON. Confirm that root scope has no elevated access, no direct assignments to individual users, and that every FIC is bound to an environment.
Cleanup: delete the test VM (if any) and the test role “Bad Role”; revoke the root-scope User Access Administrator; keep the groups, identities, and CA (the next hour continues to use id-myapp-cc and the test VM's network).
Acceptance checklist

Open-ended self-check (6 questions)

1. Why does ALZ place Landing Zone role assignments at subscription / resource group, but policy at management group?

Application teams have full autonomy in their own subscriptions, yet cannot change the policy assignments that govern them (policy is written at a higher management group, where the application teams have no roles). This reflects two design principles: “subscription democratization” and “policy-driven governance.”

2. A user holds both Application-Owners and Network-Management. Can they write a VNet? Why?

Yes. Effective permissions are the union of each role's (Actions − NotActions). Application-Owners' NotActions do not block the Microsoft.Network/* granted by Network-Management. To truly prevent this, you need a deny assignment (such as a deployment stack denySettings) or Azure Policy.

3. What happens when a PIM license expires? How do you prevent it?

Eligibility assignments are deleted, time-bound active assignments become permanent, PIM can no longer activate or manage roles, and the review ends. Prevention: alert before the license expires; keep enough licenses; prepare export and recovery procedures; emergency accounts should not depend on PIM.

4. A Terraform nightly job starts reporting MFA errors after October 2025. What are the likely causes, and what is the correct fix?

The job signs in with a user account (username and password, or a cached personal session), and phase 2 enforced MFA applies to CLI and IaC write operations. The correct fix is to switch to a service principal with a managed identity or federated credentials (workload identities are not affected), not to exempt the account or add permissions.

5. Why should the apply identity's federated credential be bound to an environment rather than the main branch?

Entra only does string matching; anyone or any workflow that can push to main gets a token for ref:refs/heads/main. An environment can require reviewers and restrict branches, so control over who gets an Owner-level token moves into the approval process.

6. When an acquired company's tenant joins group governance, what can Lighthouse do, and what can't it do?

It can use built-in roles (including JIT eligibility-based grants) to let the group team have read-only or limited operational access on the subsidiary's subscriptions, and assign a specified role to a managed identity to run DINE remediation. The subsidiary can revoke this at any time. It cannot grant Owner, custom roles, roles with DataActions, or general access management. The subsidiary tenant still needs to deploy its own ALZ, PIM, CA, and emergency accounts.

Sources and versions

Sources for all technical facts in this hour (verified on 2026-11-18)
TopicVerification resultSources (accessed 2026-11-18)
ALZ identity designCAF sample role assignment table; platform and application team responsibilities; a separate group for each Landing Zone; roles assigned to groups; policy at MG, roles at subscription / RG; conditional delegation; PIM for Groups; DINE remediation identities may only use built-in roles; fewer than 5 Global AdministratorsCAF: Landing zone identity and access management
ALZ custom roles and management groupsLibrary platform/alz/2026.11.0: the root prototype has 5 roles (Subscription-Owner, Application-Owners, Network-Management, Network-Subnet-Contributor, Security-Operations), with permissions as described in the main text; management group IDs have no prefix (alz, platform, landingzones, corp, online, local, sandbox, decommissioned, management, connectivity, identity, security)Azure-Landing-Zones-Library
Multi-tenantStart with a single tenant; in a multi-tenant setup, deploy ALZ separately in each tenant; licenses do not cross tenants; use sandbox and administrative units instead of new tenants; Lighthouse, B2B, and cross-tenant sync are recommendedCAF: multitenant considerations
RBAC limits and troubleshooting5,000 assignments per subscription (fixed; eligibility not counted), 500 per MG, 5,000 custom roles per tenant; changes take up to about 10 minutes to apply; group-based grants for managed identities are cached for about 24 hours; PrincipalNotFound and principalType; transferring a subscription permanently deletes its role assignmentstroubleshoot-limits · troubleshooting
Custom rolesAssignableScopes cannot be /, no wildcards, only one MG, up to 2,000 entries; roles with DataActions cannot be assigned at MG scope; one wildcard per operation stringAzure custom roles
Conditional delegationCondition syntax, role IDs for Owner / RBAC Admin / UAA / Reader / AcrPull, conditionVersion 2.0delegate-role-assignments-examples
Elevated accessRoot-scope User Access Administrator; elevateAccess?api-version=2016-07-01; audit logs and Sentinel rules; removal methodselevate-access-global-admin
PIM licensing and settingsRequires Entra ID P2 or ID Governance; counted objects; consequences of expiry (eligibility deleted, time-bound becomes permanent); new IGA features only in ID Governance; activation 1–24 hours; no default approvers; settings not inherited; least-privilege activation (preview)licensing-fundamentals · PIM role settings
Azure enforced MFAPhase 1 from 2024-10 (portal, Entra, Intune; M365 admin center from 2025-02); phase 2 from 2025-10-01 (write operations in CLI, PowerShell, mobile apps, IaC, REST control plane, and SDKs); workload identities not affected; deferral deadlines 2025-09-30 / 2026-07-01; cannot opt out; public cloud only; CLI 2.76+ / PowerShell 14.3+; Conditional Access requires P1mandatory MFA · CLI troubleshooting
Emergency access accounts≥ 2 accounts, cloud-only on onmicrosoft.com, FIDO2 (recommended) or CBA, permanently active GA, excluded from blocking CA (report-only policies need no exclusion), alerts, validated at least every 90 dayssecurity-emergency-access
Workload identity federationUp to 20 FICs per app / UAMI; no wildcards; issuer + subject must be unique; single-value audience; propagation delay (AADSTS70021); concurrent UAMI creation returns 409; UAMI FIC not yet supported in Malaysia South; flexible FIC is in preview and not supported for managed identitiesWIF considerations · flexible FIC
ALZ accelerator deployment identitiesTerraform: plan UAMI = Reader @ intermediate root + Storage Blob Data Contributor on the state container; apply UAMI = Owner @ intermediate root + the same state container; Bicep What-If UAMI = Reader + whatIf/validate custom roleAccelerator permissions FAQ
Azure LighthouseBuilt-in roles only; Owner, roles with DataActions, and roles with Microsoft.Authorization write operations are not supported; UAA is used only to assign roles to managed identities; security groups; Registration Assignment Delete Role (91c1777a…); eligibility grants require the managing tenant to have an ID Governance license, 30 minutes to 8 hours, up to 10 approvers, and service principals are not supportedtenants-users-roles · eligible authorizations

Video verification notes

All videos below were verified for title and channel through the YouTube oEmbed endpoint (2026-11-18): John Savill's Technical Training: “Exploring the Real Relationship Between Azure AD and Azure Subscriptions” (sXurr46f3HA), “Azure AD Cross-Tenant Access Settings Deep Dive” (Ku64fo7iZ4Y), “Azure AD B2B Overview” (iUGezQj4BpY), “Azure Role-Based Access Control Deep Dive” (qFoHDTxkQII), “Azure Master Class v2 - Module 3 - Governance” (eLSjnF6Crlw), “Azure AD Administrative Units Overview” (1-x86jJuK7c), “Azure AD Privileged Identity Management (PIM) - AZ-500, SC-300 Deep Dive Topic” (gccgIkR8_a0), “Azure Master Class v3 - Part 2 - Identity” (megA6BPpYqo), “Azure AD Conditional Access Overview” (G0pyhveHJmg), “Stronger Azure AD Authentication” (ns_94ZXrbPI), “Using Conditional Access with Authentication Flows” (A1-kSuLLNLI), “GitHub Azure AD OIDC Authentication” (XkhkkLBkAT4), “Azure DevOps Workload Identity Federation with Azure Overview. NO MORE SECRETS!” (saTUeR_U3lA), “Microsoft Azure Managed Identity Deep Dive” (rC1TV0_sIrM), “Workload Identity Protection with Azure AD Identity Protection” (TASsrY_ilWc); Microsoft Developer: “Why use workload identity federation?” (WIs3IRCJhEo); Microsoft Azure: “Azure Lighthouse: A unified control plane for managing Azure at scale | Azure Friday” (x-Db_AFKCzM). Some videos use the older name Azure AD (now Microsoft Entra ID); the concepts still apply. No verified video was found that covers the two phases of Azure enforced MFA or ALZ custom roles specifically, so the corresponding modules provide storyboard scripts instead.

Voice narration notes

The “Voice” tab uses the browser's Web Speech API (speechSynthesis, en-US) to read the narration script aloud in real time. English terms are pronounced with en-US. Quality depends on the voices installed on the system. This course-generation environment cannot call a TTS service, so no MP3 is embedded; if you need offline audio, give the narration script to any TTS tool.

Known limitations

  • None of the commands in this hour were run in a real tenant. The “expected output” examples are illustrative: IDs, names, times, and error text depend on your environment and version, and some error text is paraphrased.
  • After deployment, the display names of ALZ custom roles may include a suffix (depending on the implementation of the alz provider / AVM module), so this hour uses the query starts_with(roleName,'Application-Owners') to stay compatible.
  • For the PIM activation request API behavior where a group eligibility is activated by a member with their own principalId, follow the official REST documentation and portal behavior. If it fails, use the portal or PIM for Groups instead.
  • The application IDs (Windows Azure Service Management API), role template IDs, and built-in authentication strength IDs in the Conditional Access JSON come from commonly used official values. Verify them with a Graph query before submitting. Azure CLI's default Graph token may not include Policy.ReadWrite.ConditionalAccess.
  • Trial availability and entry points for Entra ID P2 / ID Governance follow what the portal shows. Without a license, the PIM and Conditional Access parts can only be done as read-only walkthroughs.
  • Lighthouse needs two tenants to be fully verified. With a single tenant, only template validation is possible.
  • The test VM (B1s) is billed hourly, so delete it right after the lab. Key Vault enters its soft-delete retention period after deletion.
  • Times, state changes, and logs in the animations are illustrative and explain the mechanism. They are not the service's exact timing.