Implement and Manage Azure Policy
30-second answer
Azure Policy checks resources against rules and applies an effect. A policy definition holds the rule; an initiative groups several; an assignment applies one to a scope (management group, subscription or resource group), with optional exclusions and parameters. Common effects are Deny (block the request), Audit (allow but mark non-compliant), Append, Modify (change properties such as tags during deployment) and DeployIfNotExists (deploy a related resource). Modify and DeployIfNotExists need a managed identity, and a remediation task fixes resources that existed before the assignment. Enforcement mode: Disabled lets you test without blocking. Compliance shows in Policy → Compliance.
Simulate it » No Azure account neededExam objective: 1.3.1 Implement and manage Azure Policy. (Skills measured as of April 17, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Search for <strong>Policy</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Search for Policy.
- Type policy in the search bar and pick Policy under Services.
- Under Authoring → Definitions, find Inherit a tag from the resource group if missing. Its effect is Modify: it adds the tag rather than refusing the deployment.
- Scope can be a management group, subscription or resource group. Policy enforcement: Disabled (DoNotEnforce) lets you test compliance without changing anything.
- Tell it which tag to copy: costcenter.
- A Modify policy needs a managed identity with rights to change resources. Ticking Create a remediation task fixes resources that already exist.
- Create. CLI: az policy assignment create -n inherit-costcenter --policy ea3f2387-… -g rg-finance --params tagName=costcenter --mi-system-assigned --location westeurope.
- New evaluations can take up to about 30 minutes. Existing resources show Non-compliant until remediation has run.
- The remediation task tagged all three. CLI: az policy remediation create -n fix-cc --policy-assignment inherit-costcenter -g rg-finance. Deny and Audit policies can't be remediated; only Modify and DeployIfNotExists.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Azure Policy: deny, audit, modify
Azure Policy checks what gets deployed. Deny refuses it, Audit lets it in but flags it non-compliant, Modify changes it (for example adds a tag) and needs a managed identity. A remediation task fixes resources that already exist.
🤔 What happens if…
Read this tour as text
- Users and groups in your tenant. Your Microsoft Entra tenant holds users and groups. In an assigned group you add people yourself. In a dynamic group a rule such as
user.department -eq "Sales"adds and removes them as their properties change (Entra ID P1). - Licenses and guests. Group-based licensing gives every member of a group a license, and takes it back when they leave. A direct assignment needs the user's usage location first. A guest from a partner tenant signs in with their own account (B2B collaboration).
- Self-service password reset. SSPR lets users reset their own password at aka.ms/sspr. You choose who it's for (None, Selected group or All) and how many methods they must prove (1 or 2). Users must register methods before they can use them.
- The management ladder. Management groups sit above subscriptions, which hold resource groups, which hold resources. You can nest management groups six levels below the Tenant Root Group. Move a subscription and it takes on its new parent's policies and roles.
- Role assignments flow down. An Azure role assignment = who (user, group, service principal, managed identity) + role definition + scope. Assign it at a management group and it inherits to every subscription, resource group and resource below.
- Effective access. Roles add up. Owner does everything, Contributor everything except grant access, Reader only looks, and User Access Administrator only manages access. A deny assignment beats every role.
- Azure Policy: deny, audit, modify. Azure Policy checks what gets deployed. Deny refuses it, Audit lets it in but flags it non-compliant, Modify changes it (for example adds a tag) and needs a managed identity. A remediation task fixes resources that already exist.
- Locks and tags. A CanNotDelete lock lets people change a resource but not delete it. A ReadOnly lock blocks every write. Locks apply to everyone, Owners too. Tags on a resource group aren't inherited unless a policy copies them down.
- Budgets and Advisor. A budget watches spend for a scope and sends alerts at thresholds, on actual or forecasted cost, optionally to an action group. It doesn't stop anything by itself. Azure Advisor points at savings like idle VMs.
Finance wants every resource tagged with its cost center, nothing outside Europe, production frozen during the audit, and an alert before the month's spend runs away. Build all four guardrails and see each one bite.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Half the resources have no cost center tag and some sit in the wrong region.
😊 THE SOLUTION
Deny the wrong region, Modify in the missing tag, and remediate the rest.
- Resources in any region✓ Allowed locations (Deny)
- Missing tags✓ Inherit a tag (Modify)
- Old resources still wrong✓ Remediation tasks
Start with a question
How does a building inspector keep every new house safe without visiting every site every day?
A council publishes building rules: no houses on the flood plain, every house needs a smoke alarm. Some rules stop the build before it starts (planning permission refused). Some just get noted on an inspection report. And some the council fixes for you, like fitting the missing smoke alarm and sending the bill.
Azure Policy is that rulebook. Deny refuses the build, Audit writes it on the report, and Modify fits the smoke alarm for you.
Explain it like I’m 10
The technical explanation
The pieces
- Definition: the rule (
ifa condition,thenan effect). Hundreds are built-in; you can write custom ones in JSON. - Initiative (policy set): several definitions grouped, such as a security baseline.
- Assignment: a definition or initiative applied at a scope (management group, subscription, resource group) with parameters, exclusions, a non-compliance message and an enforcement mode.
- Exemption: excludes one resource or scope, with a reason (waiver or mitigated) and an optional expiry.
Policies assigned higher up apply to everything below. The person deploying doesn’t matter: an Owner is stopped by Deny just like anyone else.
Effects
| Effect | When | Result | Needs identity? |
|---|---|---|---|
| Deny | Create or update | Request refused with RequestDisallowedByPolicy | No |
| Audit | Create, update and evaluation | Allowed, marked Non-compliant | No |
| Append | Create or update | Adds fields, such as IP rules | No |
| Modify | Create or update, and remediation | Adds, replaces or removes tags and some properties | Yes |
| AuditIfNotExists | After deployment | Flags if a related resource (like an extension) is missing | No |
| DeployIfNotExists | After deployment, and remediation | Deploys the missing related resource, such as diagnostic settings | Yes |
| Disabled | Never | Turns the rule off | No |
Assign a policy
Portal: Policy → Definitions → pick one → Assign policy. Tabs: Basics (scope, exclusions, assignment name, Policy enforcement), Parameters, Remediation (create a remediation task, managed identity type and location), Non-compliance messages, Review + create.
# Deny anything outside two regions, at a management group
az policy assignment create -n eu-only \
--policy e56962a6-4747-49cd-b67b-bf8b01975c4c \
--scope /providers/Microsoft.Management/managementGroups/mg-contoso \
--params '{ "listOfAllowedLocations": { "value": ["westeurope","northeurope"] } }'
# Modify: copy the costcenter tag from the resource group, with a managed identity
az policy assignment create -n inherit-costcenter \
--policy ea3f2387-9b95-492a-a190-fcdc54f7b070 -g rg-finance \
--params '{ "tagName": { "value": "costcenter" } }' \
--mi-system-assigned --location westeurope
# Fix resources that already exist
az policy remediation create -n fix-costcenter --policy-assignment inherit-costcenter -g rg-finance
az policy state summarize -g rg-finance # compliance numbers
az policy state trigger-scan -g rg-finance # re-evaluate now
When you assign through the CLI, give the managed identity a role (for tags, Tag Contributor) at the scope. The portal does this for you.
Compliance
New assignments are evaluated within about 30 minutes; existing resources are re-checked about every 24 hours or when you trigger a scan. Policy → Compliance shows each assignment’s percentage and the non-compliant resources with the reason.
-
1 Deny
A storage account in East US is refused at deployment.
-
2 Audit
A VM without managed disks is created but listed as non-compliant.
-
3 Modify
A new disk gets costcenter=FIN-042 copied from its resource group.
-
4 Remediate
A remediation task tags the 40 disks that existed before.
Architect level Policy and resource groups
Most built-in resource policies use mode Indexed, which evaluates resources that support tags and location, not resource groups themselves. That’s why there are separate definitions like Require a tag on resource groups. A resource group’s tags are also not inherited by its resources; Inherit a tag from the resource group (Modify) is the built-in fix. Allowed locations doesn’t apply to resource groups either; use Allowed locations for resource groups if the group’s metadata location matters.
Real-world business scenario
Tailwind Traders (fictional)
- The problem
- Tailwind found storage accounts in four regions it had never approved and could only attribute 60% of its Azure spend to a department.
- What they used
- An initiative at the root management group with Allowed locations (Deny, West Europe and North Europe), Inherit a tag from the resource group if missing for costcenter (Modify, system-assigned identity) and Require a tag on resource groups (Deny). Remediation tasks tagged the existing estate.
- Why that choice
- Wrong-region deployments now fail immediately, every resource carries its group's cost center, and new subscriptions inherit the rules the day they're created.
- The result
- Untagged spend fell from 40% to under 3%, and no new resources appeared outside Europe.
When to use it and when not to
✓ Use it when…
- Restricting regions, SKUs or resource types across many subscriptions.
- Adding or enforcing tags automatically.
- Deploying required settings (diagnostics, agents) with DeployIfNotExists.
✕ Think twice when…
- Deciding which people can act. Use RBAC.
- Protecting one critical resource from deletion. Use a lock.
- Going straight to Deny on a big estate without testing in Audit or DoNotEnforce first.
↔ Alternatives to consider
- Initiatives to manage many related rules together.
- Microsoft Defender for Cloud regulatory compliance, which is built on Policy initiatives.
Test yourself with exercises
5 original practice questions in the AZ-104 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What's the difference between Azure Policy and RBAC?
Model answer
RBAC decides who can do things. Policy decides what's allowed to exist, whoever does it. An Owner can still be stopped by an Allowed locations policy, because policy is about the resource, not the person.
Intermediate Deny or Audit for a new tagging rule?
Model answer
I'd usually start with Audit, or the assignment in DoNotEnforce mode, to see how many resources would fail without breaking anyone's deployments. Then move to Modify to add the tag automatically, or Deny if teams must supply it themselves.
Experienced developer Why does a Modify or DeployIfNotExists assignment need a managed identity?
Model answer
Because Policy itself makes the change, not the user. The assignment's managed identity needs a role such as Tag Contributor or Contributor on the scope. The portal creates and grants it for you on the Remediation tab; with the CLI you add --mi-system-assigned and --location, then assign the role.
Scenario You assigned Inherit a tag from the resource group, but old resources still don't have the tag. What now?
Model answer
Modify only acts on create and update requests. For resources that already existed I'd create a remediation task for the assignment, either from Policy, Remediation, or with az policy remediation create. It uses the managed identity to add the tag to every non-compliant resource.
Quick revision
Key points
- Definition (rule) → initiative (group) → assignment (scope + parameters + exclusions).
- Deny blocks; Audit flags; Modify and Append change the request; DeployIfNotExists deploys something related.
- Modify and DeployIfNotExists need a managed identity with the right role.
- Remediation tasks fix existing resources. Deny and Audit can't be remediated.
- Enforcement mode Disabled (DoNotEnforce) evaluates without blocking. Exemptions exclude specific resources.
Important terminology
- Policy definition
- A JSON rule with a condition and an effect, such as Allowed locations or Require a tag on resources.
- Initiative
- A set of policy definitions assigned together, for example a regulatory baseline.
- Assignment
- A definition or initiative applied to a scope with parameter values, exclusions and an enforcement mode.
- Effect
- What happens when a resource matches the rule - Deny, Audit, Append, Modify, DeployIfNotExists, AuditIfNotExists or Disabled.
- Remediation task
- A job that applies a Modify or DeployIfNotExists policy to resources that already exist.
- Exemption
- A record that excludes a resource or scope from an assignment, with a reason and optional expiry.
- Enforcement mode
- Enabled (Default) applies the effect; Disabled (DoNotEnforce) only evaluates compliance.
Common mistakes
- Expecting a new Deny policy to remove or fix resources that already exist. It only blocks new requests; old ones show non-compliant.
- Forgetting that resource groups themselves aren't checked by many resource-level policies like Require a tag on resources.
Exam tips
- "Prevent resources outside West Europe" = Allowed locations (Deny).
- "Add the tag automatically, including to existing resources" = Modify policy + remediation task.
- "Apply several policies as one unit" = an initiative.
Five quick revision questions
-
1.Which effects support remediation tasks?Show
Modify and DeployIfNotExists.
-
2.What does Audit do to a non-compliant resource?Show
Lets it be created or changed and marks it non-compliant.
-
3.Which enforcement mode tests a policy without blocking?Show
Disabled (DoNotEnforce).
-
4.What's a group of policy definitions called?Show
An initiative (policy set definition).
-
5.Which CLI command starts a remediation?Show
az policy remediation create --name ... --policy-assignment ...
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Resource Locks and Tags for Administrators
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.