Introduction
In Azure Storage, Soft Delete is a data protection feature that allows you to recover accidentally deleted data within a specified retention period. This feature helps safeguard your data against accidental deletions or overwrites, providing a safety net for critical storage operations. Additionally, the Permanent Delete feature provides flexibility for immediate cleanup of soft-deleted snapshots or versions. We will discuss both Soft Delete and permanent delete features in this blog post.
How Does Soft Delete Work?
When Soft Delete is enabled:
- Deleted data, including base blobs, snapshots, or versions, enters the soft-deleted state and becomes inaccessible to clients.
- Data is retained for a specified number of days (retention period) before being permanently removed. During this time, you can recover the data through the Azure portal, CLI, or API.
- For snapshots and versions, you can manually delete specific soft-deleted items using the Permanent Delete feature.
Soft Delete can be enabled for:
- Blob Storage (Soft Delete for Blobs): Protects individual blobs from accidental deletions or overwrites.
- Container Soft Delete: Protects entire containers from being accidentally deleted.
- Azure Files Soft Delete: Protects files and file shares in Azure Files.
Benefits of Soft Delete
- Data Recovery: Easily restore deleted blobs, containers, or files during the retention period.
- Cost-Effective Protection: Only pay for the additional storage consumed by retained data, with no additional charges for enabling the feature.
- Customizable Retention: Choose a retention period between 1 and 365 days based on your needs.
- Integrated in Azure Storage Account: Works seamlessly with your existing storage account without requiring additional infrastructure.
Soft Delete for Blobs
When a blob is deleted or overwritten:
- The previous version is marked as deleted but is still recoverable during the retention period.
- You can list the deleted blobs and restore them through the Azure portal or programmatically.
- For snapshots or versions, allows manual cleanup with the Permanent Delete feature before retention ends.
Soft Delete for Containers
With container soft delete:
- If a container is deleted, it can be restored along with all its blobs within the retention period.
- This protects against accidental deletion of an entire container.
Soft Delete for Azure Files
For Azure Files:
- Deleted files or file shares are retained for a specified retention period.
- You can restore individual files or entire shares if accidental deletions occur.
How to Enable Soft Delete
- Via Azure Portal:
- Navigate to your Storage Account.
- Under the Data Protection section, enable Soft Delete for Blobs, Containers, or Azure Files.
- Set the retention period (1–365 days).
- Save the changes.
- Via Azure CLI or PowerShell: Use commands to enable soft delete and set the retention period for blobs or Azure Files.
Permanent Delete for Blobs
The Permanent Delete feature allows you to manually delete specific soft-deleted snapshots or blob versions before the retention period expires. Once a snapshot or version is permanently deleted, it cannot be recovered—even if it was still within the soft delete retention period.
- Use Case: Immediate cleanup of sensitive data or reduction of storage costs.
- How to Enable: Enable via the Data Protection tab during storage account creation or configure later in Data Management > Data Protection.
How to Permanently Delete Soft-Deleted Blobs or Snapshots During the Soft Delete Retention Period
Prerequisite: Ensure that Soft Delete and Permanent Delete features are enabled in the storage account.
- Navigate to the Storage Account in the Azure portal.
- Go to Containers and enable Show Deleted Blobs to display soft-deleted items.
- Select the soft-deleted blob.
- Navigate to the Versions or Snapshots tab.
- Click Permanent Delete to immediately and permanently remove the selected soft-deleted item.
Limitations of Soft-Delete
- Retention Period: Data is only recoverable within the retention period; it is permanently deleted afterward.
- Additional Storage Costs: Retained data contributes to the overall storage cost during the retention period.
Best Practices for Soft-Delete
- Enable Soft Delete for Mission-Critical Data: Use soft delete for data that requires high levels of protection against accidental deletions.
- Set an Appropriate Retention Period: Choose a period that balances data recovery needs with storage costs.
- Combine with Immutable Blob Storage: For regulatory compliance, use soft delete alongside immutable blob storage to prevent deletions or modifications.
Conclusion
Soft Delete is a simple yet powerful way to add an extra layer of protection for your data in Azure Storage accounts. By enabling this feature, you can minimize the risk of data loss while ensuring quick recovery when mistakes happen.