Azure Landing Zone Hour 2: Resource Organization and Governance — Subscriptions, Naming, and Azure Policy
alz and landingzones. Deny and DenyAction will block requests for real. You get Owner on the root management group by elevating access through “Access management for Azure resources” in Entra. Revoke it when the lab is finished.- Explain why subscriptions are the scale unit of ALZ (the boundaries for scale, quotas, policy, billing, and RBAC). Plan subscriptions for platform and application landing zones, place them in the right management groups, and describe a fallback for when you have only one subscription.
- Write a naming and tagging standard (CAF abbreviation + workload + environment + region), and enforce it with Azure Policy: resource groups must have a
costCentertag, and resources inherit tags from their resource group automatically. - Break down Azure Policy into definitions, initiatives, assignments, parameters, and scopes. Write a custom definition and initiative, assign them on a management group, and understand
notScopes,definitionVersion,overrides, andresourceSelectors. - Explain the 11 effects in the official evaluation order: disabled → append / modify → deny → audit → manual → auditIfNotExists → denyAction, plus auditIfNotExists and deployIfNotExists after a request succeeds. Use DenyAction to prevent accidental deletion.
- Use remediation tasks + managed identities to fix existing resources. Handle exceptions with exemptions (Waiver / Mitigated, expiration dates, and policy components), and distinguish exemptions from exclusions.
- Read the folder structure, calendar-based version numbers, and upgrade process of the ALZ policy library (Azure-Landing-Zones-Library). Know how to change default assignments without forking the library.
- Use
az policy stateand Azure Resource Graph (policyresources,resourcecontainers,resources) to build compliance and tag reports across management groups, and complete one governance review.
1-hour timetable
| # | Time | Module | Core content | Animation / interaction | Lab (sandbox tenant) |
|---|---|---|---|---|---|
| 0 | Before class | Warm-up | Check the hour 1 management group hierarchy, subscription placement, and permissions. Starting point if you have only one subscription | Environment checklist | Starting script (creates missing hierarchy) |
| 1 | 00–06 | Subscription design | Subscription = boundary for scale / policy / billing / RBAC; platform vs. application subscriptions; limits; subscription placement; subscription vending; tenant transfer restrictions | Subscription placement simulator (which assignments it inherits) | Place 4 subscriptions in the right management groups and verify |
| 2 | 06–13 | Naming and tags | CAF abbreviations and naming patterns, name length limits, four required tags, tag inheritance, and cost allocation | Name generator + validator | Enforce the costCenter tag on resource groups + resource tag inheritance |
| 3 | 13–21 | Policy deep dive | Definition structure (mode, parameters, aliases, conditions), initiatives, assignment properties, definition location, and assignment scope rules | Scope resolver: which assignments apply to a given resource | Custom definition + initiative, DoNotEnforce trial run |
| 4 | 21–28 | Effects | The 11 effects, evaluation order, and real behavior of Deny / Audit / Modify / DINE / DenyAction | Core animation: how a request moves through the ARM and policy engine evaluation pipeline | Deny blocks, Modify rewrites, DenyAction prevents deletion |
| 5 | 28–35 | Remediation and exemptions | Remediation task parameters, managed identity permissions, exemption categories and expiration, exclusions vs. exemptions | Remediation task execution simulator | Fix tags on existing resources; create a time-limited exemption for one resource |
| 6 | 35–42 | ALZ policy library | Library folder structure, archetypes and architectures, version tags, library_references in the alz provider, upgrades and customization | Library resolution and version upgrade comparison | Review library contents and compare 2026.10.0 with 2026.11.0 |
| 7 | 42–50 | Compliance and Resource Graph | Compliance state and percentages, evaluation triggers, on-demand scans, ARG tables and KQL, throttling and paging | KQL query builder | Compliance and missing-tag reports across management groups |
| 8 | 50–60 | Governance review | Review checklist, 10 common mistakes, troubleshooting decision tree | Governance review scorecard + troubleshooting tree | Run a review on the lab tenant and fix the issues |
| — | After class | Cheat sheet · Capstone lab | Deliver a governance baseline for the myapp application landing zone | Final quiz: 12 questions | Capstone lab |
Knowledge Coverage Matrix
| Target skill | M1 | M2 | M3 | M4 | M5 | M6 | M7 | M8 | Key commands / fields | Lab |
|---|---|---|---|---|---|---|---|---|---|---|
| Subscription planning and placement | ✓ | · | ✓ | · | · | ✓ | ✓ | ✓ | az account management-group subscription add | Place 4 subscriptions |
| Naming and tagging standards | · | ✓ | ✓ | ✓ | ✓ | · | ✓ | ✓ | tags, field('name'), like / match | costCenter enforcement and inheritance |
| Write definitions and initiatives | · | ✓ | ✓ | ✓ | · | ✓ | · | ✓ | az policy definition create, set-definition create | lab-gov-baseline |
| Assignments, parameters, and scopes | ✓ | ✓ | ✓ | · | ✓ | ✓ | · | ✓ | --scope, --not-scopes, --enforcement-mode | DoNotEnforce trial run |
| Effects and evaluation order | · | ✓ | ✓ | ✓ | ✓ | ✓ | · | ✓ | then.effect, details | Deny / Modify / DenyAction |
| Remediation and managed identities | · | ✓ | · | ✓ | ✓ | ✓ | · | ✓ | az policy remediation create, roleDefinitionIds | Fixing tags on existing resources |
| Exemptions and exception management | · | · | ✓ | · | ✓ | · | ✓ | ✓ | az policy exemption create | Time-limited Waiver |
| ALZ library and version upgrades | · | · | · | ✓ | · | ✓ | · | ✓ | library_references, definitionVersion | Version comparison |
| Compliance reporting and Resource Graph | ✓ | ✓ | · | · | ✓ | · | ✓ | ✓ | az policy state, az graph query | Cross-MG reporting |
What this hour does not cover (and where to learn it)
| Topic | Why it is not in this hour | Where to learn it |
|---|---|---|
| CAF stages, ALZ design areas, where the management group hierarchy comes from, comparison of deployment options | Covered in hour 1. This hour uses its results directly | Hour 1 |
| Azure RBAC, custom roles, PIM, workload identity federation | Identity and access get their own hour. This hour covers only the managed identity permissions that remediation tasks need | Hour 3 |
| Network details of Private DNS zone DINE policies, Firewall, UDR | Belongs to network topology | Hour 4 |
| DINE policy details for Defender for Cloud, AMA, and DCR; cost management reports | Belongs to management and monitoring | Hour 5: Management and Monitoring |
| Policy-as-code pipeline (EPAC, full avm-ptn-alz deployment), subscription vending module | Needs the automation background from hour 6 | Hour 6: Automation |
| Terraform syntax, azurerm / azapi basics | Prerequisite course | Terraform in 8 Hours |
How to use this course material
Theory · diagrams · animation · commands · lab · production case · troubleshooting · quiz · voice · video. The animation in Module 4 is the core of this hour: how a request passes through disabled, modify, deny, audit, denyAction, and then DINE after the request completes.
A module counts toward your progress when you score ≥ 70% on its quiz or click “Mark this module complete.” Progress is saved in this browser. If local storage is blocked, progress is cleared on refresh.
The “Voice” tab reads the script aloud with the browser’s built-in Web Speech API (en-US). If no English voice pack is installed, you can still read the script or pass it to another TTS tool.
platform/alz/2026.11.0 (released 2026-11-06), the Terraform provider Azure/alz 0.22.1, the module Azure/avm-ptn-alz/azurerm 0.23.0, and Azure CLI 2.x (az policy and az graph extensions) as its baseline. Verified on 2026-11-18. (The date in the sidebar is the date the page skeleton was generated.) Platform facts that matter for this hour: there are 11 policy effects (including denyAction, manual, addToNetworkGroup, and mutate). Assignments support definitionVersion, overrides, resourceSelectors, and the new Enroll enforcement mode. The ALZ default hierarchy has 12 management groups (including security and local). None of the cloud commands were run against a real tenant. All output is sample output.Module 0 · Warm-up: management group hierarchy and policy starting point
- You have completed Hour 1. The sandbox tenant has an intermediate root management group
alz(display name “Azure Landing Zones”) with these child management groups:platform(withsecurity,management,connectivity, andidentityunder it),landingzones(withcorp,online, andlocalunder it),sandbox, anddecommissioned. These IDs match the official ALZ library defaults and have no prefix. Only the intermediate root is calledalz. - Subscriptions (ideal case):
sub-alz-management,sub-alz-connectivity,sub-alz-identity, andsub-lz-corp-myapp. CAF also recommends a dedicated security subscription (optional; this hour calls itsub-alz-security). - Permissions: Owner on the
alzmanagement group (or at least Resource Policy Contributor + User Access Administrator, to grant permissions to the remediation task's managed identity). - Tools: Azure CLI 2.x (
az version),az extension add --name resource-graph,jq,git. Terraform 1.x is optional for Module 6. - Prerequisite courses: Terraform in 8 Hours (IaC basics), and hour 3 of any CI platform course (OIDC and deployment identity, such as GitHub hour 3).
Connecting to Hour 1
| What hour 1 left you | How to use this hour |
|---|---|
| Management group hierarchy (12 MGs) | Module 1 places subscriptions in it. The assignment scopes in Module 3 are all these MGs |
| Overview of the ALZ default policies (root: 17 assignments, landingzones: 53, corp: 5…) | Module 4 uses its Deny and DenyAction examples. Module 6 explains where these assignments come from and how they are upgraded |
| Deployment options (IaC Accelerator, avm-ptn-alz) | This hour uses the Azure CLI to demonstrate policy mechanics. Module 6 shows how the same things are expressed in the alz provider |
Resource naming convention rg-alz-mgmt-cc, vnet-hub-cc… | Module 2 turns it into a standard and enforces it with policy |
Starting steps (if you don't have the Hour 1 results)
# 0) Sign in to the sandbox tenant (do not sign in to the production tenant!)
az login --tenant <sandbox-tenant-id>
az account show --query "{tenant:tenantId, user:user.name}" -o table
# 1) Elevate access as a Global Administrator (this gives you User Access Administrator on the root "/"), then assign yourself Owner on the root MG
az rest --method post --url "/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"
TENANT_ID=$(az account show --query tenantId -o tsv)
ME=$(az ad signed-in-user show --query id -o tsv)
az role assignment create --assignee "$ME" --role Owner --scope "/providers/Microsoft.Management/managementGroups/$TENANT_ID"
# 2) Create the minimum hierarchy (matches the ALZ default IDs)
az account management-group create --name alz --display-name "Azure Landing Zones"
for mg in platform landingzones sandbox decommissioned; do
az account management-group create --name $mg --display-name "${mg^}" --parent alz
done
for mg in security management connectivity identity; do
az account management-group create --name $mg --display-name "${mg^}" --parent platform
done
for mg in corp online local; do
az account management-group create --name $mg --display-name "${mg^}" --parent landingzones
done
{
"displayName": "Azure Landing Zones",
"id": "/providers/Microsoft.Management/managementGroups/alz",
"name": "alz",
"type": "Microsoft.Management/managementGroups"
}
Tip: ${mg^} is the bash syntax for capitalizing the first letter, and it is used only for display names. The official display name for landingzones is “Landing zones.” To fix it, run az account management-group update --name landingzones --display-name "Landing zones".
Fallback when you have only one subscription
sub-lz-corp-myapp below) under the corp management group. Put all platform resources (such as rg-alz-mgmt-cc) in this subscription too. Do all policy labs on the landingzones / corp management groups. The results are the same as with multiple subscriptions. Only the “subscription placement” in Module 1 and the cross-subscription report in Module 7 will show a single row. Do not place this subscription under platform, or the application landing zone assignments later in the hour will not apply to it.Self-check checklist
az account management-group show --name alz --expand --recurse \
--query "children[].{name:name, children:children[].name}" -o json
az account management-group entities list --query "[?type=='/subscriptions'].{sub:displayName, parent:parent.id}" -o table
az policy assignment list --scope /providers/Microsoft.Management/managementGroups/alz --query "length(@)"
az extension add --name resource-graph --upgrade 2>/dev/null; az graph query -q "resourcecontainers | summarize count() by type" -o table
[
{ "name": "platform", "children": ["security","management","connectivity","identity"] },
{ "name": "landingzones", "children": ["corp","online","local"] },
{ "name": "sandbox", "children": null },
{ "name": "decommissioned","children": null }
]
Sub Parent
-------------------- ------------------------------------------------
sub-alz-management /providers/Microsoft.Management/managementGroups/management
sub-alz-connectivity /providers/Microsoft.Management/managementGroups/connectivity
sub-alz-identity /providers/Microsoft.Management/managementGroups/identity
sub-lz-corp-myapp /providers/Microsoft.Management/managementGroups/corp
0
Type Count_
------------------------------------------------ ------
microsoft.management/managementgroups 13
microsoft.resources/subscriptions 4
microsoft.resources/subscriptions/resourcegroups 6
- ☐ 4 child MGs under
alz, 4 underplatform, and 3 underlandingzones(12 MGs + the tenant root = 13). - ☐ Subscriptions are in the correct MGs. (If you built only the hierarchy in hour 1 and did not place subscriptions, the Module 1 lab completes this step.)
- ☐ Number of assignments on
alz: 0 if you built only the hierarchy; 17 if you deployed the ALZ default policies with the accelerator in hour 1. This hour works in both cases. All lab assignments start withlab-to make cleanup easier. - ☐
az graph queryreturns results (confirms the resource-graph extension is installed and permissions are correct).
Module 1 · Subscription design: subscriptions as scale units, limits, and placement
- Name the five dimensions of a subscription as a boundary: scale / quotas, policy, RBAC, billing, and networking (a VNet cannot span subscriptions; it can only be peered).
- Plan platform subscriptions (management, security, connectivity, and identity, each separate) and application landing zone subscriptions (by workload + environment) following CAF guidance, and place them in the right management groups.
- Remember the key limits: 980 resource groups per subscription, 50 tags per resource, 800 deployment history entries, and up to 6 levels of MG hierarchy (not counting the root and subscription levels).
- Use the CLI to move subscriptions, set the default management group and the “require authorization” hierarchy setting, and know how long policies take to apply after a subscription moves.
What: what a subscription is in ALZ
In CAF, a subscription is the unit of management, billing, and scale. A resource must belong to a resource group, a resource group must belong to a subscription, and a subscription can sit under only one management group (each MG or subscription has exactly one parent). One of the ALZ design principles, subscription democratization, means treating subscriptions as “standard units delivered to application teams,” rather than having the platform team squeeze everything into a few large shared subscriptions.
| Boundary | What it means | Impact on design |
|---|---|---|
| Scale / quotas | Quotas such as vCPUs, public IPs, and storage accounts are counted per subscription + region. Resource group counts, deployment history, and similar limits are hard limits at the subscription level | Large workloads (HPC, SAP, IoT) get their own subscription to avoid competing with other workloads for quota |
| Policy | A subscription inherits all policy assignments on its MG chain. You can also assign policies directly on the subscription | PCI, production, and development need different policies → different subscriptions / different MGs |
| RBAC | A subscription Owner can manage everything in it (including role assignments) | One subscription per team gives clear permission boundaries. Platform subscriptions go only to the platform team |
| Billing | A natural dimension for bills, budgets, and cost analysis | Platform costs and each application's costs can be separated without relying on tags |
| Networking | A VNet belongs to a subscription and cannot be shared across subscriptions. It can only be peered or connected through a hub | Workloads that need to reach each other are planned in the same hub-and-spoke topology (hour 4) |
Why: why not put everything in one big subscription
- Hard limits will hit you: up to 980 resource groups per subscription; 800 deployment history entries per subscription; up to 800 instances of each resource type in a resource group (some types are exceptions).
- Policies cannot be differentiated: resources in the same subscription can only be told apart with resource group–level assignments or
notScopes. At scale, this turns into exception hell. - Permissions cannot be contained: a subscription Owner has every permission. If you put the platform's Firewall and an application's VMs in the same subscription, any application Owner can change the Firewall.
- Costs stay unclear: you can only allocate costs with tags, and tags always have gaps (Module 2 covers how to fix them).
How: subscription planning in ALZ
| Subscription (name used in this course) | Placed in which MG | What it hosts | Notes |
|---|---|---|---|
sub-alz-management | management | Log Analytics (law-alz-mgmt-cc), automation, monitoring and alerts | CAF: required |
sub-alz-connectivity | connectivity | Hub VNet, Firewall, VPN / ExpressRoute gateways, private DNS zones | CAF: required |
sub-alz-identity | identity | Domain controllers (if needed), Entra Domain Services | CAF: recommended. You can skip it if you have no AD DS requirements |
sub-alz-security (optional) | security | Microsoft Sentinel, SIEM integration | Since CAF 2025-12, a separate security subscription is recommended |
sub-lz-corp-myapp | corp | myapp spoke VNet, application resources | Workloads that need internal access / are not directly exposed to the internet |
sub-lz-online-* | online | Internet-facing workloads | Does not inherit corp's “no public internet” policy |
sub-sbx-<user> | sandbox | Personal labs | Isolated from corp's network (sandbox policies block VNet peering, among others) |
What about dev / test / prod? CAF recommends separating environments with different subscriptions, but placing them under the same management group (for example, the myapp dev and prod subscriptions both under corp). Do not create one MG per environment. Express environment differences with subscription-level assignments or parameters, and keep the hierarchy at 3–4 levels.
Subscription vending: use a pipeline and IaC (such as Terraform modules or Bicep) to fulfill “I need a landing zone” requests. The pipeline creates the subscription (using the subscription alias API), places it in the target MG, creates a spoke VNet and peers it to the hub, grants the team RBAC, and sets budgets and tags. Hour 6 implements this. For this hour, remember: subscription placement should be part of the vending process, not done by hand.
Where new subscriptions go by default: they land in the tenant root management group, which means “not subject to any ALZ policy.” In the hierarchy settings, change the default management group to sandbox (or a dedicated holding MG), and turn on “require authorization to create management groups.” This stops stray subscriptions and ad hoc MGs.
Tenant transfer restrictions: CAF recommends setting both “Subscriptions leaving Microsoft Entra directory” and “Subscriptions entering Microsoft Entra directory” to Permit no one. Add exempted users only for platform operations and emergency access accounts. (These are subscription policies in Cost Management, not Azure Policy.)
When: when you need a new subscription
| Signal | Recommendation |
|---|---|
| New workload, new team, new environment | Vend a new application landing zone subscription |
| The vCPU quota for a region in an existing subscription has been raised several times and is still not enough | Split the subscription, or use Quota Groups to share quota across subscriptions |
| Different compliance requirements (PCI, data sovereignty) | Separate subscription, and a separate MG if needed |
| Only one more region | No new subscription needed. Subscriptions are not tied to a region. Use different resource groups to separate them |
| Active-passive regional disaster recovery (same workload) | Usually the same subscription. Split only if it is active-active and has an independent lifecycle |
Architecture diagram: where subscriptions sit in the ALZ hierarchy
Comparison: one subscription vs. multiple subscriptions
Interactive animation: subscription placement simulator
Choose a subscription and a target management group, then play through the “move subscription” process: permission check → update the parent → ARM hierarchy cache refresh → subscription-level evaluation → resource-level compliance update. The panel on the right calculates how many ALZ default assignments it will inherit (adding up the per-MG assignment counts from library 2026.11.0).
Core commands and parameters
| Command | Purpose | Key parameters / notes |
|---|---|---|
az account management-group subscription add | Move a subscription to an MG | --name <mg> --subscription <id|name>. Requires Owner on the subscription + write permission on the source and target MGs |
az account management-group subscription remove | Move out of an MG (back to the tenant root) | Moving out means “leaving all ALZ policies.” Use with care |
az account management-group entities list | List all MGs and subscriptions with their parents | Use --query to filter /subscriptions |
az account management-group hierarchy-settings create | Set the default MG and “require authorization” | --name <tenant-id> --default-management-group <mg-id> --require-authorization-for-group-creation true |
az account alias create | Create a subscription with the subscription alias API (vending process) | --billing-scope, --display-name, --workload Production|DevTest. Requires the account extension and billing permissions |
az vm list-usage / az network list-usages | View regional quota usage | --location canadacentral |
az tag create / az tag update | Tag a subscription | --resource-id /subscriptions/<id> (a subscription itself can have up to 50 tags) |
1) Move a subscription and verify its parent
SUB_APP=$(az account show --name sub-lz-corp-myapp --query id -o tsv)
az account management-group subscription add --name corp --subscription "$SUB_APP"
az account management-group subscription show --name corp --subscription "$SUB_APP" \
--query "{name:displayName, parent:parent.id, state:state}" -o json
{
"name": "sub-lz-corp-myapp",
"parent": "/providers/Microsoft.Management/managementGroups/corp",
"state": "Active"
}
How to verify: in the portal's Management groups view, the subscription appears under Corp. Common error: you are Owner of the subscription but lack write permission on the target MG → AuthorizationFailed. Production use: the vending pipeline does this, and the placement is declared in IaC (the subscription_placement variable in avm-ptn-alz).
2) Set the default management group and “require authorization”
TENANT_ID=$(az account show --query tenantId -o tsv) az account management-group hierarchy-settings create --name "$TENANT_ID" \ --default-management-group "/providers/Microsoft.Management/managementGroups/sandbox" \ --require-authorization-for-group-creation true az account management-group hierarchy-settings list --name "$TENANT_ID" -o json
{
"defaultManagementGroup": "/providers/Microsoft.Management/managementGroups/sandbox",
"requireAuthorizationForGroupCreation": true
}
After you set this, new subscriptions (including Visual Studio subscriptions transferred in) land in sandbox first and are subject to sandbox policies until the vending process moves them to the right place. Creating a new MG requires Microsoft.Management/managementGroups/write on the root MG.
3) Check regional quota and the number of resource groups in the subscription
az vm list-usage --location canadacentral \
--query "[?contains(name.value,'cores')].{name:name.localizedValue, used:currentValue, limit:limit}" -o table
az group list --query "length(@)" # Compare with the 980 limit
Name Used Limit ----------------------- ------ ------- Total Regional vCPUs 2 10 Standard BS Family vCPUs 2 10 6
Lab: place 4 subscriptions in the right management groups
sub-alz-management, sub-alz-connectivity, sub-alz-identity, and sub-lz-corp-myapp to management, connectivity, identity, and corp. Set the default MG and add cost tags to the subscriptions. Cost: 0 (metadata changes only). Permissions: Owner on the alz MG + Owner on each subscription. Risk: moving a subscription changes the policies it inherits right away (if the ALZ default policies are deployed, Deny takes effect immediately).declare -A PLACE=( [sub-alz-management]=management [sub-alz-connectivity]=connectivity \
[sub-alz-identity]=identity [sub-lz-corp-myapp]=corp )
for s in "${!PLACE[@]}"; do
id=$(az account show --name "$s" --query id -o tsv 2>/dev/null) || { echo "Missing subscription $s (single-subscription fallback: only process sub-lz-corp-myapp)"; continue; }
echo "$s $id -> ${PLACE[$s]}"
donefor s in "${!PLACE[@]}"; do
id=$(az account show --name "$s" --query id -o tsv 2>/dev/null) || continue
az account management-group subscription add --name "${PLACE[$s]}" --subscription "$id" -o none && echo "moved $s"
doneaz tag update --resource-id "/subscriptions/$SUB_APP" --operation Merge \ --tags env=prod owner=team-myapp@contoso.example costCenter=CC-1001 workload=myapp
az graph query -q "resourcecontainers | where type == 'microsoft.resources/subscriptions' | extend mgChain = properties.managementGroupAncestorsChain | project name, parentMg = tostring(mgChain[0].name), tags" -o table
Name ParentMg Tags
-------------------- ------------ ---------------------------------------------
sub-alz-management management {}
sub-alz-connectivity connectivity {}
sub-alz-identity identity {}
sub-lz-corp-myapp corp {"env":"prod","owner":"team-myapp@contoso.example",...}az account management-group hierarchy-settings delete --name "$TENANT_ID".Case 1: a “shared subscription” hits the 980 resource group limit
Problem: a company put all its internal applications in sub-shared-prod. Each application and each feature branch got its own resource groups. Three years later it hit the 980 limit. New applications could not be deployed, and the subscription had as many as 60 Owners. What to do: vend new subscriptions by workload. Migrate with Resource Mover or by redeploying. Move platform resources out to the connectivity / management subscriptions first. Limits: not all resource types support cross-subscription moves. VNets and similar resources must be rebuilt. Assess before you migrate (covered in detail in hour 7).
Case 2: a Visual Studio subscription “slips” into the tenant root
Problem: a developer transferred a personal Visual Studio subscription into the company tenant. The subscription landed in the tenant root, so no ALZ policy applied, and the developer created a VM with a public IP. What to do: set the default MG to sandbox. Set “subscriptions entering the directory” to Permit no one, and list the exempted users. Use Resource Graph to run a regular query for subscriptions whose managementGroupAncestorsChain contains only the tenant root. Limits: the exempted users in a subscription policy must be individual users, not groups.
Case 3: not enough quota makes scale-out fail on launch day
Problem: on promotion day, VMSS scale-out reported QuotaExceeded. What to do: request quota based on workload size when the subscription is vended. Use a quota alert to notify the Owner at 80%. For capacity-sensitive workloads, use on-demand capacity reservations. Limits: a quota increase does not mean the region has capacity. Popular SKUs may require a different region or SKU.
Common errors and fixes
(AuthorizationFailed) The client '…' does not have authorization to perform action 'Microsoft.Management/managementGroups/subscriptions/write'
Cause: moving a subscription needs permissions in three places: Owner on the subscription (role assignment write permission), MG write permission on the target parent MG, and MG write permission on the current parent MG. Being Owner on the subscription alone is not enough.
az role assignment list --assignee "$ME" --all --query "[].{role:roleDefinitionName, scope:scope}" -o table
Fix: grant Management Group Contributor or Owner on alz (or on the source and target MGs), or have the platform team's vending identity perform the move.
Operation could not be completed as it results in exceeding approved Total Regional Cores quota
Cause: the regional vCPU quota (subscription + region) is too low.
az vm list-usage --location canadacentral -o table | grep -i -E "Total Regional|Family"
Fix: increase it in the portal under “Quotas,” or request it automatically with the Quota REST API. In the long term, split the subscription or use Quota Groups.
The subscription has moved to corp, but the Deny policy did not block anything, or the compliance page still shows old data
Cause: ARM's hierarchy and assignment caches take time to refresh. Subscription-level evaluation takes about 30 minutes. Compliance for existing resources waits for the evaluation cycle or an on-demand scan. Deny on new requests usually takes effect quickly, but it is not guaranteed to happen “within a second.”
az policy state trigger-scan --subscription "$SUB_APP" --no-wait az policy assignment list --disable-scope-strict-match --query "[].name" -o tsv | head
Fix: wait and retry. Use --disable-scope-strict-match to confirm the subscription can actually “see” the inherited assignments.
ResourceGroupQuotaExceeded / Creating the resource group would exceed the quota of '980'
Cause: the subscription has reached the 980 resource group limit.
az group list --query "[?tags.env=='feature'].name" -o tsv | wc -l
Fix: clean up temporary resource groups. Move feature-branch environments to a separate dev subscription. In the long term, split subscriptions by workload.
1. List all subscriptions that are still directly under the tenant root management group.
TENANT_ID=$(az account show --query tenantId -o tsv) az graph query -q "resourcecontainers | where type == 'microsoft.resources/subscriptions' | extend parent = tostring(properties.managementGroupAncestorsChain[0].name) | where parent == '$TENANT_ID' | project name, subscriptionId" -o table
2. Move sub-lz-online-shop from corp to online, and confirm its parent.
az account management-group subscription add --name online --subscription sub-lz-online-shop az account management-group subscription show --name online --subscription sub-lz-online-shop --query parent.id -o tsv
A team asks for “one management group each for myapp's dev, test, and prod, with the 3 subscriptions placed in them separately,” because prod needs stricter policies. How do you respond?
I would not create an MG for each environment. Put all three subscriptions under corp so they inherit the same ALZ guardrails. Express prod's stricter requirements with subscription-level assignments. For example, assign an extra Deny only on the prod subscription, or use initiative parameters to raise Audit to Deny. This keeps the hierarchy at 3–4 levels, and new environments do not require hierarchy changes. Only if prod has a completely different compliance regime (such as PCI) should you consider a separate MG.
Verified training videos
Official documentation
- Subscription considerations and recommendations
- Azure subscription and service limits
- Management groups overview
Video storyboard script (about 90 seconds)
This course material cannot generate video or MP3 files directly. The storyboard and narration script are provided so you can pass them to a video tool.
Visual: a huge subscription box packed with resource groups. The counter jumps to 980 and turns red.
Narration: Subscriptions have hard limits. You get up to 980 resource groups and up to 800 deployment history entries. Put everything in one subscription, and you will hit the wall eventually.
Visual: the subscription splits into management, connectivity, identity, security, and several application subscriptions, each sliding into the management group tree.
Narration: ALZ splits platform subscriptions by responsibility, and vends application subscriptions by workload and environment. The subscription is the scale unit.
Visual: as the subscription moves into corp, policy icons drop in from three levels: alz, landingzones, and corp. The counter adds 17 + 53 + 5.
Narration: The management group it sits in determines which assignments on that chain it inherits. Place it in the wrong spot, and the strictest or loosest policies end up on the wrong subscription.
Visual: a new subscription slides from the tenant root down into sandbox.
Narration: Set the default management group to sandbox, then turn on “require authorization to create management groups,” so stray subscriptions cannot bypass governance.
Module 2 · Naming and tagging standards: policy enforcement and cost allocation
- Name ALZ platform and application resources using the CAF naming pattern (resource type abbreviation + workload + environment + region + instance). Know that length, allowed characters, and uniqueness scope differ between resource types.
- Define the four required tags:
env,owner,costCenter, andworkload. Explain that tags are not inherited by default, and state the naming case rules. - Use the built-in policies Require a tag on resource groups (Deny) and Inherit a tag from the resource group if missing (Modify) to enforce “resource groups must have the tag, and resources get it automatically.”
- Know the limits of naming enforcement: policy can reject non-compliant names, but it cannot rename resources. Naming standards are better generated inside IaC modules.
What: naming standards and tagging standards
Names answer “what is this, who owns it, and in which environment and region.” Tags answer “who is responsible, who pays, and which workload does it belong to.” The CAF-recommended naming pattern is <resource type abbreviation>-<workload/application>-<environment>-<region>-<instance>. Include each part as needed. This course uses “abbreviation + workload + environment/function + region abbreviation cc (canadacentral)” throughout.
| Resource | CAF abbreviation | Name used in this course | Length / characters / uniqueness (official naming rules) |
|---|---|---|---|
| Management group | mg | alz, corp (uses the ALZ default IDs) | 1–90, unique within the tenant |
| Resource group | rg | rg-alz-mgmt-cc, rg-lz-myapp-cc | 1–90, unique within the subscription, cannot end with a period |
| Virtual network | vnet | vnet-hub-cc, vnet-spoke-myapp-cc | 2–64, unique within the resource group |
| Log Analytics workspace | log | law-alz-mgmt-cc (course convention) | 4–63, letters, numbers, and hyphens |
| Azure Firewall | afw | afw-hub-cc | 1–80 |
| Key Vault | kv | kv-myapp-prod-cc-01 | 3–24, globally unique, starts with a letter, no consecutive hyphens |
| Storage account | st | stmyappprodcc01 | 3–24, globally unique, lowercase letters and numbers only (no hyphens) |
| User-assigned managed identity | id | id-policy-remediation | 3–128 |
| Windows VM | vm | vm-myapp-cc-01 | 1–15 (hostname limit), Linux 1–64 |
| Policy assignment (MG scope) | Descriptive name | lab-rg-req-costcenter | Resource name 1–24 (MG scope), 1–64 for other scopes; display name 1–128 |
law- and log- The CAF abbreviation table uses log for Log Analytics workspaces. This course keeps the convention law-alz-mgmt-cc used across hours. Your organization should pick one and write it into the standard. Consistency matters more than which one you pick.Tagging standard (the four required tags in this course)
| Tag | Example value | Purpose | Enforcement |
|---|---|---|---|
env | prod / dev / sbx | Environment, shutdown policy, alert tiers | Required on resource groups + allowed value list |
owner | team-myapp@contoso.example | Who to contact when something breaks, cost notifications | Required on resource groups |
costCenter | CC-1001 | Cost allocation (chargeback) | Required on resource groups + inherited by resources |
workload | myapp | Aggregates costs and resources by workload | Inherited by resources |
Why: three tagging pitfalls
- Not inherited by default: tags you put on a resource group or subscription do not automatically appear on the resources inside it. Either write them in IaC, add them with a Modify policy (Inherit a tag…), or turn on “tag inheritance” in Cost Management. The last option only affects cost records, not the resources themselves.
- Case: tag names are case-insensitive in operations, but tag values are case-sensitive. Mixing
CostCenterandcostCentersplits reports, so fix one spelling in the standard. - Limits: each resource, resource group, or subscription can have up to 50 tags. Tag names can be up to 512 characters and values up to 256 characters (a few resource types have shorter limits).
How: enforce with policy (the combination ALZ recommends)
| Requirement | Built-in policy (ID) | Effect | Assignment location |
|---|---|---|---|
Resource groups must have costCenter | Require a tag on resource groups (96670d01-0a4d-4649-9c89-2d3abc0a5025) | Deny | landingzones |
Fill in costCenter from the resource group when a resource lacks it | Inherit a tag from the resource group if missing (ea3f2387-9b95-492a-a190-fcdc54f7b070) | Modify (requires a managed identity) | landingzones |
| The value on the resource always matches the resource group | Inherit a tag from the resource group (cd3aa116-8754-49c9-a813-ad46512ece54) | Modify (addOrReplace) | Use with care: overwrites values the team set itself |
| Resources must have a given tag | Require a tag on resources (871b6d14-10aa-478d-b590-94f262ecfa99) | Deny (Indexed mode) | Generally not recommended: it blocks many resources that tools create automatically |
The recommended pattern is “Deny on resource groups, Modify on resources.” People or pipelines create resource groups, so strict requirements there are reasonable. Many different tools create resources, including NICs and disks that the platform creates automatically. A direct Deny on resources would block many legitimate requests, so using Modify to fill in the tag is more reliable.
When: can you enforce naming with policy?
You can write a custom definition that uses field('name') with like (wildcard *) or match (# for a digit, ? for a letter, . for any character) to deny non-compliant names. The Module 3 lab writes one. Be aware, though: policy cannot rename resources. It can only deny them. Many resource names are generated automatically by services (for example, the AKS node resource group MC_…). In practice, it is better to generate names inside IaC modules (for example with the Azure Naming Tool or a Terraform naming module), and use policy only as a safety net for a few key types (resource groups and VNets).
Prod and prod are two different values. ④ “A storage account can be named st-myapp-prod.” Storage account names can contain only lowercase letters and numbers, and they must be globally unique.Flow chart: where tags come from
Naming pattern breakdown
Interactive animation: name generator + validator
Choose a resource type and fill in the workload, environment, and instance. The generator builds the name according to this course's standard, then checks it one rule at a time against the official naming rules (length, characters, uniqueness scope). Finally, it simulates the result of this create request passing through the two tag policies.
Core commands and parameters
| Command | Purpose | Key parameters / notes |
|---|---|---|
az policy definition show --name <guid> | View the parameters, effects, and roleDefinitionIds of a built-in definition | Built-in definitions are at /providers/Microsoft.Authorization/policyDefinitions/<guid> |
az policy assignment create | Assign a policy | --name (MG scope, ≤24 characters), --policy, --scope, --params, --mi-system-assigned --location (required for Modify / DINE) |
az role assignment create | Grant permissions to the assignment's managed identity (the CLI does not grant them automatically) | --assignee-object-id --assignee-principal-type ServicePrincipal --role Contributor --scope |
az tag update --operation Merge|Replace|Delete | Modify tags | Merge does not delete existing tags; Replace does |
az group create --tags | Create a resource group and tag it | Separate multiple tags with spaces: k1=v1 k2=v2 |
1) View the parameters of the two built-in tag policies
az policy definition show --name 96670d01-0a4d-4649-9c89-2d3abc0a5025 \
--query "{name:displayName, mode:mode, params:keys(parameters), effect:policyRule.then.effect}" -o json
az policy definition show --name ea3f2387-9b95-492a-a190-fcdc54f7b070 \
--query "{name:displayName, roles:policyRule.then.details.roleDefinitionIds}" -o json
{
"name": "Require a tag on resource groups",
"mode": "All",
"params": ["tagName"],
"effect": "deny"
}
{
"name": "Inherit a tag from the resource group if missing",
"roles": ["/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"]
}
b24988ac-… is the built-in Contributor role. The mode of the “Require a tag on resource groups” definition is All, because resource groups are not Indexed resources (Module 3 explains mode).
2) Assign “Require a tag on resource groups” for costCenter on landingzones
LZ=/providers/Microsoft.Management/managementGroups/landingzones
az policy assignment create --name lab-rg-req-costcenter \
--display-name "LAB: Resource groups must have costCenter" \
--policy 96670d01-0a4d-4649-9c89-2d3abc0a5025 --scope "$LZ" \
--params '{"tagName":{"value":"costCenter"}}'
3) Assign “Inherit a tag from the resource group if missing” for costCenter, and grant permissions to the managed identity
az policy assignment create --name lab-inherit-costcenter \
--display-name "LAB: Inherit costCenter from RG if missing" \
--policy ea3f2387-9b95-492a-a190-fcdc54f7b070 --scope "$LZ" \
--params '{"tagName":{"value":"costCenter"}}' \
--mi-system-assigned --location canadacentral
PID=$(az policy assignment show --name lab-inherit-costcenter --scope "$LZ" --query identity.principalId -o tsv)
az role assignment create --assignee-object-id "$PID" --assignee-principal-type ServicePrincipal \
--role Contributor --scope "$LZ"
{
"identity": { "principalId": "8f0c2e1a-0000-0000-0000-3b1d7c0e9a42", "type": "SystemAssigned" },
"location": "canadacentral",
"name": "lab-inherit-costcenter",
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/ea3f2387-9b95-492a-a190-fcdc54f7b070",
"scope": "/providers/Microsoft.Management/managementGroups/landingzones"
}
Common error: forgetting the authorization step. Modify still applies to new requests (ARM rewrites the request), but when the remediation task deploys it fails with AuthorizationFailed. When you create an assignment in the portal, the portal grants permissions automatically based on roleDefinitionIds. With the CLI, SDK, or IaC, you must do this yourself.
Lab: resource groups must have costCenter, and resources inherit it automatically
landingzones and verify the effects of Deny and Modify. Subscription: sub-lz-corp-myapp (the single-subscription fallback also applies). Cost: one empty Standard_LRS storage account, essentially zero. Permissions: Resource Policy Contributor + User Access Administrator (or Owner) on landingzones.az account set --subscription sub-lz-corp-myapp az group create --name rg-lz-notag-cc --location canadacentral
(RequestDisallowedByPolicy) Resource 'rg-lz-notag-cc' was disallowed by policy. Reasons: 'Policy enforced'. Policy: "LAB: Resource groups must have costCenter" Assignment: lab-rg-req-costcenter
az group create --name rg-lz-myapp-cc --location canadacentral \ --tags env=prod owner=team-myapp@contoso.example costCenter=CC-1001 workload=myapp ST=stmyappprodcc$RANDOM az storage account create --name $ST --resource-group rg-lz-myapp-cc --location canadacentral \ --sku Standard_LRS --min-tls-version TLS1_2 --allow-blob-public-access false az storage account show --name $ST --resource-group rg-lz-myapp-cc --query tags
{
"costCenter": "CC-1001"
}
The request has no tag, but Modify adds costCenter before the request reaches the storage resource provider. env and workload are not added, because the assignment only targets costCenter (each tag needs its own assignment, or one reference in an initiative).
az monitor activity-log list --resource-group rg-lz-myapp-cc --offset 1h \
--query "[?contains(operationName.value,'Microsoft.Authorization/policies')].{op:operationName.value, status:status.value}" -o table
Op Status --------------------------------------------- --------- Microsoft.Authorization/policies/modify/action Succeeded
rg-lz-myapp-cc are used again in Modules 3–5, so keep them. To delete: az policy assignment delete --name lab-inherit-costcenter --scope "$LZ" (also delete the role assignment: az role assignment delete --assignee "$PID" --scope "$LZ").Case 1: inconsistent tag casing splits the cost report
Problem: the report shows three columns, CostCenter, costcenter, and Cost Center, so finance cannot reconcile it. What to do: the standard allows only costCenter. Standardize the policy parameters. Use Resource Graph to find the old spellings (Module 7), then fix them in bulk with az tag update. Limits: tag names are case-insensitive in operations, but cost exports and some tools keep the original spelling.
Case 2: Require a tag on resources causes AKS deployment failures
Problem: a Deny on landingzones required every resource to have owner, and AKS failed when it created resources in the node resource group. What to do: switch to Deny on resource groups with Modify inheritance on resources. If you really need resource-level enforcement, run Audit for a month first to see which automatically created resources it would block. Limits: Modify can only fill in values. It cannot make types that do not support tags carry tags.
Case 3: name conflict — soft delete on Key Vault holds the name
Problem: when the environment was rebuilt, kv-myapp-prod-cc-01 reported “name already in use,” because the deleted vault was still in its soft-delete retention period. What to do: keep the instance number in the name. If you need to reuse the name, run az keyvault purge first (only where purge protection allows it). Limits: name conflicts for globally unique resources (Key Vaults, storage accounts) can come from other tenants.
Common errors and fixes
(RequestDisallowedByPolicy) Resource 'rg-…' was disallowed by policy. Policy: Require a tag on resource groups
Cause: the resource group create request has no costCenter tag, or the tag name is spelled differently. (Values are case-sensitive. Names are usually not case-sensitive in policy comparisons, but an empty value counts as missing.)
az policy assignment show --name lab-rg-req-costcenter --scope "$LZ" --query parameters
Fix: add the tag and create the resource again. Define the tag variables centrally in the pipeline template.
Modify works but the remediation task fails: The policy assignment's managed identity does not have permission … (AuthorizationFailed)
Cause: the assignment was created with the CLI, and the managed identity was not granted the roles listed in roleDefinitionIds.
az role assignment list --assignee "$PID" --all -o table
Fix: grant Contributor on the assignment scope (or a smaller role listed in the definition). After granting it, wait a few minutes before retrying the remediation task.
The storage account named st-myapp-prod is not valid / AccountNameInvalid
Cause: storage account names can only be 3–24 characters of lowercase letters and numbers.
Fix: use the compressed form stmyappprodcc01. Implement a separate rule for this type of resource in the IaC naming module.
InvalidPolicyAssignmentName / The policy assignment name '…' is invalid … at most 24 characters
Cause: the name of an assignment at management group scope can be up to 24 characters (64 for subscription scope and below).
Fix: shorten the name (for example, lab-inherit-costcenter is 22 characters). Put the descriptive information in --display-name.
1. List the resource groups in sub-lz-corp-myapp that are missing the costCenter tag.
az group list --query "[?tags.costCenter==null].name" -o tsv
2. Add workload=myapp to rg-lz-myapp-cc without deleting its existing tags.
RG_ID=$(az group show -n rg-lz-myapp-cc --query id -o tsv) az tag update --resource-id "$RG_ID" --operation Merge --tags workload=myapp
Finance requires “every resource must have costCenter, and the Deny must go live today.” The platform team worries about false positives. Propose a phased plan.
Week 1: Deny on resource groups (Require a tag on resource groups) and Modify on resources (Inherit if missing), and run a remediation task on existing resources. Weeks 2–4: additionally assign Require a tag on resources with enforcementMode set to DoNotEnforce (evaluate only, do not block). Use Resource Graph to count non-compliant resources by type, and identify types that are created automatically or do not support tags. After that, decide whether to enable Deny on resources, and handle exceptions with resourceSelectors or exemptions. Also turn on tag inheritance in Cost Management so the reports are usable right away.
Verified training videos
No verified English video that covers ALZ naming and tagging policy was found. (Candidate videos were checked through the YouTube oEmbed lookup, and those that did not pass are not listed.) Read the official documentation first, then use the storyboard script below.
Official documentation
- Define your naming convention · Abbreviation recommendations
- Naming rules and restrictions for Azure resources
- Use tags to organize your Azure resources · Assign policy definitions for tag compliance
Video storyboard script (about 90 seconds)
Visual: a row of messy resource names (test1, myvnet, Storage-Prod) each change into rg-lz-myapp-cc and vnet-spoke-myapp-cc.
Narration: A good name answers three questions: what is this, who owns it, and where is it. The CAF pattern is abbreviation, workload, environment, region, instance.
Visual: a storage account name input box. Hyphens are highlighted in red, and the length counter reaches 24.
Narration: Each resource type has its own rules. Storage account names can contain only lowercase letters and numbers, up to 24 characters, and they must be globally unique.
Visual: a resource group creation request hits a red Deny gate. Then a VM's NIC request passes through a blue Modify gate and gets a costCenter tag “stuck” on it.
Narration: Resource groups are guarded with Deny. Resources inherit tags from their resource group with Modify. This is strict, but it does not block automatically created resources by mistake.
Visual: a cost analysis chart clearly split into sections by costCenter.
Narration: Tags are not inherited by default, and casing must be consistent. Write the standard down, let policy enforce it, and costs can be separated clearly.
Module 3 · Azure Policy deep dive: definitions, initiatives, assignments, parameters, and scopes
- Read the structure of a policy definition:
mode(All / Indexed / resource provider modes),parameters, the conditions and aliases inpolicyRule.if, andthen.effectanddetails. - Write a custom definition and an initiative, and understand
policyDefinitionReferenceIdand parameter passing. - Know all the key properties of an assignment:
scope,notScopes,parameters,enforcementMode(Default / DoNotEnforce / Enroll),nonComplianceMessages,identity,definitionVersion,overrides, andresourceSelectors. - Remember the scope rule: a definition is stored in a MG or subscription and can be assigned only at that location or below. This is why ALZ keeps its custom definitions centralized on the intermediate root
alz.
What: four objects
| Object | Resource type | Stored where | Question it answers |
|---|---|---|---|
| Policy definition | Microsoft.Authorization/policyDefinitions | Built-in (global) or a specific MG / subscription | What condition to check? What to do on a match (effect)? |
| Initiative definition | …/policySetDefinitions | Same as above | Which definitions are managed together? How are parameters passed? |
| Assignment | …/policyAssignments | MG / subscription / resource group / resource | At which scope, with which parameters, and whether to enforce? |
| Exemption | …/policyExemptions | Exempted scope | Who is exempt from an assignment, and for how long (Module 5) |
Structure of a policy definition
{
"properties": {
"displayName": "LAB: Resource group names must start with rg-",
"mode": "All",
"metadata": { "category": "General", "version": "1.0.0" },
"parameters": {
"effect": { "type": "String", "allowedValues": ["Audit", "Deny", "Disabled"], "defaultValue": "Audit" },
"prefix": { "type": "String", "defaultValue": "rg-" }
},
"policyRule": {
"if": {
"allOf": [
{ "field": "type", "equals": "Microsoft.Resources/subscriptions/resourceGroups" },
{ "field": "name", "notLike": "[concat(parameters('prefix'), '*')]" }
]
},
"then": { "effect": "[parameters('effect')]" }
}
}
}
| Element | Key points |
|---|---|
mode | All: evaluates resource groups, subscriptions, and all resource types. Indexed: evaluates only resources that support tags and location (tag and location policies use this, to avoid misjudging types that do not support tags). Resource provider modes such as Microsoft.Kubernetes.Data, Microsoft.KeyVault.Data, and Microsoft.Network.Data are used for data-plane or component-level evaluation. |
parameters | Types (String, Array, Object, Boolean, Integer, Float, DateTime), allowedValues, defaultValue, metadata.strongType (shows a resource selector in the portal), metadata.assignPermissions (lets the portal grant the managed identity permissions on the scope the parameter points to). Each definition can have up to 20 parameters. Parameterizing the effect is a convention in the ALZ library. The same definition can be assigned as Audit or Deny on different MGs. |
| Conditions | equals, notEquals, like / notLike (one * wildcard), match (# for a digit, ? for a letter, . for any character), matchInsensitively, contains, in / notIn, containsKey, less / greater, exists; logical operators allOf, anyOf, and not; nesting limit of 512 conditions. |
| Fields | name, fullName, type, location, kind, id, tags, tags['costCenter'], identity.type, plus aliases (such as Microsoft.Storage/storageAccounts/supportsHttpsTrafficOnly). Array aliases [*] are used with count expressions. |
| Functions | A subset of ARM template functions, such as parameters(), field(), resourceGroup(), subscription(), concat(), and current() (inside count loops). |
Initiative
"policyDefinitions": [
{ "policyDefinitionReferenceId": "rgNaming",
"policyDefinitionId": "/providers/Microsoft.Management/managementGroups/alz/providers/Microsoft.Authorization/policyDefinitions/lab-deny-rg-naming",
"parameters": { "effect": { "value": "[parameters('namingEffect')]" } } },
{ "policyDefinitionReferenceId": "allowedLocations",
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e56962a6-4747-49cd-b67b-bf8b01975c4c",
"definitionVersion": "1.*.*",
"parameters": { "listOfAllowedLocations": { "value": "[parameters('allowedLocations')]" } } }
]
The initiative's own parameters (namingEffect, allowedLocations) are filled in at assignment time. They are passed to member definitions through [parameters('…')]. policyDefinitionReferenceId is each member's “ID” within the initiative. Exemptions, overrides, and non-compliance messages use it to find the specific member. Limits: each initiative can have up to 1,000 policies and 400 parameters.
Key assignment properties
| Property | Purpose | Notes |
|---|---|---|
scope / notScopes | Scope and excluded sub-scopes (up to 400) | Excluded resources are not evaluated and do not count toward compliance. This is different from an exemption. |
parameters | Assign values to definition or initiative parameters | Reuse the same definition on different MGs with different values |
enforcementMode | Default enforces. DoNotEnforce evaluates only and does not enforce (it does not write activity log entries and does not block, but you can still fix resources manually). Enroll enforces only on sub-scopes that were enrolled through “policy enrollment.” | Trial new policies with DoNotEnforce first. This is the safe rollout practice ALZ recommends. |
nonComplianceMessages | Custom message shown to users when a request is denied or non-compliant | Resource Manager mode only. The ALZ library uses {enforcementMode} as a placeholder, which is replaced with must or should at submission. |
identity + location | Managed identity for Modify / DINE remediation | An assignment can have only one identity. A system-assigned identity must specify a location (it cannot be global, and you cannot change it later). |
definitionVersion | Choose the version line of the definition. | 2.*.* automatically receives minor versions; 1.1.* pins the minor version. Patch versions are always received automatically. |
overrides | Override the effect (policyEffect) or the version (definitionVersion, built-in only) without changing the definition. | Each assignment allows up to 10 overrides, and each override allows up to 50 reference IDs. |
resourceSelectors | Applies only to some regions or resource types, for staged rollouts. | Up to 10 per assignment; kind can be resourceLocation, resourceType, or resourceWithoutLocation. |
Scope rules (the easiest place to make mistakes)
- Definition location ≥ assignment scope: a custom definition stored in
alzcan be assigned toalzand to all child MGs, subscriptions, and resource groups below it. A definition stored inlandingzonescannot be assigned toplatform. ALZ stores custom definitions and initiatives in the intermediate rootalz. - Inheritance: an assignment applies to all child MGs, subscriptions, resource groups, and resources within its scope. When multiple assignments overlap, the result is “the strictest one wins cumulatively.” There is no “child overrides parent” rule.
- Limits: each scope supports up to 500 policy definitions, 200 initiative definitions, and 200 assignments. A tenant supports up to 2,500 initiative definitions.
notScopes, an exemption, or overrides on the parent assignment. ② “If I change a definition, old assignments still run the old logic.” Assignments read the latest definition content on every evaluation (within the version line allowed by definitionVersion). ③ “DoNotEnforce equals disabled.” It still evaluates and reports compliance. It just does not block, modify, or auto-deploy. ④ “Every policy in an initiative must use the same effect.” Each member can be parameterized independently, or overridden individually with overrides.Relationship diagram: definition → initiative → assignment → scope
Sequence diagram: from assignment creation to effect
Interactive animation: scope resolver — which assignments constrain this resource?
Select a target resource. The animation moves up from resource → resource group → subscription → each level of management group to collect assignments, then removes the assignments excluded by notScopes to get the final list of effective assignments. The lab assignments are the lab-* ones created in this hour. The ALZ default assignment count is calculated for library 2026.11.0 (if your tenant has not deployed the ALZ default policies, look only at the lab assignments).
Core commands and parameters
| Command | Purpose | Key parameters / notes |
|---|---|---|
az policy definition create | Create a custom definition | --name --display-name --mode --rules --params --metadata --management-group|--subscription |
az policy set-definition create | Create an initiative | --definitions (JSON array file), --params, --definition-groups, --management-group |
az policy assignment create | Assign a definition or initiative | --policy or --policy-set-definition (for definitions in an MG, use the full ID), --scope, --not-scopes, --params, --enforcement-mode Default|DoNotEnforce |
az policy assignment update | Modify an assignment (for example, switch the enforcement mode) | --enforcement-mode, --not-scopes, --params |
az policy assignment non-compliance-message create | Add a non-compliance message | --message, --policy-definition-reference-id |
az policy assignment list --disable-scope-strict-match | List all assignments that apply to a scope (including inherited ones) | Without this parameter, only assignments made “exactly on this scope” are listed. |
az provider show -n <ns> --expand "resourceTypes/aliases" | Look up aliases | You can also use the Azure Policy extension for VS Code. |
1) Find aliases related to storage account HTTPS
az provider show --namespace Microsoft.Storage --expand "resourceTypes/aliases" \ --query "resourceTypes[?resourceType=='storageAccounts'].aliases[].name" -o tsv | grep -i https
Microsoft.Storage/storageAccounts/supportsHttpsTrafficOnly
2) List all effective assignments on a resource group (including inherited ones)
az policy assignment list --resource-group rg-lz-myapp-cc --disable-scope-strict-match \
--query "[].{name:name, scope:scope, mode:enforcementMode}" -o table
Name Scope Mode ---------------------- ------------------------------------------------------------- ------------ lab-rg-req-costcenter /providers/Microsoft.Management/managementGroups/landingzones Default lab-inherit-costcenter /providers/Microsoft.Management/managementGroups/landingzones Default lab-gov-baseline /providers/Microsoft.Management/managementGroups/landingzones DoNotEnforce
3) View the full structure of an ALZ assignment (when the ALZ default policies are deployed)
az policy assignment show --name Deny-MgmtPorts-Internet \
--scope /providers/Microsoft.Management/managementGroups/landingzones \
--query "{def:policyDefinitionId, mode:enforcementMode, msg:nonComplianceMessages[0].message}" -o json
{
"def": "/providers/Microsoft.Management/managementGroups/alz/providers/Microsoft.Authorization/policyDefinitions/Deny-MgmtPorts-From-Internet",
"mode": "Default",
"msg": "Management port access from the Internet must be blocked."
}
Note that the definition ID points to the intermediate root alz. The ALZ library uses the placeholder managementGroups/placeholder, and the deployment tool (alz provider / Bicep) replaces it with the actual intermediate root ID. The {enforcementMode} in non-compliance messages is also replaced at deployment with must (Default) or should (DoNotEnforce).
Lab: custom definition + initiative + DoNotEnforce dry run
alz, create the custom definition lab-deny-rg-naming and the initiative lab-gov-baseline (naming + allowed locations + env tag on resource groups). Assign it to landingzones and exclude local. Observe first with DoNotEnforce, then switch to Default. Cost: 0. Permissions: Resource Policy Contributor on alz.mkdir -p ~/alz-lab/policy && cd ~/alz-lab/policy
cat > rg-naming.rules.json <<'EOF'
{
"if": { "allOf": [
{ "field": "type", "equals": "Microsoft.Resources/subscriptions/resourceGroups" },
{ "field": "name", "notLike": "[concat(parameters('prefix'), '*')]" },
{ "field": "name", "notLike": "MC_*" },
{ "field": "name", "notLike": "NetworkWatcherRG" }
] },
"then": { "effect": "[parameters('effect')]" }
}
EOF
cat > rg-naming.params.json <<'EOF'
{ "effect": { "type": "String", "allowedValues": ["Audit","Deny","Disabled"], "defaultValue": "Audit" },
"prefix": { "type": "String", "defaultValue": "rg-" } }
EOF
az policy definition create --name lab-deny-rg-naming --management-group alz --mode All \
--display-name "LAB: Resource group names must start with rg-" \
--rules rg-naming.rules.json --params rg-naming.params.json \
--metadata category=General version=1.0.0
This excludes the MC_* resource groups that AKS creates automatically and the NetworkWatcherRG that Network Watcher creates automatically. That is why “the naming policy is only a fallback.”
ALZ_DEF=/providers/Microsoft.Management/managementGroups/alz/providers/Microsoft.Authorization/policyDefinitions
cat > baseline.defs.json <<EOF
[
{ "policyDefinitionReferenceId": "rgNaming", "policyDefinitionId": "$ALZ_DEF/lab-deny-rg-naming",
"parameters": { "effect": { "value": "[parameters('namingEffect')]" } } },
{ "policyDefinitionReferenceId": "rgLocations",
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988",
"parameters": { "listOfAllowedLocations": { "value": "[parameters('allowedLocations')]" } } },
{ "policyDefinitionReferenceId": "rgEnvTag",
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/96670d01-0a4d-4649-9c89-2d3abc0a5025",
"parameters": { "tagName": { "value": "env" } } }
]
EOF
cat > baseline.params.json <<'EOF'
{ "namingEffect": { "type": "String", "allowedValues": ["Audit","Deny","Disabled"], "defaultValue": "Audit" },
"allowedLocations": { "type": "Array", "defaultValue": ["canadacentral","canadaeast"] } }
EOF
az policy set-definition create --name lab-gov-baseline --management-group alz \
--display-name "LAB: Governance baseline" --definitions baseline.defs.json --params baseline.params.jsonLZ=/providers/Microsoft.Management/managementGroups/landingzones
az policy assignment create --name lab-gov-baseline --scope "$LZ" \
--policy-set-definition /providers/Microsoft.Management/managementGroups/alz/providers/Microsoft.Authorization/policySetDefinitions/lab-gov-baseline \
--params '{"namingEffect":{"value":"Deny"}}' \
--not-scopes /providers/Microsoft.Management/managementGroups/local \
--enforcement-mode DoNotEnforce
az policy assignment non-compliance-message create --name lab-gov-baseline --scope "$LZ" \
--policy-definition-reference-id rgNaming --message "Resource group names must start with rg-. See platform naming standard v1."az group create --name myapp-temp --location westus2 --tags costCenter=CC-1001
az policy state trigger-scan --resource-group myapp-temp
az policy state list --resource-group myapp-temp --filter "complianceState eq 'NonCompliant'" \
--query "[].{ref:policyDefinitionReferenceId, state:complianceState}" -o table
Ref State ---------------- ------------ rgNaming NonCompliant rgLocations NonCompliant rgEnvTag NonCompliant
Names, regions, and a missing env tag are all non-compliant. (Note: to evaluate the region of resource groups, use Allowed locations for resource groups (e765b5de-…, mode All). The common Allowed locations policy (e56962a6-…) uses Indexed mode and does not evaluate resource groups.) Because the mode is DoNotEnforce, the resource groups are still created. (Note: the costCenter policy lab-rg-req-costcenter is in Default mode, so the commands must include costCenter.)
az group delete --name myapp-temp --yes az policy assignment update --name lab-gov-baseline --scope "$LZ" --enforcement-mode Default # About 5 minutes later: az group create --name myapp-temp --location canadacentral --tags costCenter=CC-1001 env=dev
(RequestDisallowedByPolicy) Resource 'myapp-temp' was disallowed by policy. Reasons: 'Resource group names must start with rg-. See platform naming standard v1.'
lab-gov-baseline is used in Modules 7 and 8. For full course cleanup, see the cleanup script on the Capstone lab page.Case 1: the definition was stored in the wrong place, so the platform MG cannot reuse it
Problem: A team created a custom “allowed VM SKUs” definition on landingzones, then found it could not be assigned to platform. Approach: Following the ALZ convention, store all custom definitions and initiatives on the intermediate root alz. When migrating, first create the new definition on alz and update the assignment references, then delete the old definition. Limit: A definition that an assignment references cannot be deleted. You must first update or delete the assignment.
Case 2: use overrides to temporarily downgrade one member
Problem: A Deny in a guardrail initiative blocked the preview feature of a new service, and changing the initiative requires the full release process. Approach: Add overrides to the assignment (kind=policyEffect, value=Audit, with selectors that specify that member's referenceId). After the issue is fixed, remove the override. Limits: The override effect must be within the effects the definition allows. Each assignment allows up to 10 overrides.
Case 3: roll out by region with resourceSelectors
Problem: The new policy needs to take effect in the secondary region canadaeast for a week before it is rolled out further. Approach: Add resourceSelectors to the assignment (resourceLocation in [canadaeast]). After you review compliance and denial events, add canadacentral. Limit: You cannot use resourceLocation and resourceWithoutLocation in the same selector.
Common errors and fixes
(PolicyDefinitionNotFound) The policy definition '…' could not be found
Cause: The assignment was made to a scope outside where the definition is stored (for example, the definition is on landingzones and the assignment is to platform). Or, in the CLI, only a short name was given, and the CLI looks in the current subscription rather than in the MG.
az policy definition show --name lab-deny-rg-naming --management-group alz --query id -o tsv
Fix: Use the full definition ID, or move the definition to a higher MG.
(InvalidPolicyParameters) The policy parameters '…' do not match the parameters of the policy definition
Cause: The assignment's parameter name is misspelled, the type is wrong (for example, an array written as a string), or a required parameter without a default value is missing.
az policy set-definition show --name lab-gov-baseline --management-group alz --query "parameters" -o json
Fix: Rewrite --params using the definition's parameter names and types. Values must be wrapped in {"value": …}.
(InvalidPolicyRule) Failed to parse policy rule: 'The alias '…' is not valid'
Cause: The alias does not exist, the casing or path is wrong, or an unsupported field is used in Indexed or RP mode.
Fix: Find the correct alias with az provider show --expand "resourceTypes/aliases" or the VS Code policy extension.
(PolicyAssignmentScopeLimitExceeded / QuotaExceeded) … exceeds the maximum number of policy assignments (200)
Cause: More than 200 assignments on the same scope (many individual definitions, each assigned separately).
Fix: Combine related definitions into an initiative. An initiative counts as only one assignment. This is one reason ALZ makes heavy use of initiatives such as Enforce-GR-*.
1. Temporarily override the effect of the rgNaming member in the lab-gov-baseline assignment to Audit (hint: REST field overrides).
ID=$(az policy assignment show --name lab-gov-baseline --scope "$LZ" --query id -o tsv)
az rest --method patch --url "https://management.azure.com${ID}?api-version=2024-04-01" --body '{
"properties": { "overrides": [ { "kind": "policyEffect", "value": "Audit",
"selectors": [ { "kind": "policyDefinitionReferenceId", "in": ["rgNaming"] } ] } ] } }'You can also declare overrides directly in IaC. For whether the CLI provides a dedicated parameter, refer to az policy assignment update --help.
2. Find the names of all custom initiatives stored on alz.
az policy set-definition list --management-group alz --query "[?policyType=='Custom'].name" -o tsv
The security team assigned “Deny public IP” on alz, but the web app in online needs a public IP. The application team proposes assigning an Audit policy on online that allows public IPs to offset the Deny. Is this feasible? What should they do?
Not feasible. When multiple assignments overlap, the strictest result wins cumulatively, so a child-level Audit cannot offset a parent-level Deny. The correct approach is to adjust the parent assignment: add online to notScopes on the alz assignment, or assign this policy to corp instead (this is exactly why ALZ places Deny-Public-IP-On-NIC on corp by default). For an exception to a single resource, use an exemption.
Verified teaching videos
No verified English video that specifically explains the structure of policy definitions and assignment properties was found. (The YouTube oEmbed check could not verify a candidate.) The following are the official documentation and a video storyboard.
Official documentation
- Policy definition structure basics · Policy rule
- Initiative definition structure
- Policy assignment structure · Understand scope in Azure Policy
Video storyboard (about 90 seconds)
Visual: three cards, “Definition”, “Initiative”, and “Assignment”, flip open in turn, with arrows pointing from the definition to the initiative to the assignment.
Narration: The definition writes the rule, the initiative bundles the rules, and the assignment decides where it runs, with which parameters, and whether it is enforced.
Visual: in the JSON, if, allOf, field, and notLike are highlighted, and the effect in then is replaced by a parameter.
Narration: A condition is made of fields and operators. It is best to parameterize the effect, so the same definition can be assigned as Audit or Deny on different management groups.
Visual: on the management group tree, the definition is stored on alz, the assignment lands on landingzones, and local is greyed out as excluded.
Narration: The layer where a definition is stored determines where it can be assigned: that layer and everything below it. Scopes excluded by notScopes are not evaluated.
Visual: the switch flips from DoNotEnforce to Default, and a red deny gate drops down.
Narration: Test a new policy in evaluation-only mode first, understand its impact, and then switch it to enforcement. This is the safest way to release.
Module 4 · Effects: Deny, Audit, Modify, DeployIfNotExists, and DenyAction
- Describe the 11 effects: addToNetworkGroup, append, audit, auditIfNotExists, deny, denyAction, deployIfNotExists, disabled, manual, modify, and mutate, and the scenarios each one fits.
- Describe how a create or update request is evaluated, in the official order: disabled → append and modify → deny → audit → manual → auditIfNotExists → denyAction. After the resource provider returns success, auditIfNotExists and deployIfNotExists are evaluated.
- Explain why “modify before deny” and “deny before audit,” as well as DINE's
evaluationDelay(default 10 minutes) and managed identity. - Use DenyAction to prevent accidental deletion of critical resources, and know its boundaries (subscription deletion is not blocked, deleting a parent resource cascades to its child resources, and
cascadeBehaviors).
What: overview of the 11 effects
| Effect | When it applies | What it does | Example in ALZ |
|---|---|---|---|
disabled | Checked first | Rule is not evaluated (often used to turn a parameterized rule off) | Many ALZ definitions allow Disabled as an effect parameter |
append | At request time, before the RP | Append fields to the request (legacy approach) | For tag management, the official recommendation is to use modify instead |
modify | At request time, before the RP; existing resources → remediation task | Add, replace, or remove tags. Replace can change the value of an alias, and modify the identity.type of a VM or VMSS. Requires a managed identity. | Enable-DDoS-VNET (connectivity, landingzones) |
deny | At request time, before the RP | Returns 403 RequestDisallowedByPolicy; existing resources are marked non-compliant | Deny-MgmtPorts-Internet, Deny-Storage-http, Deny-Public-IP-On-NIC |
audit | At request time and in the evaluation cycle | Writes an activity log warning and marks the resource non-compliant, without blocking it | Audit-ResourceRGLocation |
manual | Attested manually | For controls that cannot be determined automatically; defaults to Unknown | Compliance framework initiatives |
auditIfNotExists | After the RP succeeds | Checks whether “related resources” exist or meet a condition. If they do not exist, the resource is marked non-compliant. | Audit-PeDnsZones |
deployIfNotExists | After the RP succeeds (evaluationDelay); existing resources → remediation task | If related resources do not exist, runs an ARM template deployment using the managed identity | Deploy-Diag-LogsCat, Deploy-Private-DNS-Zones, Deploy-VM-Backup |
denyAction | At request time (last in the list) | Blocks a specified action. Currently only delete is supported. The resource status shows Protected. | DenyAction-DeleteUAMIAMA (platform) |
addToNetworkGroup | Used by Azure Virtual Network Manager | Dynamically adds VNets that meet the condition to a network group | Hour 4 AVNM |
mutate | AKS admission (Microsoft.Kubernetes.Data) | Modifies Kubernetes objects | AKS course |
How: evaluation order (official)
- Azure Policy lists all assignments that apply to the resource and evaluates them one by one (overlapping assignments = the strictest result wins cumulatively).
- disabled is checked first, to decide whether this rule needs to be evaluated at all.
- append and modify: these can change the request content, so they come before deny. For example, after modify adds costCenter, a “missing costCenter” deny will no longer trigger. Resource Manager mode only.
- deny: before audit, so that the same non-compliant request is not both rejected and logged as an audit.
- audit → manual → auditIfNotExists → denyAction (last).
- The request is handed to the resource provider. Only after the RP returns success do auditIfNotExists and deployIfNotExists check related resources and decide whether to log non-compliance or deploy.
Note: PATCH requests that change only tags evaluate only the policies whose conditions check tags. Resources under Microsoft.Resources other than subscriptions and resource groups are not evaluated. Resource provider mode (such as the Key Vault data plane) is evaluated by the RP itself, which reports the result.
Key properties of DeployIfNotExists
| Property | Meaning |
|---|---|
type / name | The “related resource” to look for, for example Microsoft.Insights/diagnosticSettings |
existenceCondition | The condition a related resource must meet to count as compliant. If any related resource meets it, no deployment occurs. |
existenceScope / resourceGroupName | Whether to look for related resources within the resource group or across the whole subscription |
evaluationDelay | AfterProvisioning, AfterProvisioningSuccess, AfterProvisioningFailure, or an ISO 8601 duration from 0 to 360 minutes. Default PT10M |
roleDefinitionIds | Roles required by the managed identity (required) |
deploymentScope / deployment | Deployment at resource group or subscription level; full ARM template (nested templates supported, linked templates not supported) |
Note the division of identities: when evaluating existence conditions, the requesting principal's identity is used to read related resources. When executing the deployment, the assignment's managed identity is used.
DenyAction: preventing accidental deletion
"then": {
"effect": "denyAction",
"details": {
"actionNames": [ "delete" ],
"cascadeBehaviors": { "resourceGroup": "deny" }
}
}
- Returns 403. The only action currently supported is
delete. cascadeBehaviors.resourceGroup: supported only in definitions with Indexed mode. Values are allow / deny, default deny. Deleting a resource group that contains protected resources is also blocked.- Not blocked: resource removal during subscription deletion, and child and extension resources removed along with a deleted parent resource (for example, deleting a storage account also removes its diagnostic settings).
- To prevent lockout, resource types such as
policyAssignments,denyAssignments,deploymentStacks,subscriptions, andlocksare not subject to denyAction. - Difference from resource locks: a lock is set on each individual resource and can be removed by anyone with permission. denyAction is deployed centrally by policy at the MG level, and can match a batch of resources by type, name, or tag.
Pipeline diagram: policy evaluation of a single PUT request
Decision diagram: which effect to choose
Core animation: the request evaluation pipeline through ARM and the policy engine
Select a scenario, then press “Play” or “Next.” Each step highlights a stage of the evaluation pipeline. The log below shows the result ARM returns or the policy event in the activity log. You can switch to “DoNotEnforce” to see how the same request differs in evaluation-only mode.
Core commands and parameters
| Command | Purpose | Key parameters / notes |
|---|---|---|
az policy event list | View policy events (deny, audit, modify, and so on) | --resource-group, --from, --filter |
az monitor activity-log list | Policy operations in the activity log | Operation name Microsoft.Authorization/policies/<effect>/action |
az policy definition show | View the allowed values of an effect parameter | --query parameters.effect.allowedValues |
az deployment group list | View deployments created by DINE / remediation tasks | DINE deployment names usually start with PolicyDeployment_ |
az resource delete | Test DenyAction | When blocked, returns 403 with policy information |
1) Test Deny: a storage account that allows HTTP (requires Deny-Storage-http or this hour's lab assignment)
az storage account create --name stmyapphttp$RANDOM --resource-group rg-lz-myapp-cc \ --location canadacentral --sku Standard_LRS --https-only false
(RequestDisallowedByPolicy) Resource 'stmyapphttp12345' was disallowed by policy. Reasons: 'Storage accounts must use HTTPS.'.
See error details for policy resource IDs.
Code: RequestDisallowedByPolicy
Target: stmyapphttp12345
Additional Information:
Type: PolicyViolation
Info: {
"policyAssignmentName": "lab-deny-st-http",
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/404c3081-a854-4457-ae30-26a93ef643f9",
"policyDefinitionEffect": "Deny"
}
2) View recent policy events
az policy event list --resource-group rg-lz-myapp-cc --from "$(date -u -d '-1 hour' +%Y-%m-%dT%H:%M:%SZ)" \
--query "[].{time:timestamp, assignment:policyAssignmentName, effect:policyDefinitionAction, state:complianceState}" -o table
Time Assignment Effect State -------------------- ---------------------- ------- ------------ 2026-11-18T10:21:07Z lab-deny-st-http deny NonCompliant 2026-11-18T10:20:31Z lab-inherit-costcenter modify Compliant
3) Test DenyAction
az resource delete --ids "$(az storage account show -n $ST -g rg-lz-myapp-cc --query id -o tsv)"
(RequestDisallowedByPolicy) Resource 'stmyappprodcc12345' was disallowed by policy. Policy: LAB: Protect tagged resources from deletion (denyAction)
Lab: Deny blocking, Modify rewriting, DenyAction preventing deletion
landingzones, assign the built-in “Secure transfer to storage accounts should be enabled” (404c3081-…, effect parameter Deny, which uses the same definition as ALZ's Deny-Storage-http). Then use an ALZ-style denyAction definition to protect the storage account tagged protect=true. Cost: one empty storage account, almost 0. Risk: denyAction will block you from deleting the lab resource group. Be sure to delete the assignment before cleanup.Deny-Storage-http already exists on landingzones, so you can skip this step and test directly)
LZ=/providers/Microsoft.Management/managementGroups/landingzones
az policy assignment create --name lab-deny-st-http --scope "$LZ" \
--display-name "LAB: Storage accounts must use HTTPS" \
--policy 404c3081-a854-4457-ae30-26a93ef643f9 --params '{"effect":{"value":"Deny"}}'
az policy assignment non-compliance-message create --name lab-deny-st-http --scope "$LZ" \
--message "Storage accounts must use HTTPS."
About 5 minutes later, run item 1 on the Commands tab. You should get a 403.az policy event list to see the evaluation order.cd ~/alz-lab/policy
cat > protect.rules.json <<'EOF'
{
"if": { "allOf": [
{ "field": "type", "equals": "Microsoft.Storage/storageAccounts" },
{ "field": "tags['protect']", "equals": "true" }
] },
"then": { "effect": "denyAction",
"details": { "actionNames": ["delete"], "cascadeBehaviors": { "resourceGroup": "deny" } } }
}
EOF
az policy definition create --name lab-protect-delete --management-group alz --mode Indexed \
--display-name "LAB: Protect tagged resources from deletion (denyAction)" --rules protect.rules.json
az policy assignment create --name lab-protect-delete --scope "$LZ" \
--policy /providers/Microsoft.Management/managementGroups/alz/providers/Microsoft.Authorization/policyDefinitions/lab-protect-delete
az tag update --resource-id "$(az storage account show -n $ST -g rg-lz-myapp-cc --query id -o tsv)" \
--operation Merge --tags protect=truerg-lz-myapp-cc is also blocked (cascadeBehaviors=deny). On the compliance page, the storage account shows as Protected.
az group delete --name rg-lz-myapp-cc --yes --no-wait; sleep 20 az group show --name rg-lz-myapp-cc --query properties.provisioningState -o tsv
Succeeded
The resource group still exists (the deletion was blocked by policy, and the asynchronous delete operation failed). You can see the specific error, with a denyAction record, in the activity log.
az policy assignment delete --name lab-protect-delete --scope "$LZ" az tag update --resource-id "$(az storage account show -n $ST -g rg-lz-myapp-cc --query id -o tsv)" --operation Delete --tags protect=true # Keep lab-deny-st-http until the Capstone lab ends
Case 1: after upgrading to Deny, every routine change to old resources fails
Problem: The platform team changed the minimum TLS version policy from Audit to Deny. The next day, when application teams added tags to old storage accounts, the requests were rejected (the whole PUT request is evaluated). Approach: Before enabling Deny, use Audit / DoNotEnforce to produce a list of existing non-compliant resources. Fix the existing resources with modify or remediation tasks first, then switch to Deny. When switching, publish a non-compliance message that explains how to fix the issue. Limit: A PATCH request that only changes tags evaluates only the policies that include a tags condition, but many tools send a full PUT.
Case 2: DINE deployed diagnostic settings, but sent the logs to the wrong workspace
Problem: The workspace parameter of Deploy-Diag-LogsCat was not substituted during templating, so it pointed to a workspace that does not exist, and all remediation tasks failed. Approach: ALZ uses policy_default_values to set parameters such as the Log Analytics workspace uniformly (Module 6). After deployment, check one parameter of a DINE deployment. Limit: Changing an assignment parameter does not automatically redeploy existing diagnostic settings. You need a new remediation task (Module 5).
Case 3: DenyAction protects the user-assigned managed identity used by AMA
Problem: Someone cleaned up a managed identity that “looked unused” and deleted the one used by Azure Monitor Agent, so a whole batch of VMs stopped reporting logs. Approach: ALZ assigns DenyAction-DeleteUAMIAMA on platform by default (definition DenyAction-DeleteResources, with parameters for resource type and name). Limit: It does not protect against deleting the parent subscription of the resource group, or bypassing it by moving resources. RBAC least privilege is still required.
Common errors and fixes
(RequestDisallowedByPolicy) Resource '…' was disallowed by policy. Reasons: '…'. See error details for policy resource IDs.
Cause: A deny (or a modify with conflictEffect=deny) matched. The error details include policyAssignmentName and policyDefinitionId.
az policy assignment list --disable-scope-strict-match --query "[?name=='<assignment>'].{scope:scope,mode:enforcementMode}"
az policy definition show --name <definition> --query policyRule
Fix: Change the request according to the non-compliance message. If the business genuinely needs it, request an exemption (Module 5). Do not delete the assignment directly.
DINE resource has been NonCompliant for a long time, with no deployment
Cause: Existing resources are only marked non-compliant and are not deployed automatically. Or new resources are still within evaluationDelay (default 10 minutes). Or the managed identity lacks permissions, so the deployment fails.
az policy remediation list --query "[].{name:name,state:provisioningState}" -o table
az deployment group list -g <rg> --query "[?starts_with(name,'PolicyDeployment')].{n:name,s:properties.provisioningState}" -o table
Fix: Create a remediation task. Check the managed identity's role assignments.
(RequestDisallowedByPolicy) … policy 'Modify' conflict / The request was denied because of a conflict between modify policies
Cause: Two modify definitions change the same property, and both have conflictEffect set to deny (the default). The request is treated as a conflict and rejected. Existing resources show as Conflicting.
Fix: Merge them into one definition, or set conflictEffect to audit on one of them. For tag inheritance policies, avoid using both add and addOrReplace to modify the same tag.
Deleting resource group failed: … was disallowed by policy (denyAction)
Cause: The resource group contains resources protected by denyAction, and cascadeBehaviors.resourceGroup is deny (the default).
az policy state list --resource-group <rg> --filter "complianceState eq 'Protected'" --query "[].resourceId" -o tsv
Fix: First confirm that you really want to delete it. Then request an exemption, or remove the protection tag or delete the assignment. Do not temporarily elevate permissions to bypass this.
1. View the allowed effect values and the default effect of definition 404c3081-…
az policy definition show --name 404c3081-a854-4457-ae30-26a93ef643f9 \
--query "{allowed:parameters.effect.allowedValues, default:parameters.effect.defaultValue}"2. List the deployments in rg-lz-myapp-cc that were created by DINE / remediation tasks.
az deployment group list -g rg-lz-myapp-cc --query "[?starts_with(name,'PolicyDeployment')].name" -o tsv
landingzones has both: Modify (inherits costCenter from the resource group when it is missing) and Deny (resources must have costCenter). The resource group has costCenter=CC-1001. A user creates a Key Vault with no tags at all. What happens? What if the resource group itself has no costCenter either?
Case 1: In the evaluation order, modify runs before deny, so the request gets costCenter=CC-1001 added, the deny condition no longer holds, and creation succeeds. Case 2: modify reads an empty resource group tag and cannot fill in a valid value (the inheritance policy's condition is not met, or no valid value can be filled in), so deny matches and returns 403. This is exactly the point of combining “Deny on the resource group + Modify on the resource”: the resource group level guarantees there is always a value to inherit.
Verified teaching videos
No verified English video that specifically explains the evaluation order of Azure Policy effects was found. The following are the official documentation and a video storyboard.
Official documentation
- Azure Policy definitions effect basics (including evaluation order)
- denyAction · modify · deployIfNotExists
Video storyboard (about 100 seconds)
Visual: a PUT request envelope enters ARM, facing seven gates in a row: disabled, modify, deny, audit, manual, AINE, and denyAction.
Narration: Before the request reaches the resource provider, the policy engine evaluates every applicable assignment in a fixed order.
Visual: the modify gate attaches a costCenter tag to the envelope. Then the deny gate checks the tag and gives a green light.
Narration: modify comes before deny because the rewritten request may already be compliant. deny comes before audit, so the same request is not both rejected and audited.
Visual: another envelope has https set to false. The deny gate drops, and a red 403 is returned.
Narration: When deny matches, the request ends immediately, and the later steps are not executed.
Visual: the resource is created successfully, a timer counts down 10 minutes, and the DINE robot deploys diagnostic settings using the managed identity. Meanwhile, a DELETE request is blocked by the denyAction shield.
Narration: After a successful request, DINE waits for the evaluation delay before deploying companion resources. denyAction, on the other hand, specifically blocks deletion to protect critical resources.
Module 5 · Remediation tasks, managed identities, and exemptions
- Explain the scope of remediation tasks (only modify and deployIfNotExists), their parameters (resourceCount, parallelDeployments, failureThreshold, resourceDiscoveryMode, location filters), and their limits.
- Configure a system-assigned or user-assigned managed identity for an assignment, and grant it access by
roleDefinitionIds. Understand that “evaluation uses the caller's identity, and deployment uses the assignment's identity.” - Create an exemption: category Waiver / Mitigated,
expiresOn, exempting only some members of an initiative, and metadata that records the approval. Know the permissions the creator needs. - Distinguish exclusion (notScopes) from exemption. Know that
assignmentScopeValidation: DoNotValidateis used to exempt resources in advance before a subscription migration.
What: remediation task
New or updated resources are handled automatically at request time by modify / DINE. Existing non-compliant resources found in the evaluation cycle are not changed automatically. You must create a remediation task (Microsoft.PolicyInsights/remediations). A remediation task performs a modify operation or a DINE template deployment on the selected resources, using the assignment's managed identity.
| Parameter | Default / range | Description |
|---|---|---|
policyAssignmentId | Required | Full ID of the assignment (definition or initiative assignment) |
policyDefinitionReferenceId | Required for initiative assignments | A remediation task can remediate only one member of an initiative |
resourceCount | Default 500, maximum 50,000 | Maximum number of non-compliant resources to remediate in this run |
parallelDeployments | Default 10, range 1–30 | Number of deployments to run at the same time. Up to 100 remediation tasks can run in parallel for the same definition / reference. |
failureThreshold.percentage | Default 100% (that is, continue even when failures occur) | The task fails if the failure ratio exceeds the threshold |
resourceDiscoveryMode | ExistingNonCompliant (default) | ReEvaluateCompliance: rescan this assignment first, then remediate the non-compliant resources found |
| Filter | Location | Remediate only resources in certain regions (for example, fix canadaeast first) |
Status values: Running, Canceled, Cancelling, Failed, Complete, Succeeded. The task also has a deploymentSummary (total, succeeded, failed). Parameters cannot be changed after a task is created. Azure Policy deletes the task resource 60 days after it was last modified.
Managed identities and authorization
- Each assignment can be linked to one managed identity (system-assigned or user-assigned), but that identity can have multiple roles.
- A system-assigned identity requires a
location(it cannot be global, and it cannot be changed later). The location does not affect how it works in Azure Policy. - When you create an assignment in the portal, access is granted automatically based on
roleDefinitionIdsin the definition. With CLI / SDK / IaC, you must create the role assignments yourself. If you change a definition'sroleDefinitionIds, you must grant the access manually, even in the portal. - A typical case that needs extra access: a DINE deployment targets something outside the assignment scope (for example, a private endpoint in corp must write a DNS record into the private DNS zone in the connectivity subscription). ALZ's
Deploy-Private-DNS-Zonestherefore needs access granted on the connectivity subscription. - Benefits of user-assigned identities: multiple assignments share one identity, roles are managed centrally, and access can be granted in advance (common in large ALZ deployments, and supported by avm-ptn-alz). The cost: the identity has broader permissions and must be strictly protected (the DenyAction approach from Module 4 applies here too).
What: exemption
{
"properties": {
"policyAssignmentId": "/providers/Microsoft.Management/managementGroups/landingzones/providers/Microsoft.Authorization/policyAssignments/lab-gov-baseline",
"policyDefinitionReferenceId": [ "rgNaming" ],
"exemptionCategory": "Waiver",
"expiresOn": "2026-12-31T23:59:00.0000000Z",
"displayName": "Legacy RG naming until migration",
"metadata": { "requestedBy": "team-myapp", "approvedBy": "platform-ccoe", "ticketRef": "CHG-2026-1182" },
"assignmentScopeValidation": "Default"
}
}
| Property | Description |
|---|---|
exemptionCategory | Mitigated: the policy's intent is already met in another way (for example, a third-party WAF replaces the App Gateway WAF). Waiver: non-compliance is temporarily accepted (a risk accepted with an expiry). |
expiresOn | After expiry, the exemption is not deleted. The object is kept for the record, but no longer applies. |
policyDefinitionReferenceId | Exempts only some members of an initiative (an array) |
resourceSelectors | Narrows the exemption by location or type. It also supports identity-based exemptions with userPrincipalId / groupPrincipalId. |
assignmentScopeValidation | (Preview) DoNotValidate allows an exemption to be created outside the assignment scope. This is used to exempt resources in advance before a subscription moves into a new MG, so the move is not blocked by policy. |
| Permissions | You need Microsoft.Authorization/policyExemptions/write on the scope being exempted, and exempt/Action on the target assignment. The built-in Resource Policy Contributor and Security Admin roles have read and write access. |
Exclusion vs exemption
| Exclusion (notScopes) | Exemption (exemption) | |
|---|---|---|
| Where it is configured | On the assignment itself (owned by the assignment owner) | A separate resource attached to the exempted scope |
| Whether it counts toward compliance | Not evaluated, not counted | Counted, with status Exempt. It also has complianceSubState, which shows “what the state would be without the exemption.” |
| Granularity | Whole assignment | Can target only some members of an initiative |
| Expiry and approval information | None | expiresOn, metadata |
| Typical use | Structural scope division (this type of workload never applies) | Temporary or mitigated exception for individual resources |
exempt/Action on the target assignment. This prevents application teams from giving themselves a backdoor. ④ “Using notScopes is simpler for handling exceptions.” It makes exceptions invisible, leaves them out of compliance reporting, and gives them no expiry, so they cannot be explained during an audit.Sequence diagram: how remediation tasks work
Comparison diagram: exclusion vs exemption
Interactive animation: remediation task execution simulator
Set the parameters and press Play. The simulator processes resourceCount non-compliant resources in batches of parallelDeployments. Checking “managed identity lacks role” makes some deployments fail with 403. Observe how failureThreshold decides the final status of the task.
Core commands and parameters
| Command | Purpose | Key parameters / notes |
|---|---|---|
az policy remediation create | Create a remediation task | --name --policy-assignment (ID or name), --definition-reference-id, --management-group|--resource-group, --resource-discovery-mode ExistingNonCompliant|ReEvaluateCompliance, --resource-count, --parallel-deployments, --failure-threshold, --location-filters |
az policy remediation show / list | View status and summary | --query "{state:provisioningState, summary:deploymentStatus}" |
az policy remediation deployment list | Deployment result for each resource | The failure reason is in the error field |
az policy remediation cancel | Cancel a running task | Completed deployments are not rolled back |
az policy assignment identity assign | Add a managed identity to an existing assignment | --system-assigned or --user-assigned <id>, --identity-scope --role |
az policy exemption create | Create an exemption | --name --policy-assignment --exemption-category Waiver|Mitigated --expires-on --policy-definition-reference-ids --scope|--resource-group --metadata |
az policy exemption list | List exemptions | --disable-scope-strict-match lists inherited exemptions |
1) Remediate the existing resources for lab-inherit-costcenter on landingzones
az policy remediation create --name rem-costcenter-$(date +%m%d) --management-group landingzones \
--policy-assignment /providers/Microsoft.Management/managementGroups/landingzones/providers/Microsoft.Authorization/policyAssignments/lab-inherit-costcenter \
--resource-discovery-mode ExistingNonCompliant --parallel-deployments 10 --failure-threshold 0.2
az policy remediation show --name rem-costcenter-$(date +%m%d) --management-group landingzones \
--query "{state:provisioningState, summary:deploymentStatus}" -o json
{
"state": "Succeeded",
"summary": { "failedDeployments": 0, "successfulDeployments": 3, "totalDeployments": 3 }
}
When creating a remediation task at the MG scope, use --management-group. You can also create it at the subscription or resource group scope (which remediates only resources in that scope). In the CLI, the failure threshold parameter is expressed as a decimal ratio. Refer to az policy remediation create --help for details.
2) Create a time-limited exemption for the storage account (targeting only lab-deny-st-http)
ASSIGN=/providers/Microsoft.Management/managementGroups/landingzones/providers/Microsoft.Authorization/policyAssignments/lab-deny-st-http ST_ID=$(az storage account show -n $ST -g rg-lz-myapp-cc --query id -o tsv) az policy exemption create --name lab-st-http-waiver --scope "$ST_ID" \ --policy-assignment "$ASSIGN" --exemption-category Waiver \ --expires-on "$(date -u -d '+7 days' +%Y-%m-%dT%H:%M:%SZ)" \ --display-name "Legacy client needs HTTP until 2026-11-25" \ --metadata requestedBy=team-myapp approvedBy=platform-ccoe ticketRef=CHG-2026-1182
{
"exemptionCategory": "Waiver",
"expiresOn": "2026-11-25T10:30:00+00:00",
"name": "lab-st-http-waiver",
"policyAssignmentId": "/providers/Microsoft.Management/managementGroups/landingzones/providers/Microsoft.Authorization/policyAssignments/lab-deny-st-http"
}
3) List exemptions expiring within 30 days (routine governance check)
az graph query -q "policyresources | where type == 'microsoft.authorization/policyexemptions' | extend expires = todatetime(properties.expiresOn), category = tostring(properties.exemptionCategory) | where isnotnull(expires) and expires < now(30d) | project name, category, expires, scope = tostring(split(id, '/providers/Microsoft.Authorization/policyExemptions/')[0])" -o table
Lab: fix existing tags + create a time-limited exemption
landingzones. Creating an exemption also requires exempt/Action on the assignment (Owner has it).LZ=/providers/Microsoft.Management/managementGroups/landingzones
az policy assignment update --name lab-inherit-costcenter --scope "$LZ" --enforcement-mode DoNotEnforce
sleep 300 # Wait for the assignment change to take effect (about 5 minutes)
ST2=stmyapplegacy$RANDOM
az storage account create -n $ST2 -g rg-lz-myapp-cc -l canadacentral --sku Standard_LRS
az storage account show -n $ST2 -g rg-lz-myapp-cc --query tags # Expected: {} (or null)
az policy assignment update --name lab-inherit-costcenter --scope "$LZ" --enforcement-mode Defaultaz policy state trigger-scan --resource-group rg-lz-myapp-cc az policy state list --resource-group rg-lz-myapp-cc \ --filter "policyAssignmentName eq 'lab-inherit-costcenter' and complianceState eq 'NonCompliant'" \ --query "[].resourceId" -o tsv
/subscriptions/…/resourceGroups/rg-lz-myapp-cc/providers/Microsoft.Storage/storageAccounts/stmyapplegacy23817
--management-group landingzones with --resource-group rg-lz-myapp-cc). When complete:
az storage account show -n $ST2 -g rg-lz-myapp-cc --query tags
{ "costCenter": "CC-1001" }az storage account update -n $ST -g rg-lz-myapp-cc --https-only false # This should now succeed
az policy state list --resource-id "$ST_ID" --filter "policyAssignmentName eq 'lab-deny-st-http'" \
--query "[].{state:complianceState}" -o table
State ------ Exempt
az storage account update -n $ST -g rg-lz-myapp-cc --https-only true az policy exemption delete --name lab-st-http-waiver --scope "$ST_ID" az storage account delete -n $ST2 -g rg-lz-myapp-cc --yes
Case 1: all Private DNS zone DINE remediations fail with 403
Problem: Private endpoints in corp should automatically register records in the private DNS zone in the connectivity subscription through Deploy-Private-DNS-Zones, but all remediation tasks failed. Root cause: The assignment is on corp, and the managed identity has permissions only in corp, while the target DNS zone is in the connectivity subscription (outside the assignment scope). Approach: Grant Private DNS Zone Contributor to the assignment's identity on the rg-alz-dns-cc resource group (avm-ptn-alz handles this case through an extra role assignment). Limit: After changing the access, you must rerun the remediation task.
Case 2: an exemption became a “permanent backdoor”
Problem: An audit found 300 exemptions. 200 of them had no expiry and no ticket number. Approach: The policy requires every Waiver to set an expiresOn no more than 90 days out and to record the ticket number in metadata. A weekly Resource Graph report lists exemptions that are expiring or have no expiry. Only the platform team holds exempt/Action. Limit: A Mitigated exemption can have no expiry, but the mitigation still needs to be reviewed regularly for effectiveness.
Case 3: exempt a subscription in advance before moving it into corp
Problem: An acquired subscription has NICs with public IPs. Moving it into corp would inherit Deny-Public-IP-On-NIC, and then any update to those NICs would be rejected. Approach: Create an exemption against the corp assignment at the subscription's current location, and set assignmentScopeValidation: DoNotValidate (preview). Move the subscription, then delete the exemption after the planned remediation. Limit: This is a preview feature. Confirm its support status before using it in production.
Common errors and fixes
Remediation task state Failed — deployment error: The client '…' with object id '…' does not have authorization to perform action '…/write' (AuthorizationFailed)
Cause: The assignment's managed identity lacks a role in roleDefinitionIds, or the target resource is outside the assignment scope.
PID=$(az policy assignment show --name <assignment> --scope "$LZ" --query identity.principalId -o tsv) az role assignment list --assignee "$PID" --all -o table az policy remediation deployment list --name <task> --management-group landingzones --query "[?status=='Failed'].error.message" -o tsv
Fix: Grant the required role at the correct scope, wait a few minutes (Entra replication), then rerun the remediation task.
(InvalidCreateRemediationRequest) … policyDefinitionReferenceId is required for initiative assignments
Cause: The remediation task was created for an initiative assignment without specifying a member.
Fix: Add --definition-reference-id <refId>. If an initiative has multiple DINE members, create a separate task for each member.
(AuthorizationFailed) … does not have authorization to perform action 'Microsoft.Authorization/policyAssignments/exempt/action'
Cause: Creating an exemption requires the exempt permission on the target assignment. A resource group Owner does not necessarily have this permission on the MG where the assignment lives.
Fix: Have the platform team create it through the exemption process, or grant a custom role that includes this action to the approving group.
Remediation task Succeeded, but the resource still shows NonCompliant
Cause: Compliance data is updated only at the next evaluation. Or the corrected value still does not meet the condition (for example, the resource group itself has no costCenter, so the inherited value is empty).
az policy state trigger-scan --resource-group rg-lz-myapp-cc az group show -n rg-lz-myapp-cc --query tags
Fix: Trigger an on-demand scan. Fix the upstream data (resource group tags) first, then remediate.
1. For the hypothetical DINE member diagSettings of initiative assignment lab-gov-baseline, create a remediation task that remediates only resources in canadaeast, and rescan first.
az policy remediation create --name rem-diag-ce --management-group landingzones \ --policy-assignment /providers/Microsoft.Management/managementGroups/landingzones/providers/Microsoft.Authorization/policyAssignments/lab-gov-baseline \ --definition-reference-id diagSettings --location-filters canadaeast \ --resource-discovery-mode ReEvaluateCompliance
2. List all Waivers on landingzones that have no expiry date set.
az graph query -q "policyresources | where type == 'microsoft.authorization/policyexemptions' | where properties.exemptionCategory =~ 'Waiver' and isnull(properties.expiresOn) | project name, id" --management-groups landingzones -o table
An application team protects its web app with a third-party WAF, so it does not comply with ALZ's Audit-AppGW-WAF. They request adding their subscription to the assignment's notScopes. How do you handle this?
Do not change notScopes. This is an exception for one workload, and the policy's intent (WAF protection) is already met in another way. Create a Mitigated-category exemption scoped to that subscription or its relevant resource group. In metadata, record the alternative solution and the approval ticket, and schedule a regular review (for example, every 6 months). This way, the subscription shows as Exempt in the compliance report, and the reason can be traced during an audit. If the third-party WAF is removed later, deleting the exemption restores evaluation.
Verified teaching videos
No verified English video that specifically explains remediation tasks and exemptions was found. The following are the official documentation and a video storyboard.
Official documentation
- Remediate non-compliant resources · Remediation task structure
- Policy exemption structure · Scope: excluded vs exempt
Video storyboard (about 90 seconds)
Visual: on the compliance dashboard, a row of red existing resources, with the caption “evaluation only marks, it does not modify.”
Narration: modify and DINE handle only new resources automatically at request time. Existing resources need remediation tasks.
Visual: the remediation task splits 24 resources into batches of 10. Managed identity badges are stamped one by one and turn green. Two cross-subscription resources turn red with 403.
Narration: Remediation tasks use the assignment's managed identity. When you create assignments from the command line, remember to grant it the roles defined in the definition.
Visual: an exemption form showing Waiver, the expiry date, and the ticket number. The resource status changes from red to grey Exempt.
Narration: Exemptions have a category, an expiry, and an approval record, and they count toward compliance statistics. When they expire, they are not deleted. They just stop applying.
Visual: notScopes “cuts out” a whole area, and it disappears from the report. An exemption stays visible in the report.
Narration: Use exclusions for structural scope division and exemptions for individual exceptions. Do not use exclusions to hide exceptions.
Module 6 · The ALZ policy library and version management
- Describe the directory structure of
platform/alzin Azure-Landing-Zones-Library: policy definitions, initiatives, assignments, role definitions, archetypes, architecture, and the default-values file. - Understand how resolution works: “architecture → each MG's archetype → a set of assignments,” and how placeholders (
managementGroups/placeholder,${default_location}) get replaced. - Read versions: library tags
platform/alz/<year>.<month>.<patch>, the definition'smetadata.version, deprecation andsupersededBy, and the assignment'sdefinitionVersion. - Know the three customization methods:
policy_default_values,policy_assignments_to_modify, and archetype overrides in a custom library, and define an upgrade process.
What: what the ALZ library is
Azure/Azure-Landing-Zones-Library is the “data” of ALZ. It deploys nothing. Instead, it provides a set of JSON assets that a deployment tool reads and then deploys (the Terraform Azure/alz provider with the avm-ptn-alz module, or the Bicep AVM implementation). The same repository contains other libraries: platform/slz (Sovereign Landing Zone) and platform/amba (Azure Monitor Baseline Alerts).
| Path (platform/alz/…) | Contents | Scale in 2026.11.0 |
|---|---|---|
policy_definitions/*.alz_policy_definition.json | ALZ custom policy definitions | The root archetype references 149 |
policy_set_definitions/*.alz_policy_set_definition.json | Custom initiatives (such as Enforce-Guardrails-* and Deploy-Private-DNS-Zones) | 44 |
policy_assignments/*.alz_policy_assignment.json | Assignment templates (names ≤ 24 characters, scopes are placeholders) | root 17, platform 40, landingzones 53, corp 5… |
role_definitions/ | Custom roles (such as Network-Subnet-Contributor and Application-Owners) | 5 |
archetype_definitions/*.alz_archetype_definition.json | archetype = a set of definitions + initiatives + assignments + roles | 12 (root, platform, landing_zones, corp, online, local, sandbox, security, management, connectivity, identity, decommissioned) |
architecture_definitions/alz.alz_architecture_definition.json | MG hierarchy: each MG's id, display name, parent, and archetype | 12 MGs, plus the intermediate root alz |
alz_policy_default_values.json | Default names for parameters shared across assignments | log_analytics_workspace_id, private_dns_zone_subscription_id, ama_user_assigned_managed_identity_id, ddos_protection_plan_id, email_security_contact, and so on |
How: from the library to Azure, the resolution process
- Download: the provider downloads the library using
library_references(path = "platform/alz",ref = "2026.11.0"), and can layer a local custom library on top (custom_url = "${path.root}/lib"). The download cache is stored in the.alzlibdirectory (add it to.gitignore). - Select the architecture: the module variable
architecture_name = "alz"(or your customalz_custom), andparent_resource_id= the tenant ID (the intermediate root attaches directly under the tenant root group). - Expand archetypes: each MG's archetype lists the definitions, initiatives, assignments, and roles it deploys. Definitions and initiatives are deployed to the intermediate root, and assignments are deployed to their respective MGs.
- Replace placeholders: replace
/providers/Microsoft.Management/managementGroups/placeholderin assignments with the real MG. Replace${default_location}withlocation. Replace{enforcementMode}in non-compliance messages with must / should. Fill the values inpolicy_default_valuesinto all assignment parameters that reference that default name. - Calculate role assignments: for assignments with managed identities (DINE / Modify), generate role assignments based on
roleDefinitionIdsin the definition. The provider needs to read built-in definitions (a cache file can speed this up). - Deploy: the module uses the
azapiprovider to create MGs, definitions, assignments, and role assignments (avm-ptn-alz 0.23.0 depends onazure/alz ~> 0.21andAzure/azapi ~> 2.12).
Three levels of version management
| Level | Form | Example |
|---|---|---|
| Library version | Git tag platform/alz/YYYY.MM.patch (calendar version) | platform/alz/2026.10.0 (2026-10-05) → 2026.11.0 (2026-11-06) |
| Custom definition version | metadata.version; when deprecated: deprecated: true, the display name gets [Deprecated], and supersededBy points to the new name | Enforce-Guardrails-Automation (1.1.0-deprecated) is replaced by Enforce-Guardrails-Automation_20260910 |
| Built-in definition version | definitionVersion in an assignment (such as 2.*.*) | Audit-ResourceRGLocation references built-in definition 0a914e76-… with definitionVersion: "2.*.*" |
Changes in 2026.11.0 (official release notes): Deploy-Diag-LogsCat now defaults to allLogs (previously audit), keeping its display name and assignment name. The deletion protection policies for activity logs and resource diagnostic settings changed from Indexed to All mode (diagnostic setting resources are now evaluated too). The Windows VM Hotpatch guardrail moved from the Automation initiative to the Compute initiative, and Enforce-Guardrails-Automation_20260910 was added. The default Automation guardrail assignment now uses the new initiative, and the old initiative is kept but deprecated. Changes like these are why you should read the release notes and run a plan before upgrading.
Why new initiatives have a date suffix: membership changes in an initiative may require different managed identity roles or parameters. Publishing under a new name and deprecating the old one keeps existing assignments unchanged until the upgrade. During the upgrade, the tool switches assignments to the new definition, rather than modifying an object that is already being referenced in place.
When: how to choose among the three customization methods
| Need | Method | Example |
|---|---|---|
| Fill in shared parameters | policy_default_values | log_analytics_workspace_id = the ID of law-alz-mgmt-cc |
| Change the mode / parameters / message / exclusions of a default assignment | policy_assignments_to_modify (by MG → assignment name) | Set Deny-Public-Endpoints to DoNotEnforce; change parameters for Enforce-ALZ-Sandbox |
| Add or remove an archetype's assignments / definitions | *.alz_archetype_override.json in the custom library lib/ (base_archetype + policy_assignments_to_add/remove, and so on) | Add this hour's lab-gov-baseline to landingzones |
| Change the hierarchy (add or remove MGs) | Custom architecture definition | Remove local if you don't need it (careful: the more it differs from upstream, the harder upgrades become) |
ref at the main branch to get the latest fixes.” Production must be pinned to a tag. ④ “The provider is 0.x, so it's fine to upgrade freely.” 0.x means minor versions can also contain breaking changes, so pin the minor version (for example ~> 0.22.0).Structure diagram: how library assets combine
Flow diagram: library upgrade process
Interactive animation: library resolution and version upgrade comparison
The “Resolve” mode shows step by step how the provider turns platform/alz@2026.11.0 into objects in Azure. The “Upgrade comparison” mode shows the changes that would appear in the plan when upgrading from 2026.10.0 to 2026.11.0 (based on the official release notes).
Core commands and configuration
| Command / configuration | Purpose | Notes |
|---|---|---|
git clone --depth 1 --branch platform/alz/2026.11.0 https://github.com/Azure/Azure-Landing-Zones-Library.git | Get the library at a specific version | Tag names contain a slash, so they are passed as the branch argument |
jq '.policy_assignments' …archetype_definition.json | View the assignments for an archetype | Use diff to compare two versions |
provider "alz" { library_references = [...] } | Library references and custom libraries | The provider is at 0.x, so pin the minor version |
module "alz" { source = "Azure/avm-ptn-alz/azurerm" } | Deployment architecture | version = "0.23.0"; variables below |
alzlibtool cache create | Generate the built-in definition cache file | --library platform/alz@2026.11.0 --architecture alz --output alzlib-cache.json.gz |
az policy definition list --management-group alz --query "[?metadata.deprecated]" | Find deployed deprecated definitions | Clean up leftovers after upgrading |
1) View the corp archetype in the library and one of its assignments
git clone -q --depth 1 --branch platform/alz/2026.11.0 https://github.com/Azure/Azure-Landing-Zones-Library.git alzlib-2611
cd alzlib-2611/platform/alz
jq -r '.policy_assignments[]' archetype_definitions/corp.alz_archetype_definition.json
jq '{name, def: .properties.policyDefinitionId, mode: .properties.enforcementMode, msg: .properties.nonComplianceMessages}' \
policy_assignments/Deny-Public-IP-On-NIC.alz_policy_assignment.json
Audit-PeDnsZones
Deny-HybridNetworking
Deny-Public-Endpoints
Deny-Public-IP-On-NIC
Deploy-Private-DNS-Zones
{
"name": "Deny-Public-IP-On-NIC",
"def": "/providers/Microsoft.Authorization/policyDefinitions/83a86a26-fd1f-447c-b59d-e51f44264114",
"mode": "Default",
"msg": [ { "message": "Network interfaces {enforcementMode} not have a public IP associated." } ]
}
2) Terraform: reference the library, set default values, and change one default assignment
terraform {
required_providers {
alz = { source = "azure/alz", version = "~> 0.22.0" }
azapi = { source = "Azure/azapi", version = "~> 2.12" }
}
}
provider "alz" {
library_references = [
{ path = "platform/alz", ref = "2026.11.0" },
{ custom_url = "${path.root}/lib" } # local archetype override
]
}
data "azapi_client_config" "current" {}
module "alz" {
source = "Azure/avm-ptn-alz/azurerm"
version = "0.23.0"
architecture_name = "alz_custom" # custom architecture based on alz in lib/
parent_resource_id = data.azapi_client_config.current.tenant_id
location = "canadacentral"
policy_default_values = {
log_analytics_workspace_id = jsonencode({ value = "/subscriptions/<mgmt-sub>/resourceGroups/rg-alz-mgmt-cc/providers/Microsoft.OperationalInsights/workspaces/law-alz-mgmt-cc" })
}
policy_assignments_to_modify = {
corp = {
policy_assignments = {
"Deny-Public-Endpoints" = { enforcement_mode = "DoNotEnforce" } # trial run first
}
}
}
}
This section is a configuration example. For full provider authentication, management and connectivity resource modules, and the pipeline, see Hour 6. The value of policy_default_values must be jsonencode({ value = … }); this is the convention the module uses to work around Terraform type system limits.
3) Archetype override: add one assignment to landing_zones
// lib/landing_zones_custom.alz_archetype_override.json
{
"name": "landing_zones_custom",
"base_archetype": "landing_zones",
"policy_assignments_to_add": [ "lab-gov-baseline" ],
"policy_assignments_to_remove": [],
"policy_set_definitions_to_add": [ "lab-gov-baseline" ],
"policy_definitions_to_add": [ "lab-deny-rg-naming" ]
}
The matching definition, policy set definition, and assignment JSON also go under lib/ (with file name suffixes such as .alz_policy_definition.json). In your custom architecture, make landingzones use landing_zones_custom.
Lab: read the library, compare two versions, and find the changes you need to watch
mkdir -p ~/alz-lab/lib-compare && cd ~/alz-lab/lib-compare for v in 2026.10.0 2026.11.0; do git clone -q --depth 1 --branch platform/alz/$v https://github.com/Azure/Azure-Landing-Zones-Library.git $v done ls 2026.11.0/platform/alz
README.md alz_library_metadata.json alz_policy_default_values.json architecture_definitions archetype_definitions policy_assignments policy_definitions policy_set_definitions role_definitions scripts
cd 2026.11.0/platform/alz for f in archetype_definitions/*.json; do printf "%-18s %3s\n" "$(jq -r .name $f)" "$(jq '.policy_assignments|length' $f)" done
connectivity 1 corp 5 decommissioned 1 identity 4 landing_zones 53 local 1 management 0 online 0 platform 40 root 17 sandbox 1 security 0
cd ~/alz-lab/lib-compare
diff -rq 2026.10.0/platform/alz 2026.11.0/platform/alz | sed 's#.*/platform/alz/##' | head -20
jq '{def: .properties.policyDefinitionId, params: .properties.parameters}' 2026.11.0/platform/alz/policy_assignments/Deploy-Diag-LogsCat.alz_policy_assignment.json
jq '.properties.metadata | {deprecated, supersededBy, version}' \
2026.11.0/platform/alz/policy_set_definitions/Enforce-Guardrails-Automation.alz_policy_set_definition.json
{
"deprecated": true,
"supersededBy": "Enforce-Guardrails-Automation_20260910",
"version": "1.1.0-deprecated"
}Enforce-GR-Automation0 moves to the new policy set definition); ② which definitions change their mode (the evaluation scope grows, so new non-compliance may appear); ③ which default parameters change (diagnostic categories change to allLogs, so Log Analytics data volume and cost may rise). Put these three points in the change request.az policy set-definition list --management-group alz --query "[?metadata.deprecated].name" to find deployed policy set definitions that are deprecated. Cleanup: rm -rf ~/alz-lab/lib-compare.Case 1: the library was forked and not upgraded for two years
Problem: The team forked the old Enterprise-Scale policies and edited the JSON directly. Later they wanted the new guardrail policy set, but found hundreds of conflicting files. Approach: go back to the upstream library tag; move the custom changes into policy_default_values, policy_assignments_to_modify, and archetype overrides; use plan to confirm "no changes" before accepting the new version. Limit: the old Terraform module caf-enterprise-scale is archived, so migration must follow the official migration guide (hour 6).
Case 2: log costs doubled after the upgrade
Problem: After upgrading to 2026.11.0, the diagnostic settings changed from the audit category to allLogs, and Log Analytics data volume rose sharply. Approach: read the release notes before upgrading; to keep the original behavior, override the category parameter of that assignment with policy_assignments_to_modify; also review the workspace table plans and retention period (hour 5). Limit: after you change the parameters, the remediation task must also update existing diagnostic settings.
Case 3: phased rollout with DoNotEnforce first
Problem: Enabling Deny-Public-Endpoints on corp all at once would block many configuration updates to existing PaaS resources. Approach: on the first deployment, set it to DoNotEnforce with policy_assignments_to_modify, fix the workloads one by one using the compliance report, then remove the override to return to Default. Limit: during DoNotEnforce, new resources are not blocked either, so pair it with the policy checks in the pipeline (hour 6).
Common errors and fixes
Error: … failed to fetch library … platform/alz@2026.11.0 … (git / go-getter)
Cause: the runtime cannot reach GitHub (proxy or offline pipeline proxy), or the ref is wrong (for example, written as v2026.11.0 or platform/alz/2026.11.0).
Fix: for ref, use only the version number 2026.11.0. In offline environments, download the library in advance and point custom_url to the local directory.
Error: … policy assignment … parameter 'logAnalytics' … value is empty / placeholder
Cause: no value was provided for a policy_default_values default name, so the assignment parameter kept its placeholder value.
jq -r '.defaults[].default_name' ~/alz-lab/lib-compare/2026.11.0/platform/alz/alz_policy_default_values.json
Fix: provide values for the default names you use (workspace ID, private DNS zone subscription and resource group, AMA identity, and so on).
(PolicyDefinitionInUse / PolicySetDefinitionInUse) … cannot be deleted because it is referenced by assignments
Cause: during the upgrade, the tool tried to delete the replaced old definition, but an assignment in the tenant (possibly created by hand) still references it.
az policy assignment list --disable-scope-strict-match --scope /providers/Microsoft.Management/managementGroups/alz \
--query "[?contains(policyDefinitionId,'Enforce-Guardrails-Automation')].{n:name,s:scope}" -o table
Fix: first point the references to the new definition, then delete the old definition. Do not let manual assignments reference definitions in the library.
terraform plan shows many role assignments as "replace" (destroy / create)
Cause: the roleDefinitionIds of the definition changed, or the module changed how it names role assignments (for example, role_assignment_name_use_random_uuid).
Fix: read the module changelog. Apply in a non-production tenant first. During replacement, remediation tasks may fail briefly, so schedule the change in a maintenance window.
1. In the local library, find all deprecated policy set definitions and their replacements.
cd ~/alz-lab/lib-compare/2026.11.0/platform/alz for f in policy_set_definitions/*.json; do jq -r 'select(.properties.metadata.deprecated==true) | "\(.name) -> \(.properties.metadata.supersededBy)"' "$f" done
2. Find all assignments in the landing_zones archetype that have a system-assigned managed identity (these need to be corrected and authorized).
for a in $(jq -r '.policy_assignments[]' archetype_definitions/landing_zones.alz_archetype_definition.json); do jq -r 'select(.identity.type=="SystemAssigned") | .name' policy_assignments/$a.alz_policy_assignment.json done
Your organization does not need a local management group, and you don't want Enable-DDoS-VNET on landingzones (there is no DDoS plan). At the same time, you need to add this hour's lab-gov-baseline to corp. Design the implementation without forking the library.
In lib/: ① a custom architecture alz_custom that copies the official hierarchy but removes local (or keeps it with no subscriptions, to reduce differences from upstream); ② a landing_zones_custom archetype override: base_archetype = landing_zones, policy_assignments_to_remove = ["Enable-DDoS-VNET"]; ③ a corp_custom override that adds the lab-gov-baseline definitions, policy set definitions, and assignments. The provider's library_references references both platform/alz@2026.11.0 and ./lib, and the module uses architecture_name = "alz_custom". When you upgrade, change only the ref; the overrides layer on top of the new version automatically.
Verified video
No verified English video dedicated to the ALZ library and version management was found. The following are official resources and a storyboard script.
Official resources
- Azure-Landing-Zones-Library · Releases · Library docs
- Azure/alz provider · avm-ptn-alz module
- Policy definition versions (version / definitionVersion)
Video storyboard script (about 90 seconds)
Visual: the GitHub repository folder expands: policy_definitions, policy_set_definitions, policy_assignments, archetype_definitions, architecture_definitions.
Narration: The ALZ library is data, not a deployment script. The deployment tool reads it, then replaces the placeholders and fills in the default values.
Visual: each of the 12 MG nodes in the architecture takes in an archetype card, and each card holds a list of assignments.
Narration: Each management group maps to one archetype. The archetype decides which assignments are deployed on that management group.
Visual: the version tag flips from 2026.10.0 to 2026.11.0, and the plan output shows a "new policy set" and a "[Deprecated]" marker.
Narration: The library is released on a calendar-based version schedule. Before upgrading, read the release notes, review the plan, and watch for replacements, mode changes, and parameter defaults.
Visual: the local lib folder sits as a transparent layer on top of the upstream library.
Narration: Customize with default values, assignment modification variables, and archetype overrides instead of forking. That way, an upgrade only requires changing one version number.
Module 7 · Compliance reports and Azure Resource Graph queries
- State the compliance states (Compliant, Non-compliant, Exempt, Conflicting, Error, Protected, Unknown, Not started, Not registered), and the aggregation priority and percentage formula.
- Know the evaluation triggers and their delays: new assignments apply in about 5 minutes, resource changes are visible in about 15 minutes, subscription placement takes about 30 minutes, the standard cycle is 24 hours, and on-demand scans are available.
- Use
az policy state summarize / listto get compliance data, andaz graph queryto querypolicyresources,resourcecontainers, andresourcesacross management groups. - Write 5 KQL queries commonly used for governance, and know how Resource Graph paging and throttling work.
What: compliance state
| State | Meaning |
|---|---|
| Non-compliant | audit / AINE / modify: new, changed, and existing resources that meet the if condition; append / deny / DINE: existing resources that meet the condition (new requests are already denied or corrected at request time) |
| Compliant | Condition not met (for DINE / AINE, the existence condition is met) |
| Exempt | Within the exemption scope; the sub-state shows the state with the exemption removed |
| Conflicting | Conflicting rules exist within the same scope (for example, two modify rules set different values for the same tag) |
| Error | Template or evaluation error |
| Protected | Overridden by a denyAction assignment |
| Unknown | Default state for the manual effect; waiting for manual attestation |
| Not started / Not registered | Not yet evaluated, or Microsoft.PolicyInsights is not registered or you have no permission to read it; not counted in the aggregation |
Aggregation priority (when a resource has several states within a policy set, the "strongest" one wins): Non-compliant > Compliant > Error > Conflicting > Protected > Exempted > Unknown. So if a resource is non-compliant with any one rule in the policy set, its overall state is non-compliant. A resource where only one rule is exempted and the rest are compliant shows as compliant overall.
Compliance percentage = (compliant + exempt + unknown + protected)
/ (compliant + exempt + unknown + non-compliant + conflicting + error + protected)
When: when the data updates
| Trigger | Delay (official description) |
|---|---|
| New assignment / assignment update | Applies to the scope in about 5 minutes, then evaluation starts. There is no fixed completion time for large scopes. |
| Resource created or updated | The effect events and compliance state for that resource become visible in about 15 minutes (this does not trigger evaluation of other resources) |
| Subscription created or moved to an MG (for subscription-type policies) | About 30 minutes |
| Exemption created / updated / deleted | The assignment is re-evaluated for the exemption scope |
| Standard evaluation cycle | Every 24 hours |
| On-demand scan | az policy state trigger-scan (subscription or resource group, asynchronous); GitHub Action azure/policy-compliance-scan |
How: Azure Resource Graph (ARG)
ARG is a cross-subscription resource index. It is queried with a subset of KQL, returns results in seconds, and does not consume the read quotas of each resource provider. The tables most used for governance:
| Table | Contents | Governance use |
|---|---|---|
resources | Most ARM resources | Tag coverage, inventory by type and region |
resourcecontainers | Subscriptions, resource groups, management groups | Subscription placement (managementGroupAncestorsChain), resource group tags |
policyresources | microsoft.policyinsights/policystates, microsoft.authorization/policyassignments, policydefinitions, policysetdefinitions, policyexemptions, policydefinitions/versions, and so on | Compliance reports, exemption expiry, assignment inventory |
resourcechanges / resourcecontainerchanges | Resource change history (recent) | Who changed what to cause the non-compliance |
advisorresources, healthresources, authorizationresources | Advisor recommendations, resource health, role assignments, and so on | Supplementary data for governance reviews |
- Scope:
az graph queryqueries, by default, the subscriptions you have permission to read;--management-groups alzqueries the whole hierarchy; with more than 10,000 subscriptions, only the first 10,000 are returned. - Paging: each response returns up to 1,000 rows (
--firstmax 1000); for more results, continue with--skip-token. - Throttling: quotas are allocated per user and per time window (documented example: 15 calls every 5 seconds). The response headers
x-ms-user-quota-remainingandx-ms-user-quota-resets-aftershow the quota state. For bulk reports, combine queries and stagger their timing. - Permissions: ARG returns only the data you have read permission for. The reporting identity needs Reader on
alz(compliance data also requires Policy Insights read permission, which Reader already includes).
Data flow: where compliance data comes from
Aggregation example: one resource, one policy set
Interactive animation: KQL query builder
Choose a governance question. The animation builds the query one operator at a time and explains what each step does to the data, then shows a sample result. You can copy the final query into Resource Graph Explorer or az graph query -q to use it (results are sample data).
Core commands and parameters
| Command | Purpose | Key parameters / notes |
|---|---|---|
az policy state summarize | Summarize non-compliant resource counts by assignment or definition | --management-group, --subscription, --top |
az policy state list | Individual compliance records | --filter "complianceState eq 'NonCompliant'", --apply (OData aggregation), --select |
az policy state trigger-scan | On-demand evaluation | Subscription (default) or --resource-group; --no-wait |
az policy event list | Evaluation events (who, when, what effect) | --from, --to |
az graph query | Resource Graph query | -q, --management-groups, --subscriptions, --first (≤1000), --skip-token |
az graph shared-query create | Save a shared query (available in the portal) | Good for sharing governance reports with the team |
1) Top 5 non-compliant assignments under landingzones
az policy state summarize --management-group landingzones --top 5 \
--query "policyAssignments[].{assignment:policyAssignmentId, nonCompliant:results.nonCompliantResources}" -o table
Assignment NonCompliant ---------------------------------------------------------------------------------------------- ------------ /providers/Microsoft.Management/managementGroups/landingzones/…/policyAssignments/lab-gov-baseline 4 /providers/Microsoft.Management/managementGroups/landingzones/…/policyAssignments/Deploy-VM-Monitoring 2 /providers/Microsoft.Management/managementGroups/landingzones/…/policyAssignments/lab-inherit-costcenter 1
2) ARG: compliance percentage by subscription (simplified: only Compliant / NonCompliant / Exempt)
az graph query --management-groups alz -q "
policyresources
| where type == 'microsoft.policyinsights/policystates'
| extend state = tostring(properties.complianceState), subId = tostring(properties.subscriptionId)
| summarize total = count(), ok = countif(state in ('Compliant','Exempt')) by subId
| join kind=leftouter (resourcecontainers | where type == 'microsoft.resources/subscriptions'
| project subId = subscriptionId, subName = name) on subId
| project subName, total, ok, pct = round(100.0 * ok / total, 1)
| order by pct asc" -o table
SubName Total Ok Pct -------------------- ------- ---- ----- sub-lz-corp-myapp 212 196 92.5 sub-alz-connectivity 148 145 98.0 sub-alz-management 131 131 100.0
This is a record-level approximate percentage (each resource × assignment record counts as one). It differs from the portal's resource-level percentage, so state the basis in your report.
3) ARG: costCenter tag coverage for resources
az graph query --management-groups landingzones -q " resources | extend cc = tostring(tags['costCenter']) | summarize total = count(), tagged = countif(isnotempty(cc)) by type | extend coverage = round(100.0 * tagged / total, 1) | where coverage < 100 | order by total desc" --first 20 -o table
Lab: cross-management-group compliance and tag report
alz scope, generate three reports: the assignment non-compliance ranking, subscription placement by MG, and resource groups missing costCenter. Then save them as shared queries. Cost: 0. Permissions: Reader on alz is enough.for s in sub-lz-corp-myapp sub-alz-connectivity sub-alz-management sub-alz-identity; do az policy state trigger-scan --subscription "$s" --no-wait 2>/dev/null && echo "scan started: $s" done
az graph query --management-groups alz -q " policyresources | where type == 'microsoft.policyinsights/policystates' | where properties.complianceState == 'NonCompliant' | extend assignment = tostring(properties.policyAssignmentName), ref = tostring(properties.policyDefinitionReferenceId) | summarize resources = dcount(tostring(properties.resourceId)) by assignment, ref | order by resources desc" --first 10 -o table
Assignment Ref Resources ---------------------- ----------- --------- lab-gov-baseline rgEnvTag 3 lab-gov-baseline rgNaming 1 lab-inherit-costcenter 1
az graph query --management-groups alz -q " resourcecontainers | where type == 'microsoft.resources/subscriptions' | extend chain = properties.managementGroupAncestorsChain | project subscription = name, parentMg = tostring(chain[0].name), path = strcat_array(chain, ' < ')" -o table
strcat_array concatenates arrays of objects directly, so the output is long. As an exercise, try mv-apply to keep only the name at each level.
az graph query --management-groups landingzones -q " resourcecontainers | where type == 'microsoft.resources/subscriptions/resourcegroups' | where isempty(tostring(tags['costCenter'])) | project resourceGroup = name, subscriptionId, location" -o table
ResourceGroup SubscriptionId Location ---------------- ------------------------------------ ------------- NetworkWatcherRG 00000000-0000-0000-0000-00000000c0a1 canadacentral
NetworkWatcherRG is a resource group created automatically by the platform. It existed before the lab-rg-req-costcenter assignment (or was created by a service), so it is a pre-existing non-compliance. Handle it with an exemption (Mitigated), or add the tag in the pipeline.
az group create -n rg-alz-gov-cc -l canadacentral --tags env=prod owner=platform@contoso.example costCenter=CC-0001 workload=governance 2>/dev/null az graph shared-query create --name "alz-noncompliant-by-assignment" --resource-group rg-alz-gov-cc \ --description "ALZ governance report A" --graph-query "policyresources | where type == 'microsoft.policyinsights/policystates' | where properties.complianceState == 'NonCompliant' | summarize count() by tostring(properties.policyAssignmentName)"
Tip: if rg-alz-gov-cc is in sub-alz-management, it sits under platform and is not affected by the lab assignment on landingzones. The shared query resources themselves are free. Cleanup: az group delete -n rg-alz-gov-cc --yes (if you don't need to keep the reports).
Case 1: management only sees "98% compliant"
Problem: The monthly report shows 98% compliance, but a security audit found that 40% of storage accounts allow public network access. Root cause: the related policy is Audit, and most resources are covered by a Waiver exemption. Exempt resources count toward the compliance percentage. Approach: show non-compliant counts, exemption counts, exemptions expiring soon, and Deny block counts together in the report; publish separate metrics for critical controls. Limit: the basis of the percentage (resource-level or record-level) must be stated in the report.
Case 2: report script hit throttling
Problem: A nightly script queries 2,000 subscriptions one by one and frequently receives RateLimiting. Approach: switch to a single query with --management-groups alz, and page with skipToken. If grouping is necessary, keep each group to no more than 300 subscriptions, and back off based on the response headers. Limit: quotas are calculated per user, so multiple scripts sharing one service principal affect each other.
Case 3: use resourcechanges to find who made it non-compliant
Problem: An NSG suddenly appeared in the non-compliant list for Deny-MgmtPorts-Internet (the existing resource was modified another way, or the policy was assigned later). Approach: query resourcechanges for that NSG's recent changes and changedBy, then combine with the activity log to identify the operator. Limit: change history is kept for a limited time. For long-term auditing, export the activity log to Log Analytics.
Common errors and fixes
az graph query: 'graph' is misspelled or not recognized by the system
Cause: the resource-graph extension is not installed.
az extension add --name resource-graph --upgrade
(RateLimiting) Client application has been throttled and should not attempt to repeat the request until an amount of time has elapsed.
Cause: too many queries in a short time, exceeding the user's quota.
Fix: combine queries, use an MG scope, and stagger the timing. Read x-ms-user-quota-resets-after before retrying. If the error message says "Number of 'read' requests for subscription … exceeded", that is ARM throttling, not ARG.
Compliance page shows "Not registered"
Cause: the subscription has not registered Microsoft.PolicyInsights, or the current account has no permission to read compliance data.
az provider register --namespace Microsoft.PolicyInsights --subscription sub-lz-corp-myapp az provider show -n Microsoft.PolicyInsights --query registrationState -o tsv
Query returns only 1,000 rows, or the numbers don't match the portal
Cause: a single response returns at most 1,000 rows, so paging is needed; or the counting basis differs (record-level vs resource-level, whether Exempt is counted, or the portal counts only applicable resources).
Fix: loop with --skip-token; use summarize in KQL before returning results; count resources with dcount(resourceId).
1. List all policy assignments in the alz hierarchy and their enforcement modes (from ARG).
az graph query --management-groups alz -q "policyresources | where type == 'microsoft.authorization/policyassignments' | project name, scope = tostring(properties.scope), mode = tostring(properties.enforcementMode) | order by scope asc" --first 200 -o table
2. List the resources that are Protected (protected by denyAction).
az graph query --management-groups alz -q "policyresources | where type == 'microsoft.policyinsights/policystates' and properties.complianceState == 'Protected' | project resourceId = tostring(properties.resourceId), assignment = tostring(properties.policyAssignmentName)" -o table
At 09:00 you assigned a new Deny policy set to corp. At 09:10 the compliance page shows 100% compliant, and the product manager announces that "all corp resources meet the new standard." Where could the problem be? How would you confirm it?
A new assignment takes about 5 minutes to apply to its scope, and the following evaluation cycle has no fixed completion time for large scopes. The "100%" at 09:10 most likely means evaluation has not finished (Not started is not counted in the aggregation) or only a small part has been evaluated. To confirm: check whether the resource compliance details for the assignment still show Not started; run az policy state trigger-scan on each subscription and wait for it to finish; use ARG to count the policystates records for this assignment and check whether the count is close to the number of applicable resources. Also note that for existing resources, Deny only marks them non-compliant and does not modify them.
Verified video
No verified English video dedicated to policy compliance reports and Resource Graph governance queries was found. The following are official docs and a storyboard script.
Official docs
- Compliance states · Get policy compliance data
- Resource Graph tables · Azure Policy ARG samples · Throttling guidance
Video storyboard script (about 90 seconds)
Visual: the ring on the compliance dashboard fills up gradually from "evaluating", and the timeline marks 5 minutes, 15 minutes, 30 minutes, and 24 hours.
Narration: Compliance data does not appear instantly. A new assignment applies in about 5 minutes, the standard cycle runs every 24 hours, and an on-demand scan is available when you need results urgently.
Visual: seven state cards are arranged in a column by priority, with Non-compliant at the top.
Narration: If one resource is non-compliant with any single rule in the policy set, its overall state is non-compliant. Exemptions count toward the compliance percentage, so reports must list exemptions separately.
Visual: three tables, policyresources, resourcecontainers, and resources, are joined to produce a compliance table by subscription.
Narration: Resource Graph uses KQL to query across all subscriptions, linking compliance records, subscription names, and management groups together.
Visual: the query is split into pages of 1,000 rows, and a metronome shows 15 calls every 5 seconds.
Narration: Watch the paging and throttling. Combining queries and querying by management group is faster and uses less quota than querying subscription by subscription.
Module 8 · Governance review and common errors
- Complete a governance review across five dimensions (subscriptions and hierarchy, naming and tags, policy design, exception management, compliance and operations), and give an evidence command for each item.
- Identify the 10 most common errors in ALZ governance and their consequences.
- Use the troubleshooting decision tree to handle three kinds of problems: requests being denied, policy not taking effect, and remediation failing.
- Turn the review results into an actionable improvement plan (owner, deadline, verification method).
What: governance review checklist
| Dimension | Check item | Evidence method |
|---|---|---|
| Subscriptions and hierarchy | No subscriptions sitting directly under the tenant root | ARG: subscriptions where managementGroupAncestorsChain[0] equals the tenant ID |
| The default MG is not the tenant root; creating MGs requires authorization | az account management-group hierarchy-settings list | |
| Platform functions (management, connectivity, identity, security) use separate subscriptions | Subscription placement report | |
| No separate MGs created for environments (dev / prod) | Hierarchy diagram | |
| Naming and tags | Naming convention documented, IaC generates names | Convention document + module code |
| Resource groups require costCenter / owner / env | az policy assignment list | |
| Resource costCenter coverage ≥ 95% | ARG coverage query (Module 7) | |
| Policy design | Custom definitions and policy sets centralized in the intermediate root alz | az policy definition list --management-group alz |
| Effects parameterized; new policies start with DoNotEnforce or Audit | History of each assignment's enforcementMode | |
| Every assignment has a non-compliance message | ARG: assignments where properties.nonComplianceMessages is empty | |
| Assignments use policy sets rather than many individual definitions (well below the 200 limit) | Assignment count per scope | |
| ALZ library pinned to a tag and reviewed within the last 3 months | ref in IaC | |
| Exception management | Exceptions use exemptions rather than notScopes | Inventory of notScopes on assignments |
| Every Waiver has an expiry date (≤ 90 days) and a ticket number | ARG: exemption query | |
| Only the platform team has exempt/Action | Role assignment review | |
| Quarterly review of Mitigated exemptions | Review record | |
| Compliance and operations | DINE / Modify assignments have correct managed identity permissions (including cross-subscription) | Remediation task failure rate |
| Weekly compliance report (non-compliant, exempt, and Deny counts) | Shared queries / workbooks | |
| Automatic evaluation and remediation triggered after a new subscription is sold | Sales pipeline | |
| Policy changes go through PRs and are validated in a non-production tenant | Repository and pipeline |
Why: 10 common errors
| # | Error | Consequence | Correct approach |
|---|---|---|---|
| 1 | New subscription left in the tenant root | Completely bypasses ALZ policy | Default MG = sandbox; placed by the sales process |
| 2 | Create MGs for dev / test / prod | Hierarchy bloat, duplicated policies | Separate environments by subscription |
| 3 | Deny tags on all resources from the start | Managed service deployments fail | Deny on resource groups + Modify on resources |
| 4 | Custom definitions placed in a child MG | Cannot be reused on other branches | Centralize in alz |
| 5 | CLI / IaC creates a DINE assignment without authorization | All remediation tasks return 403 | Authorize by roleDefinitionIds, including cross-subscription targets |
| 6 | Assuming the evaluation cycle will fix existing resources automatically | Stays non-compliant long-term | Remediation task |
| 7 | Handle individual exceptions with notScopes | Exceptions are invisible and have no expiry | Exemptions (Waiver / Mitigated) |
| 8 | Enable Deny directly, without a trial run first | Daily updates to existing resources are denied | DoNotEnforce → fix → Default |
| 9 | Fork the ALZ library, or point ref at a branch | Cannot upgrade / not reproducible | Pin a tag + overrides |
| 10 | Looking only at the compliance percentage | Exemptions hide risk | Report exemptions and Deny events together |
How: review cadence
- Weekly: compliance report, exemptions expiring soon, failed remediation tasks.
- Monthly: assess new ALZ library versions (release notes + plan); guardrail needs for new services.
- Quarterly: score the full review checklist; review Mitigated exemptions; review the subscription and MG structure.
When: what triggers an ad hoc review
New subscriptions from an acquisition or merger; before a large migration to the cloud; after an audit finds problems; when the ALZ library has breaking changes (for example, policy set replacements or mode changes).
Review radar: five dimensions
Troubleshooting overview: three kinds of problems
Interactive animation: governance review scorecard
Score each item for your lab tenant (0 = not done, 1 = partial / manual, 2 = done and automated). The scorecard summarizes results by dimension and generates improvement suggestions ordered by highest risk and easiest to fix. Results are kept only on this page; refreshing clears them.
Review evidence commands
| Check | Command |
|---|---|
| Orphaned subscriptions | az graph query -q "resourcecontainers | where type=='microsoft.resources/subscriptions' | where tostring(properties.managementGroupAncestorsChain[0].name)=='<tenant-id>' | project name" |
| Hierarchy settings | az account management-group hierarchy-settings list --name <tenant-id> |
| Assignments per scope | az graph query -q "policyresources | where type=='microsoft.authorization/policyassignments' | summarize count() by tostring(properties.scope)" |
| Assignments without non-compliance messages | See query 1 below |
| Assignments with notScopes | See query 2 below |
| Failed remediation tasks | az policy remediation list --management-group alz --query "[?provisioningState=='Failed']" |
| Library version | grep -R 'ref *=' *.tf |
Query 1: Deny-type assignments without non-compliance messages
az graph query --management-groups alz -q " policyresources | where type == 'microsoft.authorization/policyassignments' | where array_length(properties.nonComplianceMessages) == 0 or isnull(properties.nonComplianceMessages) | project name, scope = tostring(properties.scope), mode = tostring(properties.enforcementMode)" -o table
Query 2: assignments with excluded scopes (are exceptions being hidden?)
az graph query --management-groups alz -q " policyresources | where type == 'microsoft.authorization/policyassignments' | where array_length(properties.notScopes) > 0 | project name, scope = tostring(properties.scope), notScopes = properties.notScopes" -o json
[
{
"name": "lab-gov-baseline",
"notScopes": [ "/providers/Microsoft.Management/managementGroups/local" ],
"scope": "/providers/Microsoft.Management/managementGroups/landingzones"
}
]
Query 3: are the roles for an assignment's managed identity complete? (spot-check one assignment)
A=lab-inherit-costcenter; S=/providers/Microsoft.Management/managementGroups/landingzones
PID=$(az policy assignment show -n $A --scope $S --query identity.principalId -o tsv)
DEF=$(az policy assignment show -n $A --scope $S --query policyDefinitionId -o tsv)
echo "Roles required:"; az policy definition show --name "${DEF##*/}" --query "policyRule.then.details.roleDefinitionIds" -o tsv
echo "Roles present:"; az role assignment list --assignee "$PID" --all --query "[].{role:roleDefinitionName,scope:scope}" -o table
Lab: run a governance review on your lab tenant
alz (fixing requires Owner).LZ=/providers/Microsoft.Management/managementGroups/landingzones az policy assignment non-compliance-message create --name lab-rg-req-costcenter --scope "$LZ" \ --message "Resource groups must have a costCenter tag (e.g., CC-1001). See platform tagging standard v1."
SUB=$(az account show --name sub-lz-corp-myapp --query id -o tsv) az policy exemption create --name lab-nwrg-mitigated --resource-group NetworkWatcherRG --subscription "$SUB" \ --policy-assignment "$LZ/providers/Microsoft.Authorization/policyAssignments/lab-rg-req-costcenter" \ --exemption-category Mitigated --display-name "Platform-managed RG; cost allocated via subscription" \ --metadata approvedBy=platform-ccoe reviewEvery=quarter
Case 1: 60 orphaned subscriptions in the merged tenant
Problem: Subscriptions from an acquired subsidiary moved into the tenant and all landed at the tenant root. Approach: first set the default MG to sandbox to stop new subscriptions from landing at the root. Use ARG to list the orphaned subscriptions, and place and evaluate them in batches by workload (pre-exemptions from Module 5 plus placement from Module 1). After each batch, run an on-demand scan and remediation. Limit: before moving them into corp, assess public exposure, or Deny will block later updates to many resources.
Case 2: audit requires "proof that every exception has an approval"
Approach: convert all exceptions to exemptions, with metadata recording the ticket number and approver. Export the ARG report weekly. Keep only structural exclusions in notScopes, and document the reasons in the standard. Effect: audit evidence collection went from two weeks to one day.
Case 3: review found DINE managed identities with excessive permissions
Problem: To save effort, the identity used by all DINE assignments was granted Owner on alz. Approach: narrow it to the minimum roles defined in roleDefinitionIds. For shared user-assigned identities, apply DenyAction against deletion and PIM review (hour 3). Limit: after narrowing the permissions, re-run the remediation task to confirm that no required roles were missed.
Interactive troubleshooting tree: policy-related issues
Select step by step from the symptom. At the end, you get diagnostic commands and fix suggestions.
Extra: three common errors
(RequestDisallowedByPolicy) … Reasons: 'Management port access from the Internet must be blocked.'
Cause: ALZ's Deny-MgmtPorts-Internet (landingzones, identity) denies NSG rules that allow Internet access to ports such as 22 and 3389.
Fix: use Bastion or Just-in-Time access (hour 4). Do not request an exemption for this.
(InvalidPolicyAssignmentScope) The scope '…' of policy assignment is not within the definition location '…'
Cause: the assignment scope is not below the level where the definition is stored (Module 3).
Fix: move the definition to alz.
Remediation task stuck in Running for hours
Cause: a large number of resources with low parallelism, or the resource deployments in the DINE template are themselves slow, or some deployments are waiting on dependencies.
az policy remediation deployment list --name <task> --management-group landingzones --query "[?status=='Running'].{id:remediatedResourceId,start:createdOn}" -o table
Fix: increase parallelDeployments (≤30), and batch by location filters. If needed, cancel and rebuild in batches.
1. Count the assignments on each scope, and find the scope closest to the 200 limit.
az graph query --management-groups alz -q "policyresources | where type == 'microsoft.authorization/policyassignments' | summarize assignments = count() by scope = tostring(properties.scope) | order by assignments desc" -o table
2. List all failed remediation tasks in the alz hierarchy.
az policy remediation list --management-group alz --query "[?provisioningState=='Failed'].{name:name, assignment:policyAssignmentId}" -o tableReview finding: corp has 15 subscriptions. In 6 of them, Deny-Public-Endpoints is excluded by notScopes, and there is no record explaining why. The compliance percentage is 97%. Write the first three steps of the improvement plan.
① Inventory: use ARG to list the PaaS resources with public endpoints in these 6 subscriptions and assess the risk. Contact the subscription owners to confirm the business reasons. ② Convert: remove these subscriptions from the assignment's notScopes. For resources with a valid reason, create exemptions (use Mitigated where another control compensates, and Waiver with an expiry of ≤ 90 days and a ticket number for temporary acceptance). Resources with no valid reason get fixed directly. If needed, first set the assignment to DoNotEnforce for a short transition period using policy_assignments_to_modify. ③ Reporting and process: add exemption counts, upcoming expirations, and the notScopes list to the report. Require that only the platform team can change notScopes and grant exempt/Action, and review this quarterly.
Verified video
Official docs
- ALZ design area: Governance
- Safe deployment of Azure Policy assignments
- Troubleshoot errors with Azure Policy
Video storyboard script (about 90 seconds)
Visual: a pentagon radar chart takes shape, and the five dimensions light up one by one.
Narration: A governance review looks at five things: subscriptions and hierarchy, naming and tags, policy design, exception management, and compliance and operations.
Visual: ten error cards flip over, and the back of each shows the correct approach. For example, "subscription left in the tenant root" flips to "default management group = sandbox".
Narration: The most common mistakes are often simple: subscriptions in the wrong place, Deny turned on too early, forgetting to authorize managed identities, and using exclusions to hide exceptions.
Visual: the troubleshooting tree has three branches: denied, not taking effect, and can't be fixed.
Narration: For a denial, check the assignment name in the error first. For something that isn't taking effect, check the timing, mode, exclusions, and scope. For something that can't be fixed, check the managed identity and the target scope.
Visual: calendar marks for weekly, monthly, and quarterly reviews.
Narration: Governance is not a one-time deployment. It is a review and improvement process that runs on a fixed rhythm.
Command cheat sheet
az account management-group subscription add --name corp --subscription <sub> az account management-group entities list -o table az account management-group hierarchy-settings create --name <tenant-id> \ --default-management-group /providers/Microsoft.Management/managementGroups/sandbox \ --require-authorization-for-group-creation true az vm list-usage --location canadacentral -o table
az group create -n rg-lz-myapp-cc -l canadacentral \ --tags env=prod owner=team@contoso.example costCenter=CC-1001 workload=myapp az tag update --resource-id <id> --operation Merge --tags workload=myapp az group list --query "[?tags.costCenter==null].name" -o tsv
az policy definition create --name <n> --management-group alz --mode All|Indexed \ --rules rules.json --params params.json az policy set-definition create --name <n> --management-group alz \ --definitions defs.json --params params.json az provider show -n Microsoft.Storage --expand "resourceTypes/aliases" -o json
az policy assignment create --name <≤24 characters> --scope <mg-scope> \
--policy|--policy-set-definition <id> --params '{"p":{"value":…}}' \
--not-scopes <scope> --enforcement-mode DoNotEnforce \
--mi-system-assigned --location canadacentral
az policy assignment update --name <n> --scope <s> --enforcement-mode Default
az policy assignment non-compliance-message create --name <n> --scope <s> --message "…"
az policy assignment list --disable-scope-strict-match --resource-group <rg>az role assignment create --assignee-object-id <principalId> \ --assignee-principal-type ServicePrincipal --role Contributor --scope <scope> az policy remediation create --name <n> --management-group landingzones \ --policy-assignment <assignment-id> [--definition-reference-id <ref>] \ [--resource-discovery-mode ReEvaluateCompliance] [--parallel-deployments 10] az policy remediation show|list|cancel|deployment list …
az policy exemption create --name <n> --scope <resource-or-rg-id> \ --policy-assignment <assignment-id> --exemption-category Waiver|Mitigated \ --expires-on 2026-12-31T23:59:00Z [--policy-definition-reference-ids a b] \ --metadata ticketRef=CHG-… approvedBy=… az policy exemption list --disable-scope-strict-match
az policy state trigger-scan [--resource-group <rg>] [--no-wait] az policy state summarize --management-group landingzones --top 5 az policy state list --resource-group <rg> --filter "complianceState eq 'NonCompliant'" az policy event list --resource-group <rg> --from 2026-11-18T00:00:00Z
policyresources | where type == 'microsoft.policyinsights/policystates' | where properties.complianceState == 'NonCompliant' | summarize count() by tostring(properties.policyAssignmentName) resourcecontainers | where type == 'microsoft.resources/subscriptions' | project name, parent = tostring(properties.managementGroupAncestorsChain[0].name)
az graph query --management-groups alz -q "<KQL>" --first 1000 [--skip-token <t>]
Key numbers
| Item | Value | Item | Value |
|---|---|---|---|
| Resource groups per subscription | 980 | Tags per resource / RG / subscription | 50 (key 512 / value 256) |
| MG hierarchy depth | Root + 6 levels (excluding subscriptions) | MGs per tenant | 10,000 |
| Policy definitions / policy sets / assignments per scope | 500 / 200 / 200 | Exemptions per scope | 1,000 |
| Definition parameters / policy set members / policy set parameters | 20 / 1,000 / 400 | notScopes | 400 |
| Length of assignment name at MG scope | ≤ 24 | Remediation task resource count | Default 500, max 50,000 |
| Remediation parallel deployments | 1–30 (default 10) | DINE evaluationDelay default | PT10M |
| overrides / resourceSelectors per assignment | 10 / 10 | ARG rows returned per response | 1,000 rows |
| New assignment takes effect | ≈ 5 minutes | Standard evaluation cycle | 24 hours |
Effect evaluation order (memorize)
disabled → append / modify → deny → audit → manual → auditIfNotExists → denyAction → resource provider → after success, auditIfNotExists / deployIfNotExists
Capstone lab + final quiz: deliver a governance baseline for the myapp landing zone
lab- objects using the last step, and revoke any elevated access.Scenario
The myapp team (Flask, port 5000) will go live in production in sub-lz-corp-myapp. The platform team must deliver within two days: subscription placement is correct; resource groups must carry four tags, and resources automatically inherit costCenter; resource group naming and region are controlled; storage must use HTTPS; critical resources are protected against accidental deletion; one approved temporary exception; and a compliance report that can be sent weekly. If you have only one subscription, complete all the steps on that subscription and corp.
sub-lz-corp-myapp is in corp. Set the default MG to sandbox and turn on "require authorization to create MGs". Acceptance: the ARG subscription placement report.landingzones, assign "Require a tag on resource groups" for env, owner, and costCenter. These can be combined into one policy set lab-tag-baseline, with referenceId telling the three apart. For costCenter and workload, assign "Inherit a tag from the resource group if missing" (managed identity + Contributor). Acceptance: creating a resource group without a tag is denied; new resources automatically get costCenter and workload.lab-gov-baseline (naming + resource group region + env tag). Run it with DoNotEnforce for one day first (in the lab, you can shorten this to 10 minutes). After reviewing the non-compliance list, switch to Default, and add a non-compliance message for each member.lab-deny-st-http (or ALZ's Deny-Storage-http) on Deny. Use lab-protect-delete (denyAction) to protect the myapp production storage account tagged protect=true. Acceptance: deletion is denied, and compliance shows Protected.lab-inherit-costcenter and the workload inheritance assignment, and record the deploymentSummary.myapp-legacy-int (region canadacentral) whose name does not follow the naming convention. It needs a 30-day Waiver exemption for the rgNaming member of lab-gov-baseline, with the ticket number in metadata. The tricky part: the exemption must attach to a scope that already exists, but this resource group cannot be created before the exemption is in place. Approach: ① create a temporary exemption for only rgNaming at the subscription scope, expiring in 1 hour; ② create the resource group; ③ delete the subscription-level temporary exemption, and create the formal 30-day exemption at the resource group scope. Acceptance: other resource groups with non-compliant names are still denied, and myapp-legacy-int shows Exempt.lib/ (definition, policy set, and assignment JSON, plus landing_zones_custom / corp_custom archetype overrides). Validate with terraform plan. Do not apply onto objects you created by hand, to avoid conflicts.LZ=/providers/Microsoft.Management/managementGroups/landingzones
for a in lab-gov-baseline lab-rg-req-costcenter lab-inherit-costcenter lab-deny-st-http lab-protect-delete lab-tag-baseline lab-inherit-workload; do
PID=$(az policy assignment show -n $a --scope "$LZ" --query identity.principalId -o tsv 2>/dev/null)
[ -n "$PID" ] && az role assignment delete --assignee "$PID" --scope "$LZ" 2>/dev/null
az policy assignment delete -n $a --scope "$LZ" 2>/dev/null && echo "deleted assignment $a"
done
az policy exemption list --disable-scope-strict-match --query "[?starts_with(name,'lab-')].id" -o tsv | \
xargs -r -n1 az rest --method delete --url "https://management.azure.com{}?api-version=2022-07-01-preview"
for s in lab-gov-baseline lab-tag-baseline; do az policy set-definition delete -n $s --management-group alz 2>/dev/null; done
for d in lab-deny-rg-naming lab-protect-delete; do az policy definition delete -n $d --management-group alz 2>/dev/null; done
az group delete -n rg-lz-myapp-cc --yes --no-wait # delete this if later hours don't need it
# Revoke elevated access: in the Entra portal "Properties", turn off "Access management for Azure resources", and delete the Owner role that was added at the root MG for the lab
Deleting exemptions uses a generic REST call for multiple scopes. Confirm the api-version against the official docs. You can also delete them one at a time with az policy exemption delete --name … --scope ….
Acceptance checklist
- ☐ Subscription placement and hierarchy settings are correct; there are no orphaned subscriptions in ARG.
- ☐ Creating resource groups that have no tag, a non-compliant name, or a non-compliant region is denied, with the custom message shown as the error.
- ☐ New resources automatically get costCenter and workload; after the remediation task, existing resource coverage is 100%.
- ☐ HTTP storage accounts are denied; deletion of the protected storage account is denied, and its state is Protected.
- ☐ One Waiver exemption with an expiry date and a ticket number; compliance shows Exempt.
- ☐ The three shared queries run, and the report lists both non-compliant counts and exemption counts.
Open-ended self-check (6 questions)
1. Why does ALZ recommend the "Deny on resource groups + Modify on resources" tag combination instead of Deny on all resources?
Resource groups are created explicitly by people or pipelines, so requiring the tag there is practical. Resources are created by many tools and managed services (including automatically created NICs, disks, and resources in managed resource groups), so a direct Deny would cause deployment failures. Modify is evaluated before deny, so it can read the value from the resource group and fill in the tag. This keeps coverage high without blocking deployments. Existing resources are fixed with a remediation task.
2. Explain how notScopes and exemptions appear differently in compliance reports, and give one use case for each.
Scopes listed in notScopes are not evaluated and do not appear in the report. They suit structural divisions (for example, a policy set that does not apply to the local MG). Exempted resources are still counted, with the state Exempt and a sub-state. They suit individual exceptions, such as a Mitigated third-party WAF or a Waiver during a migration.
3. A DINE assignment ran fine when created in the portal, but after rebuilding it with Terraform, all remediation tasks fail. What could be the causes?
The portal automatically grants the managed identity the roles listed in roleDefinitionIds. With Terraform, the role assignments must be created explicitly (avm-ptn-alz handles this, but it is easy to miss when you write your own resources). The target resource may be outside the assignment's scope (for example, a private DNS zone in the connectivity subscription), which needs extra authorization. Parameter defaults (such as the workspace ID) may not be filled in. The new identity may not have finished replicating in Entra yet.
4. Describe the steps to upgrade the ALZ library from 2026.10.0 to 2026.11.0, and the changes you would watch closely.
Read the release notes → change the ref in a branch → review the plan → apply in a non-production tenant and watch compliance and denials → apply to production → run remediation tasks for the new DINE and parameter changes. Watch for: Deploy-Diag-LogsCat defaulting to allLogs (data volume and cost); the delete-protection policy's mode changing from Indexed to All (a change in evaluation scope); and the Automation guardrail now using the new policy set Enforce-Guardrails-Automation_20260910 (the old policy set is deprecated).
5. Can DenyAction replace resource locks? Explain the pros and cons of each.
Partly. DenyAction is deployed uniformly at the MG level and can match a batch of resources by type, name, or tag. It is hard for a single subscription Owner to bypass, and it shows Protected in compliance. However, it only supports delete, and it does not prevent subscription deletion or the cascading deletion of parent resources. Resource locks can block deletion or make a resource read-only. They are configured per resource, and anyone with permission can remove a lock. For critical resources, you can combine both.
6. Design the metrics for a weekly governance report, and explain why you should not rely on the compliance percentage alone.
Metrics: non-compliant resource counts per subscription or MG (resource-level), the non-compliance ranking by assignment, Deny blocks this week (from the activity log), total exemptions and the number expiring within 30 days, the number of Waivers without an expiry date, remediation task failure counts, the number of orphaned subscriptions, and costCenter coverage. The compliance percentage counts Exempt in the numerator and is affected by Not started, so using it alone hides risk.
Sources and versions
Sources table
| Topic | Source | Page date / version | Verified on |
|---|---|---|---|
| Subscription design guidance (including the separate security subscription and tenant transfer limits) | CAF: Subscription considerations | 2025-12-19 | 2026-11-18 |
| Subscriptions, resource groups, MGs, Policy limits | Azure subscription and service limits | Current version | 2026-11-18 |
| Naming length and character rules (including ≤24 for MG-scope assignment names) | Naming rules and restrictions | 2026-08-07 | 2026-11-18 |
| CAF resource abbreviations (log, afw, mg…) | Abbreviation recommendations | 2026-11-14 | 2026-11-18 |
| Built-in tag and region policy IDs | Azure/azure-policy built-in Tags · General | master | 2026-11-18 |
| Effects list and evaluation order | Effect basics | 2025-12-01 | 2026-11-18 |
| denyAction / modify / deployIfNotExists | denyAction · modify · DINE | 2025-12-01 | 2026-11-18 |
| Assignment structure (definitionVersion, overrides, resourceSelectors, Enroll) | Assignment structure | 2026-09-18 | 2026-11-18 |
| Remediation tasks and managed identities | Remediate resources · Remediation structure | 2025-12 | 2026-11-18 |
| Exemption structure | Exemption structure | 2026-08-04 | 2026-11-18 |
| Compliance states, aggregation, and percentages; evaluation triggers | Compliance states · Get compliance data | 2026-03 | 2026-11-18 |
| Resource Graph tables, throttling, and paging | Supported tables · Throttling guidance | 2026-08-19 | 2026-11-18 |
| ALZ library structure, architecture definitions, archetypes, and assignments | Azure-Landing-Zones-Library (platform/alz) | 2026.11.0 (2026-11-06) | 2026-11-18 |
| 2026.11.0 release notes | Releases | 2026-11-06 | 2026-11-18 |
| alz provider configuration and caching | terraform-provider-alz (docs/index.md) | 0.22.1 (2026-11-03) | 2026-11-18 |
| avm-ptn-alz variables and dependencies | Terraform Registry | 0.23.0 (2026-11-18) | 2026-11-18 |
Video verification notes
The video section lists only English videos whose titles and channels were verified through YouTube oEmbed (https://www.youtube.com/oembed?url=…&format=json):
R-5oeguxFpo"Azure Landing Zones - How many subscriptions should I use in Azure?" — Azure Verified Modules (Module 1)mluS8ovuBKg"Azure Landing Zones Overview" — John Savill's Technical Training (Modules 1, 8)
No topic videos that pass verification were found for Modules 2–7. Storyboard scripts are provided for use with a video generation tool.
Voice notes
The Voice tab uses the browser's Web Speech API to read the English narration script aloud, with English terms read in an English voice. The result depends on the voice packs installed on your operating system. Without a voice pack, you can read the script directly or use another TTS tool.
Known limitations
- None of the cloud commands were run in a real tenant: the commands were written from the official docs and CLI help. Output, IDs, times, and counts are examples. For some CLI parameters (such as the failure threshold format for remediation tasks, or CLI support for overrides), refer to
az … --help. - The default assignment counts for ALZ (root 17, platform 40, landingzones 53, corp 5, and so on) come from the library
platform/alz/2026.11.0. Other versions will differ. You will only see these assignments in your tenant if you deployed the ALZ default policies. - The compliance delays (about 5 / 15 / 30 minutes, 24 hours) are typical values from the official description. Large environments may take longer.
- The Resource Graph throttling quotas are example values from the documentation and can change with conditions. The compliance percentage query is a record-level approximation.
- Features related to
assignmentScopeValidationand theEnrollenforcement mode depend on the current status in the official docs (some are in preview). - The "Verified on 2026-11-15" label in the sidebar is the date the page skeleton was generated. This hour's content was verified on 2026-11-18.