Implementing soft delete for Azure Files protects your file shares by allowing you to recover deleted files or file shares within a specified retention period.
Here's how to enable and configure soft delete for Azure Files.
Steps to Implement Soft Delete for Azure Files
Using Azure Portal
1. Navigate to the Storage Account
Log in to the .
Go to the Storage Accounts section and select the storage account where your file shares reside.
2. Access File Share Settings
Under the selected storage account, go to Data protection in the left-hand menu.
3. Enable Soft Delete
In the File Share section of Data Protection, find the Soft delete for Azure Files option.
Toggle it to Enabled.
4. Set the Retention Period
Specify the number of days (1–365 days) you want the deleted data to be retained.
5. Save Changes
Click Save to apply the configuration.
Using Azure PowerShell
1. Install/Update Azure PowerShell
Ensure the Azure PowerShell module is installed and updated:
xxxxxxxxxx
11Install-Module -Name Az -AllowClobber -Scope CurrentUser
2. Log in to Azure
xxxxxxxxxx
11Connect-AzAccount
3. Enable Soft Delete
Use the following command to enable soft delete and set a retention period:
xxxxxxxxxx
91$resourceGroupName = "YourResourceGroupName"
2$storageAccountName = "YourStorageAccountName"
3$retentionDays = 30 # Set the desired retention period (in days)
4
5Set-AzStorageAccount `
6-ResourceGroupName $resourceGroupName `
7-Name $storageAccountName `
8-EnableShareSoftDelete `
9-ShareSoftDeleteRetentionInDays $retentionDays
Using Azure CLI
1. Install/Update Azure CLI
Ensure Azure CLI is installed and updated:
xxxxxxxxxx
11az upgrade
2. Log in to Azure
xxxxxxxxxx
11az login
3. Enable Soft Delete
Run the following command to enable soft delete and set the retention period:
xxxxxxxxxx
91resourceGroupName="YourResourceGroupName"
2storageAccountName="YourStorageAccountName"
3retentionDays=30 # Set the desired retention period (in days)
4
5az storage account file-service-properties update \
6--account-name $storageAccountName \
7--resource-group $resourceGroupName \
8--enable-delete-retention true \
9--delete-retention-days $retentionDays
Using Azure REST API
Use the Set File Service Properties API to enable soft delete and specify the retention period.
Refer to Azure's REST API documentation for details.
Recovering Deleted File Shares
1. In Azure Portal
Go to the storage account.
Under File shares, select Deleted file shares.
Locate the file share you want to restore and click Restore.
2. Using Azure CLI or PowerShell
Use the respective commands to list deleted shares and restore them.
Summary
Soft delete incurs additional costs based on the data retained during the retention period.
Once the retention period expires, the deleted data is permanently removed and cannot be recovered.
Soft delete protects entire file shares; to enable recovery for individual files, use Share Snapshots.
By enabling soft delete, you add an extra layer of data protection for accidental or malicious deletions.
Leave a Reply