Resource Locks and Tags for Administrators
30-second answer
A resource lock stops changes for everyone, Owners included. CanNotDelete (Delete in the portal) lets people read and update but not delete; ReadOnly blocks every write, so it can also break things like listing storage account keys or scaling an App Service plan. Locks are set at subscription, resource group or resource scope, inherit to child resources, and removing one needs Microsoft.Authorization/locks/delete (Owner or User Access Administrator). Tags are name/value pairs (up to 50 per resource) used for cost, ownership and automation. Resource group tags aren't inherited by resources; use Azure Policy (Inherit a tag, Require a tag) to apply them at scale.
Exam objective: 1.3.2 Configure resource locks. 1.3.3 Apply and manage tags on resources. (Skills measured as of April 17, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open <strong>rg-finance</strong> and, under <strong>Settings</strong>, select <strong>Locks</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open rg-finance and, under Settings, select Locks.
- No locks yet. Select + Add.
- Delete (CanNotDelete) allows changes but blocks deletion. Read-only blocks every write, even tags and some actions that sound like reads, such as listing storage keys.
- CLI: az lock create -n no-delete -t CanNotDelete -g rg-finance. Now Tags.
- Tags are name/value pairs. A resource group's tags aren't inherited by its resources unless a policy copies them.
- To tag many resources at once, select them in All resources and use Assign tags. At scale, the Inherit a tag from the resource group policy keeps everything consistent.
- Tags pay off in Cost analysis: group by tag costcenter and each department sees its share. Untagged spend is the gap to chase.
🧪 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
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.
🤔 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
Someone deleted the production database resource group on a Friday evening.
😊 THE SOLUTION
Lock production against deletion and tag everything for ownership and cost.
- Accidental deletes✓ CanNotDelete lock
- Changes during an audit✓ ReadOnly lock for a short freeze
- Who owns this?✓ owner and costcenter tags
Start with a question
How do museums stop anyone, even staff, from moving the most valuable painting?
A museum puts the famous painting behind glass with a lock. Curators can still dim the lights and adjust the label, but nobody lifts it off the wall without first getting the key from security. During a stocktake they lock the whole room, so nothing gets touched at all. And every item has a little card saying who donated it and which gallery pays for its care.
The glass case is a CanNotDelete lock, the locked room is a ReadOnly lock, and the little card is a set of tags.
Explain it like I’m 10
The technical explanation
Resource locks
| CanNotDelete (portal: Delete) | ReadOnly (portal: Read-only) | |
|---|---|---|
| Read | Yes | Yes |
| Update, tag, scale, start | Yes | No |
| Delete | No | No |
| Side effects | Few | Blocks POST actions like listing storage keys; can stop App Service, VMs and backups working normally |
| Typical use | Production, always on | Short freezes, audits |
- Scopes: subscription, resource group or resource. A lock on a parent applies to everything under it, including resources created later. The most restrictive lock wins.
- Locks affect the control plane only. A CanNotDelete lock on a storage account doesn’t stop someone deleting a blob inside it.
- Locks apply to everyone. To remove one you need
Microsoft.Authorization/locks/delete, which Owner and User Access Administrator have and Contributor doesn’t.
Portal: resource or group → Settings → Locks → + Add → Lock name, Lock type (Read-only or Delete), Notes.
az lock create --name no-delete --lock-type CanNotDelete --resource-group rg-finance --notes "Finance production"
az lock create --name freeze --lock-type ReadOnly --resource-group rg-finance \
--resource-name stfin0424 --resource-type Microsoft.Storage/storageAccounts
az lock list --resource-group rg-finance -o table
az lock delete --name freeze --resource-group rg-finance --resource-name stfin0424 --resource-type Microsoft.Storage/storageAccounts
New-AzResourceLock -LockName no-delete -LockLevel CanNotDelete -ResourceGroupName rg-finance
Tags
A tag is name: value, such as costcenter: FIN-042, env: prod, owner: finance-ops@contoso.com. Each resource, resource group or subscription can have up to 50 tags. Names are case-insensitive, values case-sensitive, and some resource types don’t support tags.
az group update -n rg-finance --tags costcenter=FIN-042 env=prod # replaces the group's tags
az tag update --resource-id <id> --operation Merge --tags owner=finance-ops # adds without wiping
az resource tag -g rg-finance -n stfin0424 --resource-type Microsoft.Storage/storageAccounts --tags costcenter=FIN-042
Use --operation Merge to add tags and keep the existing ones; Replace swaps the whole set and Delete removes the ones you list. You need write access to the resource or the Tag Contributor role to change tags. A ReadOnly lock blocks tag changes too.
Tags at scale
Resource group tags aren’t inherited. To make them stick everywhere:
- Inherit a tag from the resource group if missing (Modify) copies the group’s tag to resources, with a remediation task for existing ones.
- Require a tag on resources or on resource groups (Deny) forces people to supply one.
- All resources → select → Assign tags tags many resources in the portal at once.
- Cost Management’s tag inheritance setting applies group and subscription tags to cost records only, without changing the resources.
-
1 Lock
CanNotDelete on rg-finance: deletes fail, changes still work.
-
2 Tag
rg-finance gets costcenter=FIN-042 and owner=finance-ops.
-
3 Inherit
A Modify policy copies costcenter onto every resource inside.
-
4 Report
Cost analysis groups spend by costcenter for the monthly chargeback.
Architect level Locks, deployments and automation
ARM template and Bicep deployments in Complete mode try to delete resources that aren’t in the template, and a CanNotDelete lock will make that fail. Backup and Site Recovery need write access to restore points, so a ReadOnly lock on a VM’s resource group can break backups. Some services create their own locks; for example, a Recovery Services vault may add one. If automation must remove and re-add a lock, give its managed identity a narrow custom role with only the lock actions rather than Owner.
Real-world business scenario
Woodgrove Bank (fictional)
- The problem
- A script cleaning up test resource groups matched the wrong name and deleted a production resource group, and nobody could tell which team owned half the remaining resources.
- What they used
- CanNotDelete locks on every production resource group (applied through a pipeline), owner and costcenter tags required on resource groups by a Deny policy, and the Inherit a tag policy copying them to resources. ReadOnly locks are used only during quarter-end audit freezes.
- Why that choice
- Scripts and people can still update production, but deletes fail until a platform admin removes the lock on purpose, and every resource shows an owner.
- The result
- No accidental production deletions since, and the chargeback report covers 98% of spend.
When to use it and when not to
✓ Use it when…
- CanNotDelete on production subscriptions, resource groups and shared networking.
- ReadOnly for short, planned freezes.
- Tags for cost center, owner, environment and automation schedules.
✕ Think twice when…
- Long-term ReadOnly on resources that need normal operations (scaling, backups, key listing).
- Relying on resource group tags to label resources without a policy.
↔ Alternatives to consider
- Azure RBAC to stop specific people deleting things, rather than everyone.
- Deployment stacks deny settings to protect everything a stack deployed.
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 a Delete lock and a ReadOnly lock?
Model answer
A Delete lock, CanNotDelete, lets people keep working on the resource but stops anyone deleting it. ReadOnly stops any change at all, including tags. I use Delete on production all the time and ReadOnly only for short freezes.
Intermediate Why might a ReadOnly lock break an app?
Model answer
Because some operations that feel like reads are actually POST requests in Azure Resource Manager. Listing storage account keys is one, so anything that reads keys through the management API fails. Scaling a plan, starting a VM or adding a tag also stop working.
Experienced developer Do resource group tags flow down to resources?
Model answer
No, not by themselves. I'd assign the built-in Inherit a tag from the resource group if missing policy with a managed identity, plus a remediation task for existing resources. Cost Management also has a tag inheritance setting, but that only affects cost data, not the resources' actual tags.
Scenario An Owner can't delete a resource group they created. What's going on?
Model answer
Almost certainly a lock, on the group or inherited from the subscription. Locks apply to everyone. They'd check Locks on the group and the subscription, remove it if that's the right call, then delete. If there's no lock, I'd check for a deny assignment from a deployment stack.
Quick revision
Key points
- CanNotDelete = no deletes, updates allowed. ReadOnly = no writes at all.
- Locks apply to every user, including Owners, and inherit from parent scopes.
- Removing a lock needs Microsoft.Authorization/locks/delete (Owner, User Access Administrator).
- Tags are name/value pairs, up to 50 per resource. Not every resource type supports tags.
- Resource group tags don't flow to resources unless a policy copies them.
Important terminology
- CanNotDelete lock
- Called Delete in the portal. Users can read and modify a resource but can't delete it.
- ReadOnly lock
- Users can read a resource but can't update or delete it. Some POST operations are blocked too.
- Lock inheritance
- A lock on a subscription or resource group applies to every resource inside it, including ones added later.
- Tag
- A name and value pair on a resource, resource group or subscription, such as costcenter = FIN-042.
- Tag inheritance
- Copying a resource group's or subscription's tag to its resources, done with Azure Policy or Cost Management tag inheritance.
- Tag Contributor
- A built-in role that can manage tags on resources without access to the resources themselves.
Common mistakes
- Putting ReadOnly on a busy production resource group and breaking normal operations.
- Expecting resources to inherit a tag from their resource group automatically.
Exam tips
- "Prevent accidental deletion but allow changes" = CanNotDelete (Delete).
- "Prevent any change" = ReadOnly.
- "Every resource must carry its resource group's costcenter tag" = Inherit a tag policy (+ remediation).
Five quick revision questions
-
1.Which lock still allows updates?Show
CanNotDelete (Delete).
-
2.Does a lock stop an Owner?Show
Yes. Locks apply to everyone.
-
3.Which command creates a lock on a resource group?Show
az lock create --name ... --lock-type CanNotDelete --resource-group ...
-
4.How many tags can a resource have?Show
Up to 50.
-
5.Are resource group tags inherited by resources by default?Show
No.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Resource Groups, Subscriptions and Management Groups
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.