What resource locks do
- Protect resources from accidental modification or deletion.
- Act like a safety cover on a switch: prevent unintended on/off or removal.
- Can be applied at three scopes: subscription, resource group, or single resource. Locks at a parent scope are inherited by child scopes.
- Enforced consistently across Azure Portal, ARM, CLI, and SDKs.
Types of locks

To create, modify, or delete management locks you need appropriate RBAC permissions (for example, Owner, User Access Administrator, or a custom role that includes
Microsoft.Authorization/locks/* or Microsoft.Authorization/* actions for the target scope). Ensure your account has these permissions before planning lock changes.Hands-on: Creating locks in the Azure portal
- In the Azure portal, open the target resource group that contains the resource to protect.
- Select the resource (for example, an Automation Account). In the resource’s left menu, choose Locks.
- Click Add to create a new lock:
- Enter a name (for example,
DNDfor Do Not Delete). - Choose the lock type:
CanNotDelete(delete lock) orReadOnly. - Optionally add a note explaining the lock’s purpose.
- Select Save.
- Enter a name (for example,
- With a delete lock in place, attempts to delete the resource will fail with a scope-locked error. To delete the resource you must first remove the lock.

Difference between delete and read-only locks
CanNotDelete(Delete lock): You can still modify the resource (for example, add or edit runbooks in an Automation Account), but you cannot delete it.ReadOnly: Blocks all modifications. Creating or updating child resources or properties is prevented while this lock is present.
- With a delete lock on an Automation Account you can create a new runbook (PowerShell or Python) — the operation succeeds.
- Replace the delete lock with a read-only lock (for example, name it
RO). Attempts to create new runbooks or change the resource will now fail with aScopeLockederror.

Inheritance: locks at higher scopes
- Locks applied at the resource group level are inherited by all resources in that resource group.
- Locks applied at the subscription level apply to every resource in the subscription.
- Inherited locks behave the same way as locks set directly on the resource: they block deletion or modification according to the lock type.
- Add a
CanNotDeletelock calledRG lockto a resource group. Attempts to delete a VM (and its disks/NICs) inside that group will fail because the VM inherits the delete lock.
Best practices
Be careful when removing locks to perform changes. Only users with adequate RBAC should remove or alter locks. After completing the change, reapply the lock immediately to restore protection.