Run az group delete against the wrong resource group and production is gone. A resource lock stops that, and it's a single command.
Lock a resource group so nobody can delete anything in it:
az lock create --name no-delete --lock-type CanNotDelete --resource-group prod-rg
CanNotDelete still lets people read and change resources; it refuses deletion until someone removes the lock. To freeze something completely, with no changes at all, use ReadOnly instead.
A lock applies to everything inside its scope (the level you put it on: a subscription, a resource group or a single resource), so one on the resource group protects every resource in it, including ones created later.
Here's the same lock in Terraform, so it lives in a repo:
data "azurerm_resource_group" "prod" {
name = "prod-rg"
}
resource "azurerm_management_lock" "no_delete" {
name = "no-delete"
scope = data.azurerm_resource_group.prod.id
lock_level = "CanNotDelete"
notes = "Protects production from accidental deletion."
}
Removing the lock is a deliberate second step, which is the point. At scale you can apply locks automatically across a management-group hierarchy.
The full, runnable version is in the blog-examples repo.