Management and Governance Management locks verified

Resource delete protection

Resource delete protection is the safety guard you place around Azure resources that should not disappear during normal operations. In practice, it usually means applying a CanNotDelete management lock at a resource, resource group, or subscription scope. People with permission can still read the resource and often modify it, but delete operations are blocked until the lock is removed. It is not a backup, access policy, or data protection feature. It is a control-plane guardrail against accidental cleanup, rushed incident response, and risky automation.

Aliases
Azure delete protection, management lock delete protection, CanNotDelete lock, delete lock, protected Azure resource
Difficulty
fundamentals
CLI mappings
5
Last verified
2026-05-22

Microsoft Learn

Microsoft Learn describes Azure management locks as restrictions applied to a subscription, resource group, or resource to prevent accidental deletion or modification. A CanNotDelete lock permits reads and updates but blocks deletes, while a ReadOnly lock blocks changes across control-plane operations.

Microsoft Learn: Lock your Azure resources to protect your infrastructure2026-05-22

Technical context

In Azure architecture, resource delete protection sits in the Azure Resource Manager control plane. The lock is stored through Microsoft.Authorization and evaluated when management operations try to delete a locked resource or a child protected by inherited scope. It works beside RBAC, Azure Policy, deployment stacks, backup, and recovery controls, but it does not replace any of them. Operators use it on production resource groups, stateful services, networking foundations, shared monitoring, and backup-related resources where deletion would create a large blast radius. CLI exposes lock discovery, creation, and removal for repeatable governance.

Why it matters

Delete protection matters because many Azure outages are not caused by exotic failures; they are caused by someone or something deleting the wrong resource. A cleanup script, portal mistake, broken deployment, or rushed incident response can remove a resource group faster than a team can understand the dependency chain. A CanNotDelete lock adds a deliberate pause. It forces an engineer to identify the lock, justify removing it, and usually create a change record before deletion proceeds. That extra step protects production data stores, networking hubs, backup vaults, monitoring workspaces, and shared platform components. The business value is fewer irreversible mistakes, cleaner accountability, and more time to choose restore or rollback instead of emergency reconstruction.

Where you see it

Signals, screens, and Azure surfaces where this term usually becomes operational.

Signal 01

In the Azure portal Locks blade, a production resource group shows a CanNotDelete lock name, notes field, inherited scope, and delete operations fail until the lock is removed.

Signal 02

In az lock list output, the id, level, scope, and notes fields reveal whether protection is applied directly to the resource or inherited from a parent scope.

Signal 03

In Activity Log and deployment failures, delete attempts return lock-related errors, showing which lock blocked the operation and which identity attempted the change during cleanup.

When this becomes relevant

Specific situations where this term helps solve real Azure design, operations, migration, security, reliability, cost, or governance problems.

  • Protect production resource groups from accidental deletion during subscription cleanup, tenant migration, or automated environment pruning.
  • Guard shared platform assets such as private DNS zones, hub networks, recovery vaults, and Log Analytics workspaces from project-level mistakes.
  • Require a deliberate unlock step before deleting stateful resources whose recovery depends on backups, replicas, or service-specific restore procedures.
  • Create auditable evidence that critical resources were protected during high-risk release windows, disaster-recovery tests, or decommissioning reviews.
  • Stop deployment or cleanup scripts from removing resources outside their intended blast radius when names, tags, or scopes are wrong.

Real-world case studies

Different enterprise-style examples that show the term being used to hit measurable objectives.

Case study 01

Water utility prevents telemetry platform deletion

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

Northgate Water operated pump telemetry, alarm routing, and emergency dispatch dashboards in Azure. A contractor cleanup script almost deleted the production monitoring resource group while removing retired test environments.

Business/Technical Objectives
  • Block accidental deletion of production telemetry resources.
  • Keep authorized engineers able to patch and update services.
  • Create auditable unlock steps for emergency maintenance.
  • Reduce recovery exposure for shared monitoring and alerting assets.
Solution Using Resource delete protection

The platform team used resource delete protection by applying CanNotDelete locks to the production telemetry resource group, the shared Log Analytics workspace, and the private DNS zone used by field gateways. The locks were created with Azure CLI after Bicep deployment and named with owner and runbook references. RBAC stayed unchanged, so engineers could still update alert rules, scale compute, and rotate secrets. A break-glass procedure required two approvals before deleting any lock, and Activity Log alerts were added for Microsoft.Authorization lock delete events. The team also documented which resources were not locked because they were safe to recreate from infrastructure code.

Results & Business Impact
  • A second cleanup run deleted only retired test groups and skipped the locked production group.
  • Estimated worst-case telemetry outage exposure fell from eight hours to less than one hour.
  • Monthly lock reviews found three stale nonproduction locks before they preserved unnecessary cost.
  • Auditors accepted Activity Log evidence showing every lock removal and recreation event.
Key Takeaway for Glossary Readers

Resource delete protection adds a practical control-plane safety stop where a mistaken delete would be far more expensive than an extra approval step.

Case study 02

University protects grant-funded research platform

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A university genomics department shared Azure storage, compute, and workflow resources across several grants. Temporary student administrators sometimes removed old project resources without seeing hidden dependencies.

