Whenever any blob is erased by deleting from an Azure storage account, it’s immediately deleted and cannot be recovered. To overcome such a problem, Microsoft recently released a new feature known as Soft Delete. This feature is available as a public preview and can be used by all regions, including public and private. You can consider this feature to recover your deleted blobs.
Deleted blobs data will be recoverable after enabling the soft delete, which will help to get the deleted data that’s erased due to data overwriting of the same blob.
How to Configure Soft Delete Using Azure Portal
Soft delete needs to be enabled first for Azure storage account either existing or new storage accounts. After enabling this feature we also have to define the number of days as retention period. Navigate to the Azure storage account and enable the soft delete for the Azure storage account.
Soft Delete can also be enabled using the latest versions of:
- NET Client Library
- Java Client Library
- Python Client Library
- Node.js Client Library
- CLI 2.0
- REST API version 2017–07–29
Let’s See How Soft Delete Works
- Upload a file into an Azure storage container. I created one container for the demo.
- Let’s delete this blob.
- Blob is now deleted.
- As we have already enabled the soft delete, let’s see the list of deleted blobs. We can see the list of deleted blobs by selecting the checkbox.
- We can recover this blob selecting undelete:
- Deleted blob is now recovered.
Configuring Soft Delete Using the C# Azure SDK:
The soft delete feature can also be enabled by using
DeleteRetentionPolicy . Use it in
ServiceProperties blobServiceProperties = AzureBlobClient.GetServiceProperties();blobServiceProperties.DeleteRetentionPolicy.Enabled = true;blobServiceProperties.DeleteRetentionPolicy.RetentionDays = 14;AzureBlobClient.SetServiceProperties(blobServiceProperties)
The following are some important points to consider.
- If a container is deleted, then all the blobs will be deleted, included soft-deleted blobs, and cannot be recovered.
- Soft delete is not available for blobs in archive tier.
- Soft-deleted data is included as a part of your total storage account capacity.
- Soft-deleted blobs cannot be read without making them undelete first.
- All soft-deleted data is billed at the same rate as active data for the retentions period.