Infrastructure

Azure Blob Storage: diagnose a blocking lease before breaking it

A production runbook for identifying an Azure Blob lease holder, preventing concurrent workers and choosing controlled recovery or a lease break.

20 Nov 2026 azurestorageblob-storageconcurrencyautomationobservabilityrunbookrollbackproduction

A production export has stopped: a worker receives a lease error on the blob used to coordinate the job. Restarting the job or breaking the lease looks quick. The previous worker, however, may still be calling external systems even when it can no longer write that blob. Two workers can then create side effects that Storage cannot undo.

In this scenario, a batch uses a blob as a lock before publishing an export. The next run cannot acquire the lease. The task is to establish whether the holder is still working, protect business side effects, and decide whether to wait, release normally or break the lease under controlled conditions.

Contain first

Pause new triggers and automatic retries for this job without blindly stopping every worker. Name an incident owner and record the incident window, account, container, exact blob name, environment and last confirmed export. Do not put keys, SAS tokens or lease IDs in a broadly accessible ticket.

Check the application contract: does this blob protect only a Storage write, or also a publication, payment, API call or another system? A blob lease controls operations on that blob; it does not by itself fence external side effects. If the old worker cannot be isolated and those effects are not deduplicated, keep the job paused.

Read state and identify the holder

Using an identity authorized to read the data plane, inspect the exact blob:

bash 01-inspect-blob.sh
ACCOUNT="stexampleprod"
CONTAINER="coordination"
BLOB="exports/daily.lock"

az storage blob show --account-name "$ACCOUNT" --container-name "$CONTAINER" --name "$BLOB" --auth-mode login --output json

Record the lease properties, ETag and last-modified time from the response. Do not assume that last-modified time represents the latest business activity. A 403 or network failure is not evidence of a blocking lease: first qualify identity, target and access. The properties do not prove who holds the lease.

Correlate scheduler and worker traces: execution ID, instance, acquisition and renewal times, latest business step, errors and process state. Compare available Storage operations with application logs without exposing secrets. Missing logs may indicate broken collection, not a stopped worker. For a Terraform lock or another tool-managed lock, use that tool’s unlock procedure first: the underlying lease may protect critical state.

Interpret the lease, not just the clock

Observed stateOperational reading
LeasedThe blob is locked. Identify and contact the holder; an active lease does not prove useful progress.
BreakingA break is in progress. Wait for the break period and reread state before attempting acquisition.
Expired, Broken or AvailableThe lock is no longer active, but that does not prove the former process or its external effects have stopped.

A fixed-duration lease can expire or be renewed; an infinite lease will not simply time out. A holder with its lease ID can release normally. An authorized break does not require that ID and makes the lease nonrenewable. Depending on the requested period and remaining time, unlocking may not be immediate. See Microsoft’s lease states and operations for the precise semantics.

Choose a bounded action

  1. Wait when the holder is known and progressing, or a safe completion is near. Set a reassessment deadline and keep new jobs paused.
  2. Release normally when the owner confirms completion and the holder can release its own lease. Then verify state and business effects.
  3. Break only when the owner approves the exact target, the former holder is stopped or isolated from every relevant side effect, and business state has been reconciled. A timeout alone is insufficient.
  4. Keep the stop in place when the holder, impact or recovery path remains unknown.

Before a break, preserve the ETag, observed state, evidence of stopping or isolation, decision, time and accountable owner. Prepare export reconciliation and a way to pause recovery immediately. If the application relies on a wider lock than this blob, restore that protection too.

Break and resume under observation

This example is for an approved intervention on the identified blob only. Check parameters and permissions in the Azure CLI reference. The command changes real state; it is not a dry run.

bash 02-break-approved-lease.sh
az storage blob lease break --account-name "$ACCOUNT" --container-name "$CONTAINER" --blob-name "$BLOB" --auth-mode login --lease-break-period 15 --output json

Fifteen seconds is an example, not a universal delay. Record the returned interval, wait and reread the properties; a successful request does not mean a new lease is already available. A break cannot be undone for that lease: its ID cannot be restored. If the request fails or state is ambiguous, do not launch parallel retries.

Allow one controlled execution through the normal application path. Observe acquisition, progress, result and release. Reconcile the business identifier and export against the last confirmed output; check for duplicates and integrity with the receiving system. Re-enable the scheduler gradually only after the owner validates the result.

Rollback and decision

If the canary fails, the old worker reappears or an unexpected action occurs, pause triggers again and isolate producers. Do not automatically break another lease. Compare outputs and external effects, then use the approved compensation or restore procedure with the business owner: restoring a previous file does not retract an action already received by an API.

Resume only when the former holder is controlled, one producer has completed and released its lease, and effects have been reconciled. Otherwise, a controlled stop remains the production decision.