Recover Deleted Azure Blobs by Enabling Soft Delete

DZone 's Guide to

Recover Deleted Azure Blobs by Enabling Soft Delete

There is no greater fear than having your work deleted without a backup. Fortunately, Microsoft has a solution to keep that from happening in Azure.

· Cloud Zone ·
Free Resource

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.

Image title

Soft Delete can also be enabled using the latest versions of:

  • NET Client Library

  • Java Client Library

  •  Python Client Library

  • Node.js Client Library

  •  PowerShell

  • 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.Image title
  • Let's delete this blob.Image title

  • Blob is now deleted.Image title
  • 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.Image title
  • We can recover this blob selecting undelete:Image title
  • Deleted blob is now recovered.

Image title

Configuring Soft Delete Using the C# Azure SDK: 

The soft delete feature can also be enabled by using DeleteRetentionPolicy . Use it in serviceproperties for blobclient 

ServiceProperties blobServiceProperties = AzureBlobClient.GetServiceProperties();
blobServiceProperties.DeleteRetentionPolicy.Enabled = true;
blobServiceProperties.DeleteRetentionPolicy.RetentionDays = 14;

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.
azure ,blob storage ,cloud ,data backup ,microsoft ,soft delete

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}