1. Answers
  2. Enabling soft delete for Azure Blob storage

How do I enable soft delete for Azure Blob storage?

In this guide, we will enable soft delete for Azure Blob storage using Pulumi. Soft delete for Azure Blob storage allows you to recover blob data after it has been deleted, protecting your data from accidental deletions.

We will create the following resources:

  1. An Azure Resource Group.
  2. An Azure Storage Account.
  3. Configure the Blob Service Properties to enable soft delete.
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";

// Create an Azure Resource Group
const resourceGroup = new azure.resources.ResourceGroup("resourceGroup", {
    location: "WestUS",
});

// Create an Azure Storage Account
const storageAccount = new azure.storage.StorageAccount("storageAccount", {
    resourceGroupName: resourceGroup.name,
    location: resourceGroup.location,
    sku: {
        name: "Standard_LRS",
    },
    kind: "StorageV2",
});

// Enable soft delete for Azure Blob storage
const blobServiceProperties = new azure.storage.BlobServiceProperties("blobServiceProperties", {
    accountName: storageAccount.name,
    resourceGroupName: resourceGroup.name,
    deleteRetentionPolicy: {
        enabled: true,
        days: 7, // Retain deleted blobs for 7 days
    },
});

Key Points

  • We created an Azure Resource Group to contain our resources.
  • An Azure Storage Account was created with the StorageV2 kind and Standard_LRS SKU.
  • Soft delete was enabled for the Blob Service with a retention period of 7 days.

Summary

In this guide, we successfully enabled soft delete for Azure Blob storage using Pulumi. This configuration helps protect your blob data from accidental deletions by retaining deleted blobs for a specified period, allowing you to recover them if needed.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up