Skip to main content
emnode
Site Reliability

Enable soft delete and a sufficient retention window for storage

One capability across blobs and containers: make sure that an accidental or malicious delete, or a bad overwrite, can be undone for at least a week, rather than being instant and permanent the moment it happens.

13 min·10 sections·AZURE

Last reviewed

Soft delete and retention: the basics

What actually happens when someone deletes a blob you needed?

By default, a delete against Azure Blob Storage is immediate and final. A script with a wrong prefix, a lifecycle rule with an off-by-one date, an engineer cleaning up the wrong resource group, or an attacker with a stolen key can remove objects, and unless you have arranged otherwise, there is nothing to undo. Soft delete changes that default. When blob soft delete is enabled, deleting a blob marks it as soft-deleted and keeps it recoverable for a retention period you choose. Container soft delete does the same for an entire container if someone removes it whole. Neither is on unless you turn it on.

There are three settings that make up this one capability, and they protect against different shapes of mistake. Blob soft delete recovers individual objects, snapshots and versions that were deleted or overwritten. Container soft delete recovers a deleted container and everything in it, which a blob-level setting cannot do because once the container is gone the blobs go with it. Blob versioning keeps a previous copy on every overwrite, so a corrupting in-place write is recoverable even though nothing was technically deleted. Microsoft's guidance is to enable all three together, with a retention period of at least seven days, for a complete in-account data-protection posture.

The retention window is the part people get wrong. A one-day window technically satisfies 'soft delete is enabled' but gives you almost no margin: a delete that happens late on a Friday can age out before anyone is back at work to notice. The recoverable period runs from one to 365 days, and the clock starts the moment an object is deleted or overwritten, not when someone discovers the problem. At least seven days is the recommended floor precisely so that a weekend, a holiday or a slow alert does not turn a recoverable incident into a permanent one.

In this lesson you will learn how Azure Blob Storage handles deletes and overwrites by default, why that default turns an ordinary mistake into an outage, and how to enable blob soft delete, container soft delete and versioning with a retention window that actually gives you room to recover. You will see how to find every account that is unprotected, how to set the window safely, and how to enforce it across the estate so new accounts inherit the protection.

Fun fact

The clock starts when you delete, not when you notice

The most counter-intuitive thing about soft delete is the timing. The retention clock starts the moment an object is deleted or overwritten, not the moment a human realises something is wrong. A blob deleted at 6pm on Friday with a one-day window is gone for good by Saturday evening, long before the Monday-morning standup where someone says 'wait, where did that data go?' This is exactly why the recommended floor is seven days rather than one: the window has to outlast not just the mistake, but the time it takes a real team, with weekends and on-call rotations, to spot it and act.

Finding storage accounts with no recovery window

Priya runs the platform team at a SaaS company that just had a near miss: a cleanup script deleted a container of customer documents, and only blind luck, an engineer who happened to be watching, caught it before the data was needed. The container had no soft delete. It was unrecoverable, and the team rebuilt it by hand from a stale export.

Before changing anything, Priya wants the real picture: which accounts have a recovery window at all, and how long that window is. A finding that simply says 'soft delete is enabled' is not enough, because a one-day window is barely protection. She starts by listing the actual retention days on every account.

List the blob soft-delete retention days for every account in a resource group. A blank or single-day value is the real exposure.

$ az storage account blob-service-properties show --account-name appdataprod --resource-group rg-platform --query "{blobSoftDelete:deleteRetentionPolicy.enabled, blobDays:deleteRetentionPolicy.days, containerSoftDelete:containerDeleteRetentionPolicy.enabled, versioning:isVersioningEnabled}" -o table
BlobSoftDelete BlobDays ContainerSoftDelete Versioning
---------------- ---------- --------------------- ------------
False False False
# appdataprod has NO recovery window: a delete here is permanent. Fix first.

An account that holds data a live service depends on, with no soft delete and no versioning, is the highest-value target. One wrong delete here is an outage, not an undelete.

How soft delete, versioning and the retention window actually behavedeep dive

The three settings sit on the blob service of the storage account, not on individual blobs. 'deleteRetentionPolicy' with 'enabled' and 'days' controls blob soft delete; 'containerDeleteRetentionPolicy' with the same shape controls container soft delete; and 'isVersioningEnabled' is the boolean for versioning. Because they live at the account level, turning them on protects everything in the account from that point forward, and the control-plane change takes effect immediately.

What the settings do depends on whether versioning is on alongside soft delete, and this is the part worth understanding. With blob soft delete alone, overwriting a blob automatically creates a soft-deleted snapshot of the blob's state before the write, recoverable for the retention period. With both versioning and soft delete enabled, an overwrite instead creates a new previous version, and that version is not soft-deleted and is not removed when the soft-delete retention period expires. This is why Microsoft recommends running versioning and soft delete together: versioning protects overwrites durably, while soft delete protects outright deletes, and the two cover different failure modes.

