Home / Azure

AzureChecklistAdvanced

Rolling out immutable Blob Storage (WORM): container vs version-level policies, locking and the traps before you commit

A checklist for rolling out WORM retention on Azure Blob Storage. Choose container-level or version-level scope, test unlocked, lock deliberately and plan for cost, lifecycle rules and deletion blocks.

Deepak Bhardwaj8 min read

Applies toAzure Blob Storage (general-purpose v2 and premium block blob), container-level and version-level immutability, Azure CLI 2.60+, Az.Storage PowerShell

Why a checklist

Immutable storage is one of the few Azure settings you can't undo. A locked time-based retention policy can be extended but never shortened or removed. Protected blobs can't be deleted or overwritten by anyone, including subscription owners and Microsoft Support. The account can't be deleted while protected data exists. Get the scope, period or account wrong and you either pay for years of storage you didn't need, or build a "protection" that ransomware can still get around.

Go through this list in order, and don't lock anything until every box before step 6 is ticked.

1. Decide what you're protecting against

  • Regulatory retention (SEC 17a-4(f), FINRA, CFTC style). You need a locked time-based policy and evidence of it.
  • Ransomware and insider deletion of backups or logs. A locked policy, or an unlocked policy plus a strict RBAC split, may be enough. Decide which.
  • Litigation hold with no known end date. Use a legal hold, not a long retention period.
  • Write-once audit logs where new entries are appended. You need protected append writes.

Tip

If what you really want is immutable backups of VMs, SQL or files, an immutable Recovery Services or Backup vault is usually the better tool. Blob WORM fits data you write directly: exports, logs, documents and third-party backup targets.

2. Choose the scope

Container-level WORM Version-level WORM
Policy applies to Every blob in the container, with one period Each blob version, with a per-version expiry; can default from the container or account
Blob versioning Not required Required
Overwrite behaviour Blocked Overwrite creates a new version; earlier versions stay protected
Hierarchical namespace (ADLS Gen2) Supported Not supported, because versioning isn't available with HNS (check current docs)
Different retention per blob No Yes
Best for Simple compliance archives, Data Lake Backup targets, mixed retention, apps that overwrite
  • Scope chosen per container and written down with the reason.
  • For version-level: confirm that every application writing to the container can live with versioning (extra versions cost money, and lifecycle rules must handle them).

3. Prepare the account

RG=rg-records
ST=strecordsprod01

az storage account show -g $RG -n $ST \
  --query "{kind:kind, sku:sku.name, hns:isHnsEnabled, sharedKey:allowSharedKeyAccess}" -o json

# Version-level WORM needs versioning
az storage account blob-service-properties update -g $RG -n $ST --enable-versioning true
  • Redundancy decided before writing protected data (ZRS/GZRS for production). Changing redundancy later is possible but slower on large accounts.
  • Shared key access disabled, or at least restricted, so protection doesn't hang on a key that can leak.
  • A CanNotDelete resource lock on the account, which guards the unlocked-policy phase and any containers without policies:
