How to configure Azure Blob Data Retention Policy

Here’s an example of how to enable the Azure Blob Data Retention Policy using the Azure portal:

  1. Open the Azure portal and navigate to the storage account where you want to enable the retention policy.
  2. In the left menu, select “Blob service.”
  3. Select the container for which you want to enable the retention policy.
  4. In the container settings menu, select “Retention policy.”
  5. Select “Enable retention” and specify the retention period in days or indefinitely.
  6. Click “Save” to save the retention policy settings.

Here’s an example of how to enable the Azure Blob Data Retention Policy using PowerShell:

  1. Open PowerShell and connect to your Azure account using the command:Connect-AzAccount
  2. Select the subscription where your storage account is located using the command:Select-AzSubscription -SubscriptionName <subscription_name>
  3. Get the container object using the command:$container = Get-AzStorageContainer -ResourceGroupName <resource_group_name> -StorageAccountName <storage_account_name> -Name <container_name>
  4. Set the retention policy using the command:$container | Set-AzStorageContainerLegalHold -LegalHold $true -RetentionDays <retention_days>Note: Replace <resource_group_name>, <storage_account_name>, <container_name>, and <retention_days> with your own values.
Author: tonyhughes