Blob Soft Delete and Versioning
30-second answer
Blob soft delete keeps deleted blobs (and their versions and snapshots) for 1 to 365 days so you can undelete them. Container soft delete does the same for whole containers (1 to 365 days) and restores them with their blobs. Blob versioning automatically keeps the previous version of a blob every time it's overwritten or deleted, so you recover from a bad edit by copying an older version back over the current one. Turn them on in Data management > Data protection. Microsoft recommends using them together; none of them protects against deleting the storage account (use a resource lock).
Simulate it » No Azure account neededExam objective: 2.3.4 Configure soft delete for blobs and containers. 2.3.7 Configure blob versioning. (Skills measured as of April 17, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Under <strong>Data management</strong> open <strong>Data protection</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Under Data management open Data protection.
- Turn on soft delete for blobs (14 days), for containers (7 days) and versioning. Each takes 1 to 365 days. Select Save.
- Someone deleted contract-88.docx. In the container, toggle Show deleted blobs.
- Select it and choose Undelete. With versioning on, you would instead promote its previous version.
- A bad edit overwrote contract-12.docx. Open the blob, go to Versions, pick the version from three days ago and Make current version.
- Containers deleted by mistake come back from Containers → Show deleted containers → Undelete. Soft delete doesn’t protect against deleting the whole account: use a delete lock for that.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Undo buttons: soft delete, versioning and snapshots
Blob soft delete and container soft delete keep deleted items for 1 to 365 days. Versioning keeps every previous version of a blob. For Azure Files, share snapshots are read-only point-in-time copies and share soft delete keeps a deleted share.
🤔 What happens if…
Read this tour as text
- The front door: the storage firewall. Every account has a public endpoint that accepts all networks by default. Set the default action to Deny and only what you list gets in: virtual network rules (subnets with the Microsoft.Storage service endpoint), IP rules (public addresses only) and trusted Azure services if you tick the exception.
- Three ways in, plus one for file shares. Callers prove who they are with an account key (full control), a SAS (limited rights for limited time) or a Microsoft Entra ID token checked against RBAC data roles. For SMB file shares, users bring a Kerberos ticket from AD DS, Microsoft Entra Domain Services or Microsoft Entra Kerberos.
- SAS tokens and stored access policies. A service SAS can point at a stored access policy on the container (up to 5 per container). The policy holds the permissions and expiry, so deleting or editing it revokes every SAS that names it. An ad hoc SAS can only be revoked by regenerating the key that signed it.
- Rotate access keys. Each account has two keys so you can rotate without downtime: move apps to key2, regenerate key1, and next time do the reverse. A key expiration policy flags old keys. Regenerating a key kills every SAS signed with it.
- Encryption at rest. Azure Storage always encrypts data with AES-256. By default Microsoft manages the key. With a customer-managed key in Key Vault (soft delete and purge protection on), the account’s managed identity wraps and unwraps its data key with your key, and you can revoke it.
- Redundancy and a region outage. LRS keeps 3 copies in one datacenter, ZRS spreads 3 across availability zones, GRS adds an async copy in the paired region and GZRS combines both. RA- versions let you read the secondary. A customer-managed failover promotes the secondary when the primary region is down.
- Moving data: AzCopy and object replication. AzCopy moves files in parallel from the command line, signed in with Microsoft Entra ID (and a Storage Blob Data role) or with a SAS. Storage Explorer does the same with a GUI. Object replication keeps copying new block blobs to another account by itself.
- Access tiers and lifecycle management. Blobs sit in Hot, Cool (30-day minimum), Cold (90 days) or Archive (180 days, offline). A lifecycle management rule moves or deletes blobs by age or last access, about once a day. Reading an archived blob means rehydrating it first.
- Undo buttons: soft delete, versioning and snapshots. Blob soft delete and container soft delete keep deleted items for 1 to 365 days. Versioning keeps every previous version of a blob. For Azure Files, share snapshots are read-only point-in-time copies and share soft delete keeps a deleted share.
Someone at Contoso deletes a contract, someone else overwrites one, and a whole file share disappears on a Friday afternoon. Find out what you can and can't get back, then switch on the protection that makes each mistake a two-minute fix.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
A contract was deleted on Monday and another overwritten on Tuesday.
😊 THE SOLUTION
Turn on soft delete and versioning so both are a two-minute fix.
- Deleted blob✓ Undelete
- Overwritten blob✓ Restore a version
- Deleted container✓ Container soft delete
Start with a question
Why does your phone's photo app keep deleted photos for 30 days?
Because people delete the wrong photo all the time. The “Recently deleted” album gives you a month to change your mind. And your document editor keeps a version history, so a bad edit isn’t the end of the world either.
Azure Blob Storage has both. Soft delete is the recently deleted album. Versioning is the version history.
Explain it like I’m 10
The technical explanation
All three settings live in Data management > Data protection on the storage account (and on the Data protection tab when you create one). The portal turns soft delete on by default for new accounts (7 days); accounts created with the CLI or templates don’t get it unless you ask.
Blob soft delete
When a blob, a snapshot or a version is deleted, it’s kept in a soft-deleted state for the retention period (1 to 365 days). You can list it (--include d, or Show deleted blobs in the portal) and undelete it. When versioning is off, overwriting a blob also keeps the old data as a soft-deleted snapshot. Soft-deleted data is billed until it’s purged.
Container soft delete
Deleted containers and everything in them are kept for 1 to 365 days. Restore from Containers > Show deleted containers > Undelete, or with az storage container restore. You can’t restore over a container that has since been recreated with the same name.
Blob versioning
With versioning on, every write creates a new current version and keeps the old one as a previous version with a timestamp version ID. Deleting a blob turns its current version into a previous version. To recover, copy a previous version over the base blob (portal: blob > Versions > Make current version). Versions are billed, so pair versioning with a lifecycle rule that deletes old versions. Versioning isn’t supported on hierarchical namespace accounts.
How they fit together
| Accident | With soft delete only | With versioning (and soft delete) |
|---|---|---|
| Blob deleted | Undelete it | Make a previous version current |
| Blob overwritten | Restore the soft-deleted snapshot | Make a previous version current |
| Version deleted | Undelete the version | Undelete the version |
| Container deleted | Needs container soft delete | Needs container soft delete |
| Account deleted | Not covered (use a lock) | Not covered (use a lock) |
Point-in-time restore builds on these: it restores block blobs in chosen containers to a moment in the past, and needs versioning, the change feed and blob soft delete, with a restore window shorter than the soft delete retention. Object replication also needs versioning.
CLI and PowerShell
az storage account blob-service-properties update -g rg-storage-prod -n stcontosoprod \
--enable-delete-retention true --delete-retention-days 14 \
--enable-container-delete-retention true --container-delete-retention-days 7 \
--enable-versioning true
# Deleted blob (soft delete): list and undelete
az storage blob list --account-name stcontosoprod -c contracts --include d -o table
az storage blob undelete --account-name stcontosoprod -c contracts -n contract-88.docx
# Overwritten blob (versioning): copy a previous version back
az storage blob list --account-name stcontosoprod -c contracts --include v -o table
az storage blob copy start --account-name stcontosoprod \
--destination-container contracts --destination-blob contract-12.docx \
--source-uri "https://stcontosoprod.blob.core.windows.net/contracts/contract-12.docx?versionid=<version-id>"
Enable-AzStorageBlobDeleteRetentionPolicy -ResourceGroupName rg-storage-prod -StorageAccountName stcontosoprod -RetentionDays 14
Enable-AzStorageContainerDeleteRetentionPolicy -ResourceGroupName rg-storage-prod -StorageAccountName stcontosoprod -RetentionDays 7
Update-AzStorageBlobServiceProperty -ResourceGroupName rg-storage-prod -StorageAccountName stcontosoprod -IsVersioningEnabled $true
Architect level Immutability is a different tool
Soft delete and versioning help with mistakes, but an admin can still turn them off and purge data. If regulations say data must not be changed or deleted for a period, use immutable storage: time-based retention policies or legal holds on a container or on versions. Locked policies can’t be shortened, even by the account owner.
Real-world business scenario
Alpine Ski House (fictional)
- The problem
- A sync tool deleted a season's booking contracts on Monday, and on Tuesday an intern saved a blank template over the master price list.
- What they used
- Blob soft delete (14 days), container soft delete (7 days) and versioning, with a lifecycle rule that deletes versions older than 90 days.
- Why that choice
- Undelete brought back the contracts, and the previous version of the price list was made current again in two clicks.
- The result
- Both incidents were fixed before lunch. The team later added a delete lock on the account for the one accident these features don't cover.
When to use it and when not to
✓ Use it when…
- Any account holding data people or tools can delete or overwrite.
- You plan to use object replication or point-in-time restore (versioning required).
- You want a quick undo without restoring from a backup.
✕ Think twice when…
- Data that must be legally unchangeable (use immutable storage).
- Hierarchical namespace accounts if you need versioning (not supported).
- Blobs rewritten constantly with no lifecycle rule for versions (cost grows).
↔ Alternatives to consider
- Immutable storage for WORM compliance.
- Azure Backup for blobs for vaulted, longer-term copies.
- Resource locks to stop the account itself being deleted.
Test yourself with exercises
5 original practice questions in the AZ-104 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What's the difference between soft delete and versioning?
Model answer
Soft delete is about deletes: a deleted blob waits for a set number of days before it's really gone, and you can undelete it. Versioning is about changes: every time a blob is overwritten, the old content is kept as a version. Together they cover both "I deleted it" and "I saved over it".
Intermediate Versioning is on and someone deletes a blob. How do you get it back?
Model answer
With versioning, a delete turns the current version into a previous version; there's no current blob left. I list versions with --include v, find the one I want and copy it back over the blob name with az storage blob copy start using the version ID in the source URL, or in the portal pick the version and select Make current version.
Experienced developer What does versioning cost, and how do you keep it under control?
Model answer
Each version is billed for the data it holds, so a blob that's rewritten hourly can pile up versions fast. I add a lifecycle rule that deletes versions older than, say, 90 days, or moves them to a cooler tier. Versioning also isn't supported on accounts with a hierarchical namespace.
Scenario A container with a year of reports was deleted this morning. Container soft delete was on with 7 days. What do you do?
Model answer
List containers with --include-deleted to get its deleted version, then az storage container restore with the name and version, or Show deleted containers and Undelete in the portal. It comes back with its blobs. If a container with the same name was created since, I'd have to remove or rename that first.
Quick revision
Key points
- Portal path: storage account > Data management > Data protection.
- Blob soft delete and container soft delete - 1 to 365 days each.
- Portal-created accounts get 7-day soft delete by default; the CLI doesn't turn it on.
- Versioning keeps a version on every write; restore by copying a version back.
- Object replication and point-in-time restore need versioning.
- None of these protect against deleting the storage account; use a CanNotDelete lock.
Important terminology
- Blob soft delete
- Keeps deleted blobs, snapshots and versions for a retention period of 1 to 365 days.
- Container soft delete
- Keeps deleted containers and their contents for 1 to 365 days so they can be restored.
- Blob versioning
- Automatically keeps a previous version of a blob each time it's modified or deleted.
- Version ID
- A timestamp that identifies one version of a blob.
- Undelete
- Restoring a soft-deleted blob (az storage blob undelete) within the retention period.
- Point-in-time restore
- Restores block blobs in containers to an earlier state; needs versioning, change feed and blob soft delete.
Common mistakes
- Expecting undelete to work when soft delete was off at the time of the delete.
- Using undelete for a blob deleted while versioning was on (promote a version instead).
- Forgetting that versions are billed.
Exam tips
- "Recover a blob that was overwritten" = versioning.
- "Recover a deleted container" = container soft delete.
- "Prevent deletion of the storage account" = resource lock, not soft delete.
Five quick revision questions
-
1.What retention range does blob soft delete allow?Show
1 to 365 days.
-
2.Which CLI command restores a soft-deleted blob?Show
az storage blob undelete
-
3.Which CLI flag turns on blob versioning?Show
--enable-versioning true (az storage account blob-service-properties update)
-
4.Which three features does point-in-time restore need?Show
Versioning, change feed and blob soft delete.
-
5.Does container soft delete protect against deleting the storage account?Show
No.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Read and Modify ARM Templates and Bicep Files
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.