What are resource locks and what are their gotchas?
IntermediateConceptFundamentals and Resource Hierarchy
Answer
Locks protect against deletion or modification regardless of RBAC. Two levels: CanNotDelete and ReadOnly. They inherit downward.
Gotchas:
- ReadOnly on a storage account blocks
listKeys, which breaks anything using account keys. - ReadOnly on an AKS RG or the node RG breaks scaling and upgrades.
- A lock on an RG blocks
terraform destroywithScopeLocked.
az lock create -n no-delete -g rg-shop-prod --lock-type CanNotDelete
az lock list -g rg-shop-prod -o table
We use CanNotDelete on prod data stores and shared networking, and almost never ReadOnly.
More on Fundamentals and Resource Hierarchy
Explain the Azure resource hierarchy from top to bottom.BeginnerWhat is the difference between an Entra tenant and a subscription?BeginnerWhat should go into a resource group and what should not?BeginnerWhat are regions, region pairs and availability zones in Azure?BeginnerWhy do logical zone numbers differ between subscriptions?IntermediateWhat is Azure Resource Manager (ARM)?Beginner