Introduction
Azure Blob Storage lifecycle management provides users with enhanced control over how and when objects can be restored from the archive tier. The recent enhancements enable better data retention strategies, allowing objects to stay in an online tier for a predefined period before being transitioned or deleted. This article explores how to optimize lifecycle management in Azure Blob Storage.

Lifecycle Rules and Definitions
Lifecycle management enables users to define rules based on the age, modification date, or last access time of objects. These rules can be configured using the following parameters:
- daysAfterModificationGreaterThan: Controls actions based on the number of days since the object was last modified.
- daysAfterCreationGreaterThan: Defines actions based on the number of days since the object was created.
- daysAfterLastAccessTimeGreaterThan: Triggers actions based on the last time the object was accessed.
- daysAfterLastTierChangeGreaterThan: Governs actions based on the last time an object’s storage tier was changed.
Rule-Based Actions
When lifecycle rules are applied, the following actions can be performed:
- tierToCool: Moves objects to the Cool storage tier.
- tierToCold: Moves objects to the Cold storage tier.
- enableAutoTierToHotFromCool: Automatically moves objects from the Cool tier back to Hot when accessed.
- tierToArchive: Moves objects to the Archive tier.
- delete: Permanently removes objects.
Lifecycle Policy Examples
Moving Old Data to a Lower-Cost Tier
The following example moves block blobs in the “sample-container/blob1” and “container2/blob2” paths to Cool storage if they haven’t been modified in 30 days and to the Archive tier if untouched for 90 days.
jsonCopyEdit{
"rules": [
{
"name": "agingRule",
"enabled": true,
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [ "blockBlob" ],
"prefixMatch": [ "sample-container/blob1", "container2/blob2" ]
},
"actions": {
"baseBlob": {
"tierToCool": { "daysAfterModificationGreaterThan": 30 },
"tierToArchive": { "daysAfterModificationGreaterThan": 90 }
}
}
}
}
]
}
Moving Data Based on Last Access Time
The following policy moves blobs to Cool storage if they haven’t been accessed in 30 days and automatically moves them back to Hot storage when accessed.
jsonCopyEdit{
"enabled": true,
"name": "last-accessed-thirty-days-ago",
"type": "Lifecycle",
"definition": {
"actions": {
"baseBlob": {
"enableAutoTierToHotFromCool": true,
"tierToCool": {
"daysAfterLastAccessTimeGreaterThan": 30
}
}
},
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"mylifecyclecontainer/log"
]
}
}
}
Archiving Data Immediately After Creation
The following lifecycle policy moves all blobs in “archivecontainer” to the Archive tier immediately upon creation.
jsonCopyEdit{
"rules": [
{
"name": "archiveRule",
"enabled": true,
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [ "blockBlob" ],
"prefixMatch": [ "archivecontainer" ]
},
"actions": {
"baseBlob": {
"tierToArchive": {
"daysAfterModificationGreaterThan": 0
}
}
}
}
}
]
}
Deleting Data Based on Age
The following rule deletes block blobs that haven’t been modified in 365 days.
jsonCopyEdit{
"rules": [
{
"name": "expirationRule",
"enabled": true,
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [ "blockBlob" ]
},
"actions": {
"baseBlob": {
"delete": { "daysAfterModificationGreaterThan": 365 }
}
}
}
}
]
}
Deleting Data Based on Blob Index Tags
This rule deletes all block blobs tagged with “Project = Contoso”.
jsonCopyEdit{
"rules": [
{
"enabled": true,
"name": "DeleteContosoData",
"type": "Lifecycle",
"definition": {
"actions": {
"baseBlob": {
"delete": {
"daysAfterModificationGreaterThan": 0
}
}
},
"filters": {
"blobIndexMatch": [
{
"name": "Project",
"op": "==",
"value": "Contoso"
}
],
"blobTypes": [
"blockBlob"
]
}
}
}
]
}
Conclusion
Azure Blob Storage lifecycle management is a powerful tool for efficient data retention and cost optimization. Users can automate data transitions based on modification dates, access frequency, and storage tier changes, reducing manual effort and storage costs.
The examples provided illustrate how to apply lifecycle policies in various scenarios. For more details, refer to the Azure Storage Lifecycle Management Guide.