Azure Blob Storage Soft Delete
Protect your data from accidental deletions or overwrites with Blob Storage soft delete. This feature allows you to retain deleted blobs and snapshots for a specified period, enabling easy recovery.
What is Soft Delete?
Soft delete for Azure Blob Storage is a mechanism that protects your data by retaining deleted blobs, blob snapshots, and blob versions for a configurable retention period. Instead of permanently deleting the data immediately, it's marked for deletion and moved to a soft-deleted state. During this period, you can restore the blob to its previous state.
How it Works
When soft delete is enabled for your storage account, and a blob is deleted, it isn't immediately removed from the storage. Instead, the blob enters a soft-deleted state.
- Deleted Blob: The blob is no longer accessible via its original URI but can be restored.
- Blob Snapshot: If snapshots exist, they are also retained and can be restored along with the parent blob.
- Blob Version: If versioning is enabled, deleted versions are also retained.
After the specified retention period expires, the soft-deleted data is permanently deleted by Azure Storage.
Key Benefits
- Data Protection: Safeguards against accidental data loss due to human error or malicious attacks.
- Simplified Recovery: Allows for straightforward restoration of deleted data with a few clicks or API calls.
- Configurable Retention: You control how long soft-deleted data is kept, balancing protection with storage costs.
- Protection for Snapshots and Versions: Extends protection to other important data recovery mechanisms.
Enabling Soft Delete
Soft delete can be enabled at the storage account level. It's highly recommended to enable this feature when creating a new storage account or reviewing the configuration of existing ones.
Steps to Enable (Azure Portal):
- Navigate to your Azure Storage Account in the Azure portal.
- Under Data protection, select Soft delete for blobs.
- Toggle the switch to Enabled.
- Set the desired Retention period (in days, typically between 1 and 365).
- Click Save.
Restoring Soft-Deleted Blobs
Restoring a soft-deleted blob is a simple process:
- Using the Azure Portal: Navigate to the container, and if soft-deleted blobs are present, you'll see an option to "Show deleted blobs". Select the blob you wish to restore and click "Undelete".
- Using Azure CLI or PowerShell: Utilize commands like `az storage blob undelete` or `Restore-AzStorageBlob` to programmatically restore blobs.
Code Example (Azure CLI)
To restore a soft-deleted blob:
az storage blob undelete --container-name --name --account-name --account-key
Considerations
- Soft delete incurs storage costs for the duration the data is retained.
- Ensure your retention period aligns with your business and compliance requirements.
- When enabling soft delete, consider its impact on any existing lifecycle management policies.