Blob Lifecycle Management
Blob lifecycle management allows you to manage the entire lifecycle of your blobs by automatically transitioning them between different access tiers or deleting them at the end of their lifecycle.
This feature is ideal for optimizing costs by moving infrequently accessed data to cheaper tiers or deleting it when no longer needed.
Key Concepts
- Rules: Define policies for lifecycle management. Each rule applies to a set of blobs identified by a prefix or tags.
- Actions: Operations that can be performed on blobs, such as moving them to a cooler tier (Cool or Archive) or deleting them.
- Filters: Specify which blobs a rule applies to, using blob prefixes or tags.
Access Tiers and Lifecycle Management
Azure Blob Storage offers several access tiers to optimize costs based on data access frequency:
- Hot: For frequently accessed data.
- Cool: For infrequently accessed data (minimum 30 days).
- Archive: For rarely accessed data (minimum 180 days) with longer retrieval times.
Lifecycle management can automate the transition from Hot to Cool, Hot to Archive, or Cool to Archive based on the age of the blob or its last modification date.
Configuring Lifecycle Management Rules
You can configure lifecycle management rules through the Azure portal, Azure CLI, or PowerShell.
Using the Azure Portal
- Navigate to your storage account in the Azure portal.
- In the left-hand menu, under Data management, select Lifecycle management.
- Choose either the Rules or Rules+policies tab.
- Click Add a rule.
- Define the rule name, scope (container or storage account), and filters (prefix or tags).
- Configure the actions for the rule, specifying tier transitions and deletion policies.
- Save the rule.
Example Rule: Move blobs older than 30 days to Cool tier and delete blobs older than 365 days
{
"name": "tier_and_delete_rule",
"type": "Microsoft.Storage/storageAccounts/blobServices/lifecyclePolicies",
"properties": {
"rules": [
{
"name": "move_to_cool",
"enabled": true,
"type": "LifecycleRule",
"definition": {
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
}
}
},
"filters": {
"blobTypes": [
"blockBlob"
]
}
}
},
{
"name": "delete_old_blobs",
"enabled": true,
"type": "LifecycleRule",
"definition": {
"actions": {
"baseBlob": {
"delete": {
"daysAfterModificationGreaterThan": 365
}
}
},
"filters": {
"blobTypes": [
"blockBlob"
]
}
}
}
]
}
}
Best Practices
- Start with a small scope (e.g., a single container) to test your rules.
- Use descriptive rule names.
- Leverage blob tags for more granular control over rule application.
- Monitor your lifecycle management execution to ensure rules are working as expected.
- Be mindful of minimum retention periods for Cool and Archive tiers to avoid early deletion fees.
Considerations
- Lifecycle management rules run at least once a day.
- Changes to rules can take up to 24 hours to take full effect.
- Lifecycle management does not apply to append blobs or page blobs.
For more detailed information and advanced configurations, refer to the official Azure documentation on Blob Lifecycle Management.
Previous: Blob Versioning Next: Blob Soft Delete