BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeDesigning Microsoft Azure Infrastructure Solutions (AZ-305)Build Lab — Assign one policy and watch it refuse a deployment
Build Lab480 words

Build Lab — Assign one policy and watch it refuse a deployment

AZ-305 › Unit 1 › Design governance

Build Lab — Assign one policy and watch it refuse a deployment

Build brief

Unit
1 — Identity, governance, monitoring
You need
Your own Azure subscription
Time
20 minutes
Cost
No billable resource is created
Interface
Azure CLI

This is the hands-on twin of the design lab "Put each control at the scope that owns it". There you decided where a control belongs. Here you assign one, put a subscription under it, and watch Azure refuse a deployment that breaks it — which is the part that makes the scope argument stop being abstract.

Read before you run anything

These commands run against YOUR subscription and create real objects: a management group and a policy assignment. Neither provisions compute or storage, so this lab creates nothing that bills by the hour — but a policy assignment DOES affect what can be deployed in the scope you attach it to. Do not attach it to a management group containing production subscriptions. Teardown is at the end and removes everything this lab creates.

Before you start

  • The Azure CLI installed, and az login completed.
  • Permission to create management groups. On many tenants this is restricted; if the first command fails with an authorization error, skip to If it did not work — that failure is itself worth understanding.
  • Your subscription id to hand: az account show --query id -o tsv

What you are building

Loading Diagram...
Figure 1 — Mermaid diagram

Step 1 — create the management group

bash
az account management-group create \ --name bb-lab-eu \ --display-name "BB Lab — EU boundary"

You should get a JSON object back with "name": "bb-lab-eu". Creation is asynchronous; if a later command says the group is not found, wait a few seconds and retry.

Step 2 — move your subscription under it

bash
az account management-group subscription add \ --name bb-lab-eu \ --subscription "$(az account show --query id -o tsv)"

This is the step the design lab was really about: the subscription now inherits anything assigned at that group.

Step 3 — find the built-in policy by name

bash
az policy definition list \ --query "[?displayName=='Allowed locations'].{name:name, id:id}" -o table

Look up the definition by display name rather than pasting a GUID — the id is stable, but looking it up is the habit that survives the id changing and works for any built-in.

Step 4 — assign it at the management group

bash
az policy assignment create \ --name bb-lab-allowed-locations \ --display-name "BB Lab — EU regions only" \ --scope "/providers/Microsoft.Management/managementGroups/bb-lab-eu" \ --policy "$(az policy definition list --query "[?displayName=='Allowed locations'].name" -o tsv)" \ --params '{"listOfAllowedLocations":{"value":["westeurope","northeurope"]}}'

One assignment. Note the scope: a management group path, not a subscription or resource group.

Step 5 — prove it works, in both directions

Allowed region — this should succeed:

bash
az group create --name bb-lab-ok --location westeurope

Disallowed region — this should be refused:

bash
az group create --name bb-lab-blocked --location eastus

Checkpoint

The second command must fail with a policy error naming RequestDisallowedByPolicy. If it succeeded, the assignment has not propagated yet — policy evaluation is not instant. Wait a few minutes and try again before assuming something is wrong.

Look carefully at what refused you. It was not a role, a lock, or a quota. It was a rule assigned once, at a scope above the subscription, that you never attached to this resource group — because the resource group did not exist when you assigned it. That is inheritance, and it is the entire argument of the design lab in one error message.

Why this matters on the exam

Multiple choice · MediumPolicy scope and inheritance

You just watched a policy assigned at a management group refuse a deployment into a resource group created afterwards. Which exam claim does that experiment support?

Teardown

Run all of it. The first two commands remove what could affect future deployments.

bash
az policy assignment delete \ --name bb-lab-allowed-locations \ --scope "/providers/Microsoft.Management/managementGroups/bb-lab-eu" az group delete --name bb-lab-ok --yes --no-wait az account management-group subscription remove \ --name bb-lab-eu \ --subscription "$(az account show --query id -o tsv)" az account management-group delete --name bb-lab-eu

Verify nothing is left:

bash
az policy assignment list --query "[?name=='bb-lab-allowed-locations']" -o table az account management-group list --query "[?name=='bb-lab-eu']" -o table

Both should return nothing.

If it did not work

The three failures worth understanding

  1. 1

    'Authorization failed' on step 1

    Creating management groups can be restricted at the tenant, and by default the creator needs the right at root scope. This is not a broken lab — it is the governance model working. If you cannot create one, read steps 3-5 and run the policy assignment against your SUBSCRIPTION scope instead: everything works the same except the inheritance-to-future-subscriptions property, which is the one thing you cannot demonstrate that way.

Next

Go back to the design lab "Put each control at the scope that owns it" and re-answer the four cards. The forty-assignments question in that brief should now read differently: you have seen the window where a subscription exists but its rule does not.

All Designing Microsoft Azure Infrastructure Solutions (AZ-305) Study Resources

Related Notes

  • Cram Sheet — Design governance621 words
  • Design Governance — Topic Lesson5,170 words
  • Design Lab — Put each control at the scope that owns it302 words
  • Design Studio — Design governance732 words
  • Quick Note — Recommend a Solution for Identity Governance817 words
  • Recommend a Solution for Identity Governance — Lesson6,121 words
  • Quick Note — Recommend a Solution for Managing Compliance792 words
  • Recommend a Solution for Managing Compliance — Lesson4,603 words
  • Quick Note — Recommend a Structure for Management Groups, Subscriptions, Resource Groups, and Tagging832 words
  • Recommend a Structure for Management Groups, Subscriptions, Resource Groups, and Tagging — Lesson5,361 words
  • AZ-305 Exam Map and Design Decision Playbook652 words
  • Unit 1 Capstone — Design identity, governance, and monitoring solutions668 words

Ready to study Designing Microsoft Azure Infrastructure Solutions (AZ-305)?

Practice tests, flashcards, and all study notes — free, no sign-up.

Start Studying

Ready to study Designing Microsoft Azure Infrastructure Solutions (AZ-305)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free
Designing Microsoft Azure Infrastructure Solutions (AZ-305) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.

Loading Diagram...
Flowchart, top to bottom. Management group<br/>bb-lab-eu connects to Allowed locations<br/>= westeurope, northeurope ("policy assigned HERE, once"). Management group<br/>bb-lab-eu"] -->|"policy assigned HERE, once"| B["Allowed locations<br/>= westeurope, northeurope connects to Your subscription<br/>moved under it. C connects to Deployment in westeurope<br/>✅ allowed. C connects to Deployment in eastus<br/>❌ refused by policy.