Business/Technical Objectives
  • Protect grant-funded shared infrastructure from accidental removal.
  • Allow project teams to clean up their own disposable environments.
  • Separate protected platform assets from experiment-specific resources.
  • Produce evidence for grant compliance and internal chargeback reviews.
Solution Using Resource delete protection

Cloud administrators placed CanNotDelete locks on the shared resource group containing the workflow scheduler, key vault, managed identity, and premium storage used by multiple research projects. Individual experiment resource groups stayed unlocked but were tagged with expiration dates. The team used CLI reports to list lock scopes, notes, and owner tags before each monthly cleanup. Azure Policy audited missing Owner and GrantId tags, while the lock notes pointed to the compliance contact and unlock procedure. The architecture avoided ReadOnly locks because researchers still needed controlled management updates during active analysis runs.

Results & Business Impact
  • No shared platform resources were deleted during the next four quarterly cleanup cycles.
  • Cleanup review time dropped from two days to five hours because protected and disposable groups were clearly separated.
  • Chargeback disputes fell by 31 percent after lock reports were paired with owner and grant tags.
  • The department avoided recreating a premium storage namespace that supported nine active studies.
Key Takeaway for Glossary Readers

Delete protection works best when critical shared resources are locked and disposable research environments remain easy to retire.

Case study 03

Airline operations adds unlock discipline

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A regional airline ran crew scheduling integrations through Azure Logic Apps, storage queues, and private endpoints. During an outage, responders nearly removed a resource group that looked like a failed staging deployment.

Business/Technical Objectives
  • Prevent emergency responders from deleting live integration components.
  • Keep maintenance actions fast enough for incident response.
  • Alert platform owners when delete protection changes.
  • Document which resources require post-incident relocking checks.
Solution Using Resource delete protection

The operations team applied resource delete protection to the crew scheduling production group and to the key private endpoint resources that connected partners to the integration workflow. Locks were created with Azure CLI and included notes linking to the incident runbook. The runbook allowed temporary unlock only after the incident commander confirmed the exact resource ID and recovery plan. Azure Monitor alerts watched for lock deletion, and a post-incident checklist verified that every expected lock was restored. Teams avoided ReadOnly locks because Logic App and integration maintenance required normal control-plane updates.

Results & Business Impact
  • A later incident avoided deleting the production queue namespace after the lock blocked the attempted cleanup command.
  • Mean time to identify protected resources fell from 22 minutes to six minutes using CLI lock reports.
  • No emergency maintenance step was blocked by unnecessary ReadOnly restrictions.
  • Post-incident reviews showed 100 percent relock completion across three high-severity events.
Key Takeaway for Glossary Readers

In live operations, delete protection turns a dangerous irreversible action into a deliberate, reviewable step without freezing ordinary maintenance.

Why use Azure CLI for this?

After ten years of Azure engineering work, I trust Azure CLI for delete protection because locks must be visible across scopes, not buried in one portal blade. CLI can list inherited locks, show exact lock IDs, create CanNotDelete locks during a release, and export evidence before a risky cleanup. It also makes lock handling repeatable in pipelines and runbooks. The portal is fine for one resource, but it is slow when checking dozens of production groups. With CLI, I can confirm tenant and subscription, prove which scope is protected, and remove a lock only through a controlled command that leaves a clear audit trail.

CLI use cases

  • Inventory CanNotDelete and ReadOnly locks before a cleanup script, migration, or subscription retirement touches production resource groups.
  • Create a named CanNotDelete lock automatically after deploying a protected platform resource group through Bicep or Terraform.
  • Export lock IDs, scopes, levels, and notes as change evidence before a risky resource deletion or disaster-recovery exercise.
  • Remove a lock by explicit ID during an approved maintenance window, then recreate it after validation instead of relying on portal clicks.
  • Compare expected lock coverage with actual lock inventory across subscriptions to find unprotected production resources and stale retired locks.

Before you run CLI

  • Confirm tenant, subscription, resource group, target resource, and whether the lock should apply at resource, resource group, or subscription scope.
  • Verify you have Microsoft.Authorization lock permissions; Owner and User Access Administrator usually can create or delete management locks.
  • Check whether a ReadOnly lock would block required POST operations such as start, scale, list keys, role assignment, backup cleanup, or provider actions.
  • Review destructive and cost risk: deleting a lock may allow immediate deletion, while creating a lock may prevent legitimate cleanup of expensive resources.
  • Use JSON output for automation and table output for human review; capture lock ID, level, notes, scope, and inherited context in the change record.

What output tells you

  • The level field shows CanNotDelete or ReadOnly, which determines whether delete operations only, or broader management changes, are blocked.
  • The id and scope identify whether the lock is attached to a subscription, resource group, or specific resource and which delete command must target it.
  • The notes field should explain the business reason for protection; blank notes usually mean the lock needs owner review before future changes.
  • A missing lock in a resource-level query does not prove the resource is unprotected; check parent resource group and subscription locks for inheritance.
  • Delete command success only removes the lock object. It does not delete the protected resource, fix data-plane permissions, or update backup settings.