az lock create -g $RG -n lock-$ST --lock-type CanNotDelete \
  --resource-type Microsoft.Storage/storageAccounts --resource $ST
  • Who may change immutability policies is restricted. Policy changes are management-plane operations on the container (Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies/*). Grant them only to a small, PIM-protected role.

4. Create policies unlocked and test them

Container-level, with protected append writes for log-style data:

az storage container immutability-policy create -g $RG --account-name $ST \
  --container-name audit-logs --period 2555 \
  --allow-protected-append-writes-all true

az storage container immutability-policy show -g $RG --account-name $ST \
  --container-name audit-logs --query "{state:state, days:immutabilityPeriodSinceCreationInDays, etag:etag}" -o json

Version-level on a new container, with a per-blob policy from PowerShell:

az storage container-rm create -g $RG --storage-account $ST -n backups --enable-vlw
$ctx = New-AzStorageContext -StorageAccountName strecordsprod01 -UseConnectedAccount
Set-AzStorageBlobImmutabilityPolicy -Container backups -Blob "db/full-2026-11-14.bak" `
  -ExpiresOn (Get-Date).AddDays(35) -PolicyMode Unlocked -Context $ctx

Test, and keep the output as evidence:

  • Upload a blob, then try to delete and overwrite it. Both should fail with a 409 and an error code such as BlobImmutableDueToPolicy.
  • Append to an append blob in the log container. It should succeed if protected appends are enabled.
  • Run your real writer (backup software, export job or log shipper) end to end. Some tools overwrite or delete temporary files and break under WORM.
  • Confirm reads, listing and Set Blob Tier still work. Tier changes are allowed on immutable blobs.
az storage blob delete --account-name $ST --container-name audit-logs \
  --name test/probe.txt --auth-mode login
# Expect: This operation is not permitted as the blob is immutable due to a policy.

5. Line up lifecycle, soft delete and cost

  • Lifecycle management rules that delete blobs or versions don't apply while retention is active. They take effect after expiry. Write the rules to delete after the retention period, so data doesn't build up forever once it expires.
  • Tiering rules (Cool, Cold, Archive) are fine, but early deletion charges still apply when data later moves or expires.
  • Container soft delete and blob soft delete are on as a second layer for containers without policies.
  • Cost model signed off: protected size × retention period × tier price, plus version growth for version-level scope. A locked policy means that cost is committed. Use the current pricing page, not an old estimate.

6. Lock (deliberately)

Caution

Locking is irreversible. After you lock, the retention period can only be extended, not shortened. The policy can't be deleted, and you can't delete the storage account until every protected blob has expired. Have the period, the container name and the account confirmed in writing by the data owner and compliance before you run this.

ETAG=$(az storage container immutability-policy show -g $RG --account-name $ST \
  --container-name audit-logs --query etag -o tsv)

az storage container immutability-policy lock -g $RG --account-name $ST \
  --container-name audit-logs --if-match "$ETAG"
  • Change ticket references the test evidence from step 4.
  • Lock done by a second person who checked the container name.
  • state now reads Locked.

To extend later (allowed only a limited number of times on a locked policy, so check current limits):

az storage container immutability-policy extend -g $RG --account-name $ST \
  --container-name audit-logs --period 3650 --if-match "$(az storage container immutability-policy show -g $RG --account-name $ST --container-name audit-logs --query etag -o tsv)"
az storage container legal-hold set --account-name $ST --container-name audit-logs --tags case2026x14
az storage container legal-hold show --account-name $ST --container-name audit-logs
az storage container legal-hold clear --account-name $ST --container-name audit-logs --tags case2026x14
  • Tags follow a case-ID convention so legal can audit them.
  • Clearing a hold is a controlled change, owned by legal, not by platform engineering.

8. Report and monitor

az storage container-rm list -g $RG --storage-account $ST \
  --query "[].{name:name, worm:hasImmutabilityPolicy, hold:hasLegalHold, vlw:immutableStorageWithVersioning.enabled}" -o table
  • Monthly export of this inventory per account to the compliance evidence store.
  • Activity Log alert on immutabilityPolicies/write, delete and lock operations.
  • Alert on capacity growth of WORM accounts, because they can't be cleaned up quickly.

Common traps

Trap Result Avoid it
Locked the wrong container Paying for the retention period, no way out Second-person check, unlocked soak period
Period entered in years, not days 365× longer retention than intended Policy period is in days; review the show output
Version-level on an app that rewrites one blob every minute Version explosion and cost Container-level, or redesign the writes
Backup tool deletes its staging files Jobs fail with 409 Separate staging container without WORM
Policy admin is a standing Owner Insider can shorten an unlocked policy PIM, an RBAC split, and lock when compliance needs it

Prevent it next time

  • Manage policies in Bicep or Terraform. Keep lock as a separate, manually approved pipeline stage.
  • Keep a test account with the same settings for trying new writers before they touch the production WORM account.
  • Review retention periods every year with the data owner. You can extend them, but every extension is a cost commitment.