You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Manually managing the lifecycle of millions of blobs is impractical. Azure Blob Storage lifecycle management policies let you automate the transition of data between access tiers and the deletion of expired data. This lesson covers how to create lifecycle policies, the rules and filters available, and practical strategies for managing data at scale.
Lifecycle management is a rule-based policy that automatically performs actions on blobs based on conditions you define. Instead of writing scripts to move or delete old data, you define rules that Azure executes automatically once per day.
A lifecycle management policy is a collection of rules. Each rule has:
Azure evaluates all rules once per day. Actions may take up to 24 hours to execute after the conditions are met.
az storage account management-policy create \
--account-name mystorageaccount \
--resource-group rg-storage-demo \
--policy @policy.json
resource lifecyclePolicy 'Microsoft.Storage/storageAccounts/managementPolicies@2023-01-01' = {
parent: storageAccount
name: 'default'
properties: {
policy: {
rules: [
{
name: 'moveToCoolAfter30Days'
enabled: true
type: 'Lifecycle'
definition: {
filters: {
blobTypes: ['blockBlob']
prefixMatch: ['logs/']
}
actions: {
baseBlob: {
tierToCool: {
daysAfterModificationGreaterThan: 30
}
tierToArchive: {
daysAfterModificationGreaterThan: 90
}
delete: {
daysAfterModificationGreaterThan: 365
}
}
}
}
}
]
}
}
}
A lifecycle management policy is a JSON document with the following structure:
{
"rules": [
{
"name": "rule-name",
"enabled": true,
"type": "Lifecycle",
"definition": {
"filters": { ... },
"actions": { ... }
}
}
]
}
| Filter | Description |
|---|---|
| blobTypes | Which blob types to target: blockBlob, appendBlob |
| prefixMatch | Blob name prefixes to match (e.g., ["logs/", "temp/"]) |
| blobIndexMatch | Match blobs by index tag key-value pairs |
Actions can target the base blob, snapshots, or versions:
| Action | Applies To | Description |
|---|---|---|
| tierToCool | Base blob, snapshot, version | Move to Cool tier |
| tierToCold | Base blob, snapshot, version | Move to Cold tier |
| tierToArchive | Base blob, snapshot, version | Move to Archive tier |
| delete | Base blob, snapshot, version | Permanently delete |
| enableAutoTierToHotFromCool | Base blob | Auto-move back to Hot if accessed from Cool |
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.