Managing Blob Retention Policies
Blob retention policies are a crucial feature in Azure Blob Storage that allow you to define how long your data is stored. They help in complying with regulatory requirements, managing storage costs, and preventing accidental data deletion.
Azure Storage offers two main types of retention policies:
Immutable storage provides a robust way to ensure data integrity and compliance. You can configure a retention period, after which blobs become eligible for deletion.
Key Features:
You can set these policies at the container level using Legal Hold or Time-based retention policies.
Soft delete protects your blobs from accidental deletion by keeping them in a recoverable state for a specified duration. This is a safety net for operational data.
Key Features:
Enabling soft delete is recommended for most scenarios to prevent data loss.
Retention policies can be configured using the Azure portal, Azure CLI, Azure PowerShell, or Azure SDKs.
To enable soft delete for blobs with a 14-day retention period on a storage account:
az storage account update --name <your-storage-account-name> --resource-group <your-resource-group-name> --set isSoftDeleteEnabled=true
az storage blob service-properties update --account-name <your-storage-account-name> --days-retained 14
To set a 7-day time-based retention policy on a container:
az storage container immutability policy update --container-name <your-container-name> --account-name <your-storage-account-name> --retention-days 7 --policy-mode locked
Note: The --policy-mode locked sets the policy to 'locked' mode, making it immutable and unchangeable.
For more in-depth information, refer to the official Azure documentation: