Resource Locks
😟 THE PROBLEM
A clean-up script deletes the production resource group by mistake.
😊 THE SOLUTION
Put Delete or ReadOnly locks on critical resources.
- Accidental deletion✓ Delete lock blocks it
- Unwanted changes✓ ReadOnly lock
- Admins can do anything✓ Locks apply even to Owners
Quick answer
Resource locks prevent resources from being accidentally deleted or changed. A Delete lock (CanNotDelete) allows changes but blocks deletion. A ReadOnly lock blocks both changes and deletion. Locks can be applied to subscriptions, resource groups or individual resources, are inherited by child resources, and apply to everyone, even Owners, until the lock is removed.
Exam objective: 3.2.3 Describe the purpose of resource locks. (Skills measured as of July 20, 2026)
Start with a question
What stops a tired admin deleting the production database at 2 a.m.?
A resource lock. Even with full permissions, the delete simply fails.
Explain it like I’m 10
The technical explanation
| Lock | Read | Modify | Delete |
|---|---|---|---|
| Delete (CanNotDelete) | ✅ | ✅ | ❌ |
| ReadOnly | ✅ | ❌ | ❌ |
Locks override RBAC: even an Owner must remove the lock before deleting or changing a locked resource.
Real-world business scenario
An online bank
- The problem
- A clean-up script deleted the wrong resource group, taking down a payment service.
- What they used
- Delete locks on all production resource groups, with lock removal limited to a small ops group.
- Why that choice
- Locks block deletion regardless of permissions.
- The result
- A later scripting mistake was blocked by the lock with no impact.
When to use it and when not to
✓ Use it when…
- Production and shared resources that must never be deleted by accident.
✕ Think twice when…
- ReadOnly locks on resources that need normal operations like scaling.
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 is a resource lock?
Model answer
A safety catch on an Azure resource that stops it from being deleted, or changed, by mistake.
Intermediate What is the difference between Delete and ReadOnly locks?
Model answer
A Delete lock still lets you change the resource but not delete it. A ReadOnly lock stops both changes and deletion, making it effectively read-only.
Experienced developer What surprises can ReadOnly locks cause?
Model answer
Some operations that look like reads are actually writes in Azure Resource Manager. For example, listing storage account keys is a POST, so a ReadOnly lock can block it. A ReadOnly lock on a resource group can also block scaling or creating resources inside it. Test locks before applying them broadly.
Test yourself with exercises
3 original practice questions in the AZ-900 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.
Quick revision
Key points
- Locks prevent accidental deletion or modification.
- Delete (CanNotDelete) vs ReadOnly.
- Apply at subscription, resource group or resource; inherited downward.
- Locks apply to all users, including Owners.
- Remove the lock first to make the change.
Important terminology
- Delete lock (CanNotDelete)
- Users can read and modify a resource but cannot delete it.
- ReadOnly lock
- Users can read a resource but cannot modify or delete it.
- Lock inheritance
- A lock on a resource group or subscription applies to everything inside.
Common mistakes
- Thinking Owners can bypass locks.
Exam tips
- "Prevent accidental deletion but allow changes" = Delete (CanNotDelete) lock.
Five quick revision questions
-
1.Which lock allows changes but blocks deletion?Show
Delete (CanNotDelete).
-
2.Which lock blocks changes and deletion?Show
ReadOnly.
-
3.Can an Owner delete a locked resource?Show
Not until the lock is removed.
-
4.Are locks inherited?Show
Yes, by resources within the locked scope.
-
5.Where can locks be applied?Show
Subscriptions, resource groups and resources.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Azure Portal