Hello, today I want to talk to you about soft delete, this feature allows you to recover files or blobs that were previously marked for deletion. When the feature is enabled, you can recover your data after deletion, within a retention period that you must specify when enabling this feature.

Once explained this feature, we can begin this tutorial.

Prerequisites

  • This tutorial assumes that you already have a Microsoft Azure account configured.
  • You can use an existing Storage Account, or you can create a new one. If you want to know how to create a Storage Account using PowerShell, check out this link.

Azure PowerShell Workaround

If you want to know how to install the PowerShell Azure module on your machine, check out this link.

The simplest way to get started is to sign in interactively at the command line.

This cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account.
If you have more than one subscription associated with your mail account, you can choose the default subscription. To perform this task, we will use the following commands:

Once you set your default subscription, you’re ready to start.

Set the variables

Here, we define the characteristics of our environment and the resource’s properties.

Enable soft delete for blobs

first, you can view the current soft delete retention policy, using the following command.

 Get-AzStorageServiceProperty

To enable soft delete for blobs in your storage account, you should use the Enable-AzStorageDeleteRetentionPolicy cmdlet with the following syntax.

You can verify that soft delete has been enabled by using the Get-AzStorageServiceProperty cmdlet.

soft delete storage

Enable soft delete for file shares

Note that the following Soft Delete cmdlets are available in version 3.0.0 of the Az.Storage module, please check and update the version before continuing.
To view the current soft delete retention policy, use the following command.


To enable soft delete for all file shares in your storage account, you should use the Update-AzStorageFileServiceProperty cmdlet with the following syntax.

Get-AzStorageFileServiceProperty
You can verify that soft delete has been enabled by using the Get-AzStorageFileServiceProperty cmdlet.

soft delete storage

Azure CLI Workaround

In this case, we will use Azure Cloud Shell, a browser-based shell built into Azure Portal. This allows us to use the Azure command-line tools (Azure CLI and Azure PowerShell) directly from a browser. If you want to know more about Azure Cloud Shell, check out this link.
First, we define the characteristics of our environment and store the values in variables.

Enable soft delete for blobs

To enable soft delete for blobs in your storage account, you should use the following command.

and using the following command you can verify that the parameters have been set correctly.

soft delete storage

Enable soft delete for file shares

To enable soft delete for all file shares in your storage account, you should use the following command.

You can verify that soft delete has been enabled by using the following command.

soft delete storage

Thanks for reading my post. I hope you find it useful.

This functionality is currently in preview for containers in the storage account. As soon as it is generally available, I will write a post about this topic.

If you want to know more about soft delete in Azure Storage Services, check out this link: https://docs.microsoft.com/en-us/azure/storage/blobs/soft-delete-blob-overview