Azure Files offers soft delete, which allows you to recover your file share if you mistakenly deleted it.
Applies to
Management model
Billing model
Media tier
Redundancy
SMB
NFS
Microsoft.Storage
Provisioned v2
HDD (standard)
Local (LRS)
Microsoft.Storage
Provisioned v2
HDD (standard)
Zone (ZRS)
Microsoft.Storage
Provisioned v2
HDD (standard)
Geo (GRS)
Microsoft.Storage
Provisioned v2
HDD (standard)
GeoZone (GZRS)
Microsoft.Storage
Provisioned v1
SSD (premium)
Local (LRS)
Microsoft.Storage
Provisioned v1
SSD (premium)
Zone (ZRS)
Microsoft.Storage
Pay-as-you-go
HDD (standard)
Local (LRS)
Microsoft.Storage
Pay-as-you-go
HDD (standard)
Zone (ZRS)
Microsoft.Storage
Pay-as-you-go
HDD (standard)
Geo (GRS)
Microsoft.Storage
Pay-as-you-go
HDD (standard)
GeoZone (GZRS)
How soft delete works
When soft delete is enabled, deleted file shares are retained in a soft deleted state for the defined retention period before being permanently deleted. When you undelete a file share, the file share and all of contents, including snapshots, are restored to their state prior to deletion.
Soft delete for file shares is enabled at the storage account level so the soft delete settings apply to all file shares within a storage account. New storage accounts have soft delete enabled by default, but you can enable or disable soft delete as desired for new or existing storage accounts. If you disable soft delete, any file shares deleted before disabling soft delete can still be undeleted.
By default, the retention period for file shares is 7 days, but you can specify any retention period between 1 and 365 days. The retention period clock starts when the file share is deleted. You can change the soft delete retention period at any time. Shares deleted before the retention period update expire based on the retention period that was configured when that data was deleted.
To permanently delete a file share in a soft delete state before its expiry time, you must undelete the share, disable soft delete, and then delete the share again. If desired, remember to reenable soft delete for the storage account to protect other file shares from accidental deletion.
For soft-deleted provisioned file shares, the file share quota (the provisioned size of a file share) is used in the total storage account quota calculation until the soft-deleted share expiry date, when the share is fully deleted.
Billing
Billing for soft delete depends on the billing model of the file share. For more information, see the following:
Navigate to your storage account and select File shares under Data storage.
Select Disabled next to Soft delete.
Select Enabled for Soft delete for all file shares.
Under File share retention period in days, use the slider to specify a number between 1 and 365 days.
Select Save to confirm your data retention settings.
To enable soft delete, you must update the settings for all Azure file shares, also known as the FileService properties. The following example enables soft delete for all file shares in a storage account. Remember to replace <resource-group> and <storage-account> with the appropriate values for your environment.
To enable soft delete, you must update a file client's service properties. The following example enables soft delete for all file shares in a storage account. Remember to replace <resource-group> and <storage-account> with the appropriate values for your environment.
Navigate to your storage account and select File shares.
On the file share blade, enable Show deleted shares to display any shares that are soft deleted.
This displays any shares currently in a Deleted state.
Select the share and select undelete to restore the share.
You can confirm the share is restored when its status switches to Active.
To restore a soft deleted file share, you must first get the -DeletedShareVersion value of the share. To get that value, use the following command to list out all the deleted shares for your storage account.
Once you identify the share you want to restore, you can use the following command to restore it:
Restore-AzRmStorageShare `
-ResourceGroupName $resourceGroupName `
-StorageAccountName $storageAccountName `
-DeletedShareVersion 01D5E2783BDCDA97 # replace with your deleted version number
To restore a soft deleted file share, you must first get the --deleted-version value of the share. To get that value, use the following command to list out all the deleted shares for your storage account.
az storage share-rm list \
--resource-group $resourceGroupName \
--storage-account $storageAccountName \
--include-deleted
Once you identify the share you'd like to restore, you can restore it with the following command:
If you want to stop using soft delete, follow these instructions. To permanently delete a file share that's been soft deleted, you must undelete the share, disable soft delete, and then delete the share again.