Mapped Azure CLI commands

Resource delete protection CLI Commands

direct
az lock list --resource-group <resource-group> --output table
az lockdiscoverManagement and Governance
az lock create --name <lock-name> --lock-type CanNotDelete --resource-group <resource-group> --notes "Protect production resources from accidental deletion"
az locksecureManagement and Governance
az lock list --resource-group <resource-group> --resource-name <resource-name> --namespace <provider-namespace> --resource-type <resource-type> --output json
az lockdiscoverManagement and Governance
az lock show --name <lock-name> --resource-group <resource-group> --query "{id:id,level:level,notes:notes,scope:id}" --output json
az lockdiscoverManagement and Governance
lockid=$(az lock show --name <lock-name> --resource-group <resource-group> --query id -o tsv) && az lock delete --ids $lockid

Architecture context

A good Azure architect treats delete protection as a narrow but important part of the production control model. It belongs near RBAC, policy assignments, deployment stacks, backup, and incident runbooks. Use it where deletion is more dangerous than temporary operational friction: shared virtual networks, private DNS zones, recovery vaults, key vaults, Log Analytics workspaces, and production data platforms. Avoid blanket ReadOnly locks unless the operational side effects are understood, because many control-plane POST operations can be blocked. CanNotDelete is usually safer for production preservation. The design should also define who may remove locks, how exceptions are approved, and which automation checks for locks before destructive work. Locks should be deliberate, documented, and tested, not a surprise discovered during an outage.

Security

Security impact is indirect but real. A delete lock does not grant access, encrypt data, rotate secrets, or stop data-plane deletion inside a service. Its security value is protecting control-plane assets that support security controls, such as key vaults, diagnostic settings, private DNS zones, firewalls, and monitoring workspaces. The risk is assuming a lock replaces RBAC or backup. It does not. Users with data-plane permissions may still change or delete service data, and people with Microsoft.Authorization lock permissions can remove the lock. Protect lock management with least privilege, Privileged Identity Management, change approval, and activity log monitoring. Treat unexpected lock removal as a security event because it lowers a defensive barrier.

Cost

Delete protection has no direct SKU charge, but it strongly affects cost control. A lock can prevent accidental deletion of expensive-to-rebuild assets, which avoids emergency labor, data recovery work, support tickets, and business downtime. It can also keep unused resources alive if teams forget that a lock blocks cleanup. FinOps teams should distinguish intentional production protection from stale lock debt. Cost reviews need lock inventory, owner tags, environment tags, and a process for removing protection from retired workloads. The expensive mistake is leaving orphaned premium storage, idle App Service plans, or unused managed disks protected forever because nobody can confidently delete them. Good lock governance protects value without preserving waste.

Reliability

Reliability impact is direct at the control plane. Delete protection reduces the chance that a critical resource disappears during cleanup, deployment rollback, or incident triage. It also narrows blast radius when a script targets the wrong group. The tradeoff is operational friction: locks can block legitimate deletion, resource moves, backup cleanup, autoscale behavior, or service-managed cleanup in some scenarios. Reliable use means applying locks only where the recovery value is worth the constraint, documenting removal steps, and testing runbooks that require temporary unlock. Pair locks with backups, soft delete, deployment what-if, and clear ownership. A lock should buy time to prevent accidental loss, not become a hidden cause of failed maintenance.

Performance

Runtime performance is usually not affected by delete protection because locks act on Azure Resource Manager control-plane operations, not normal application traffic. Operational performance is affected. A well-named CanNotDelete lock helps engineers quickly understand why a delete failed and prevents wasted time during risky cleanup. A poorly documented lock slows deployments, migrations, and automation because teams must investigate whether the block is intentional. ReadOnly locks can reduce operational speed more severely by blocking POST-style management actions that look like reads, such as list keys or start operations. Use CLI output, lock notes, and runbook references to make protected resources fast to identify and safe to change.

Operations

Operators manage delete protection by listing locks, checking inherited scope, creating named CanNotDelete locks, and recording why a lock exists. In real environments, the work usually happens before cleanup, migration, disaster-recovery testing, subscription decommissioning, or platform changes. CLI and Azure Resource Graph can inventory locks across subscriptions, while Activity Log shows who created, changed, or removed them. Runbooks should state whether a resource group has expected locks, who approves removal, and what must be verified after relocking. Operators also watch for side effects, especially on backup-managed groups, service-managed resource groups, storage accounts, and network resources where locked control-plane operations can surprise application teams.

Common mistakes

  • Assuming CanNotDelete protects service data when it only blocks Azure Resource Manager delete operations, not every data-plane delete inside the service.
  • Applying ReadOnly at a broad resource group scope and then discovering scale, start, list keys, backup cleanup, or diagnostic changes are blocked.
  • Deleting a lock during maintenance and forgetting to recreate it, leaving critical production resources exposed after the change window.
  • Using locks as a substitute for RBAC, backups, soft delete, private networking, or deployment what-if instead of layering controls.
  • Leaving retired resources locked for months, which prevents cleanup and creates avoidable spend that nobody feels safe removing.