Skill 1.3.2

Configure resource locks

Key Concepts

A lock is applied to a subscription, resource group or resource and has one of two levels. CanNotDelete (Delete in the portal) lets authorized users read and modify the resource but not delete it. ReadOnly lets users read the resource but not delete or update it, which behaves like restricting everyone to the Reader role. Locks are inherited by child resources, and when several locks apply, the most restrictive one takes effect.

Locks apply to every user, including Owners, so a lock must be removed before a protected operation can run; only users with Microsoft.Authorization/locks/* permissions, such as Owner and User Access Administrator, can create or delete locks. Locks apply to control plane operations only. A ReadOnly lock can have surprising effects: on a storage account it blocks listing keys, so the portal cannot show data with key authorization, and on a resource group it blocks starting or resizing VMs. A resource group with a CanNotDelete lock cannot be deleted, and neither can the resources in it.