Azure Storage Blob Lifecycle Management

Optimize costs and manage data across different access tiers.

Azure Blob Storage lifecycle management offers a cost-effective way to manage blobs throughout their lifetime. You can define rules to automatically transition blobs between different access tiers (Hot, Cool, Archive) or delete them based on rules that you define.

Key Concepts

How Lifecycle Management Works

Lifecycle management policies are applied at the storage account level. A policy is a collection of rules. Each rule consists of:

  1. Scope: All blobs or a subset of blobs defined by a filter.
  2. Filters: Criteria to select blobs. Common filters include:
    • Blob prefix: Matches blobs with a specific path.
    • Blob tags: Matches blobs with specific key-value tags.
    • Last modified date: Filters blobs based on when they were last modified.
  3. Actions: The operations to perform on the filtered blobs. These can include:
    • Transition to Cool: Move blobs to the Cool tier after a specified number of days.
    • Transition to Archive: Move blobs to the Archive tier after a specified number of days.
    • Delete: Permanently delete blobs after a specified number of days.

Important Considerations

The cool tier is optimized for storing data that is accessed less frequently but requires rapid access when needed. The archive tier is optimized for storing data that is rarely accessed and allows for the lowest storage costs but the longest retrieval times. Ensure your access patterns align with the tier characteristics.

Creating a Lifecycle Management Policy

You can create lifecycle management policies using the Azure portal, Azure CLI, PowerShell, or the Storage Management REST API.

Using Azure Portal

  1. Navigate to your storage account in the Azure portal.
  2. Under "Data management," select "Lifecycle management."
  3. Click "Add a rule."
  4. Configure the rule name, scope, filters, and actions as needed.
  5. Save the rule.

Using Azure CLI

Here's an example of how to create a rule to move blobs with a prefix of logs/ to the Cool tier after 30 days and to the Archive tier after 90 days:


az storage lifecycle-management policy create \
    --account-name <your-storage-account-name> \
    --policy '{
        "rules": [
            {
                "name": "transition-to-cool-and-archive-logs",
                "enabled": true,
                "type": "Management",
                "definition": {
                    "actions": {
                        "version": {
                            "tierToCool": {"daysAfterModificationGreaterThan": 30},
                            "tierToArchive": {"daysAfterModificationGreaterThan": 90}
                        },
                        "baseBlob": {
                            "tierToCool": {"daysAfterModificationGreaterThan": 30},
                            "tierToArchive": {"daysAfterModificationGreaterThan": 90}
                        }
                    },
                    "filters": {
                        "prefix": ["logs/"]
                    }
                }
            }
        ]
    }'
            

Understanding DaysAfterModificationGreaterThan

This parameter defines the number of days after a blob's last modification date to trigger the action. For versioning, it applies to the base blob's last modification date.

Monitoring Lifecycle Management

You can monitor the execution of your lifecycle management rules using Azure Monitor. This includes viewing metrics related to rule execution and troubleshooting any issues.

Best Practices

Tip

Combine lifecycle management with Blob Versioning and Soft Delete for comprehensive data protection and cost management.

By effectively using Azure Blob Storage lifecycle management, you can significantly reduce your storage costs while ensuring your data is accessible when you need it.