The retention window is the single most important parameter and the one most often set too low. It can be one to 365 days, the clock starts at the moment of deletion or overwrite, and when it expires the soft-deleted object is permanently deleted with no further recourse. A one-day window satisfies any check that only asks 'is soft delete enabled', but it gives a real team almost no margin to notice and act. At least seven days is the recommended floor so the window outlasts a weekend, a public holiday or a slow-firing alert. Soft delete and versioning are not a substitute for backup against region loss, but they are the fast, in-account recovery path for the far more common cause of incidents: an accidental or malicious delete or overwrite.

What is the impact of leaving storage with no recovery window?

The direct impact is permanent data loss leading to downtime. Without soft delete, a delete is final the instant it lands, so an accidental delete, a buggy lifecycle policy, a wrong-prefix script or a malicious key holder removes data with no undo. The dependent service does not just lose a file: it goes down, or runs degraded, until the data is reconstructed from somewhere else, and if no other copy exists the loss is total. Accidental and malicious deletes are one of the most common causes of data-driven outages precisely because the default makes them irreversible.

The second-order impact is recovery time, and it dominates the cost. With soft delete and versioning, recovery is an undelete: minutes, self-service, no heroics. Without them, recovery means finding another copy, validating it, and rebuilding state, which can run from hours to days and may involve serving stale or partial data the whole time. The longer the recovery, the larger the outage cost, and the variable that most determines recovery time is whether a recovery window existed at the moment of the delete.

There is a reliability-posture impact too. Azure Advisor surfaces a reliability recommendation, 'Enable Soft Delete to protect your blob data', for accounts that lack it, because Microsoft treats in-account recoverability as part of a sound data-protection strategy. An estate where every data-bearing account has soft delete, versioning and a sufficient window is one where the single most common cause of a data outage has a fast, built-in recovery path rather than an open-ended one.

How do you make storage recoverable safely?

Treat this as one capability rather than three separate toggles, and lead with the accounts whose data a live service depends on. The order matters: protect the data-bearing accounts first, set a window that survives a weekend, then enforce it so new accounts inherit the protection.

1. Inventory the recovery window, not just the toggle

List every account and read the actual retention days for blob and container soft delete, plus whether versioning is on. A value of false or one day is the real exposure. Rank accounts by how much a live service depends on their data, because an account behind a customer-facing feature is a far higher priority than a scratch account.

2. Enable all three together on data-bearing accounts

Turn on blob soft delete, container soft delete and versioning together, as Microsoft recommends, so deletes and overwrites are both recoverable and a removed container can be brought back whole. Each covers a different failure mode, and together they close the common ways data goes missing.

3. Set a window that outlasts a weekend

Use at least seven days as the floor. The clock starts at the moment of deletion, so the window has to survive a Friday-night mistake going unnoticed until Monday. Lengthen it for high-value data where you want more margin; the only cost of a longer window is a little more retained storage.

4. Enforce it so new accounts inherit protection

Use Azure Policy to audit or deny accounts that lack soft delete or a sufficient window, so a new account cannot be created without the safety net. This turns a one-off cleanup into a standing guarantee that every data-bearing account is recoverable by default.

# Make a data-bearing account recoverable: blob + container soft delete + versioning,
# with a seven-day window that survives a weekend. Runs as-is.
RG=rg-platform
ACCT=appdataprod

az storage account blob-service-properties update \
  --account-name "$ACCT" \
  --resource-group "$RG" \
  --enable-delete-retention true \
  --delete-retention-days 7 \
  --enable-container-delete-retention true \
  --container-delete-retention-days 7 \
  --enable-versioning true

# Confirm the recovery window is actually set.
az storage account blob-service-properties show \
  --account-name "$ACCT" --resource-group "$RG" \
  --query "{blobDays:deleteRetentionPolicy.days, containerDays:containerDeleteRetentionPolicy.days, versioning:isVersioningEnabled}" -o table

Quick quiz

Question 1 of 5

By default, what happens when a blob is deleted from an Azure Storage account that has no soft delete configured?

You can now treat recoverability as one capability rather than three loose toggles: inventory the actual retention window on every account, enable blob soft delete, container soft delete and versioning together on the data-bearing ones, set a window of at least seven days so a weekend cannot age out a mistake, and enforce it with Azure Policy so new accounts inherit the protection. The single most common cause of a data outage, an accidental or malicious delete, now has a fast, built-in recovery path.

Back to the library