Configure soft delete for blobs and containers

Configure Azure Files and Azure Blob Storage

📘Microsoft Certified: Azure Administrator Associate (AZ-104)


1. What is Soft Delete?

  • Definition: Soft delete is a feature in Azure Blob Storage that retains deleted blobs or blob snapshots for a specified retention period.
  • Purpose: It prevents permanent data loss due to accidental deletion or corruption.
  • Scope: Soft delete works for individual blobs and entire containers.

2. How Soft Delete Works

  1. You enable soft delete on a storage account.
  2. When a blob or container is deleted:
    • It does not disappear immediately.
    • Azure marks it as deleted but recoverable.
    • You can restore the blob or container within the retention period.
  3. Once the retention period expires, the blob or container is permanently deleted and cannot be recovered.

3. Retention Period

  • You can set the retention period when enabling soft delete.
  • Range: From 1 day up to 365 days.
  • Example: If you set the retention period to 30 days:
    • A blob deleted today can be restored anytime within the next 30 days.
    • After 30 days, it is permanently removed.

4. Soft Delete for Blobs vs Containers

FeatureBlobsContainers
Soft delete support✅ Yes✅ Yes
Retention periodConfigurable (1–365 days)Configurable (1–365 days)
RecoveryRestore deleted blob/snapshotRestore deleted container and all blobs inside it
Use caseAccidentally deleted individual filesAccidentally deleted entire storage container

Tip: If you delete a container with soft delete enabled, all blobs in that container are recoverable during the retention period.


5. Enabling Soft Delete

Soft delete can be enabled in Azure Portal, PowerShell, CLI, or ARM templates.

a) Using Azure Portal

  1. Go to your Storage Account.
  2. Click Data protection (sometimes under “Settings”).
  3. Toggle Soft delete for blobs ON.
  4. Set the Retention period in days.
  5. Save your settings.

b) Using Azure CLI

az storage account blob-service-properties update \
  --account-name <StorageAccountName> \
  --resource-group <ResourceGroupName> \
  --enable-delete-retention true \
  --delete-retention-days 30

c) Using PowerShell

Set-AzStorageServiceProperty -ServiceType Blob `
  -StorageAccountName <StorageAccountName> `
  -EnableDeleteRetention $true `
  -DeleteRetentionDays 30

6. Restoring Deleted Blobs or Containers

  1. Go to the storage account in Azure Portal.
  2. Open Containers → select the deleted container or blob.
  3. Choose Restore → select the version or point in time.
  4. The blob/container is restored back to its original location.

Note: Only possible if the retention period has not expired.


7. Exam Tips for AZ-104

  • Know the difference: Soft delete for blobs vs containers.
  • Retention period: Must know it can be set 1–365 days.
  • Recovery: Only within the retention period.
  • Enabling soft delete: You can do it via Portal, CLI, PowerShell, ARM templates.
  • Purpose on exam: Focus on data protection, accidental deletion recovery, and Azure management options.

8. Summary (Key Points)

  • Soft delete protects against accidental deletion.
  • It works for blobs and containers.
  • Retention period determines how long deleted items can be recovered.
  • Can be enabled via Portal, CLI, PowerShell, or templates.
  • You can restore deleted items if the retention period hasn’t expired.
  • Helps meet data protection and compliance requirements.

Leave a Reply

Your email address will not be published. Required fields are marked *

Buy Me a Coffee