Azure Blob Storage Lifecycle Management

Optimize costs and manage data efficiently.

What is Blob Storage Lifecycle Management?

Azure Blob Storage lifecycle management offers a cost-effective way to manage the lifecycle of blobs in your storage account. You can use this feature to move blobs between different access tiers (Hot, Cool, and Archive) or to delete blobs when they are no longer needed.

By automating these actions based on rules, you can ensure that your data is always stored in the most appropriate and cost-efficient tier, and that obsolete data is removed, reducing storage costs and improving compliance.

Key Benefits

  • Cost Optimization: Automatically move data to less expensive tiers (Cool, Archive) as it ages.
  • Compliance: Ensure data retention policies are met by deleting data after a specified period.
  • Automation: Reduce manual effort and potential for human error.
  • Flexibility: Define rules based on blob creation date, last modification date, or last access date.

How it Works: Lifecycle Rules

Lifecycle management works by defining rules. Each rule consists of one or more actions that are applied to blobs that match the rule's filters.

Rule Components:

  • Filters: Specify which blobs the rule applies to. You can filter by prefix (e.g., container name or blob path) and by blob age (creation date, modification date, or access date).
  • Actions: Define what happens to matching blobs. Common actions include:
    • Moving blobs to the Cool tier.
    • Moving blobs to the Archive tier.
    • Deleting blobs.
  • Scope: Rules can apply to an entire storage account or a subset of blobs within the account.

Defining a Lifecycle Rule (Example)

Here's an example of a rule that moves blobs older than 30 days to the Cool tier, and then to the Archive tier after 90 days, and finally deletes them after 365 days. This rule applies to all blobs in a specific container named mydatalogs.

Example Rule Configuration:

  • Rule Name: Data Archiving and Deletion
  • Scope: Container: mydatalogs
  • Actions:
    1. Action 1:
      • Type: Move to Cool tier
      • Days after creation: 30
    2. Action 2:
      • Type: Move to Archive tier
      • Days after creation: 90
    3. Action 3:
      • Type: Delete blob
      • Days after creation: 365

Azure CLI Example:

You can also define and manage lifecycle rules using the Azure CLI. Here's a simplified conceptual example:

az storage lifecycle rule create --account-name  \
    --rule-name "ArchivingRule" \
    --filters "{"prefix": "mydatalogs/"}" \
    --actions '[{"type": "SetBlobTier", "parameters": {"tier": "Cool", "daysAfterCreationGreaterThan": 30}}, {"type": "SetBlobTier", "parameters": {"tier": "Archive", "daysAfterCreationGreaterThan": 90}}, {"type": "Delete", "parameters": {"daysAfterCreationGreaterThan": 365}}]'
                

Getting Started

Setting up lifecycle management is straightforward:

  1. Navigate to your Azure Storage account in the Azure portal.
  2. Under the "Data management" section, select "Lifecycle management".
  3. Click "Add a rule" and configure your filters and actions.
  4. Save your rule. Azure will begin applying it to your blobs.
Go to Azure Portal