Welcome to the Azure Storage Lifecycle Management samples repository! This repository contains code samples and documentation to help you implement and manage lifecycle policies for your Azure Blob Storage accounts.
Azure Storage Lifecycle Management provides a rich feature set to manage your blobs at different stages of their lifecycle. You can use it to transition blobs between access tiers (Hot, Cool, Archive) or delete them when they are no longer needed. This helps you to:
This repository is organized to provide clear examples and resources:
samples/
: Contains practical code samples demonstrating how to interact with Lifecycle Management policies programmatically.
azure-sdk/
: Examples using the Azure SDKs (e.g., Python, .NET, Java).arm/
: Examples using Azure Resource Manager templates.bicep/
: Examples using Bicep for infrastructure as code.documentation/
: Additional guides, tutorials, and best practices related to Lifecycle Management.
scripts/
: Utility scripts that might be helpful for managing or testing lifecycle policies.
To get started with these samples, you'll typically need:
Here's a conceptual overview of how you might define a lifecycle rule to move blobs to the Cool tier after 30 days and to the Archive tier after 90 days:
// Pseudo-code representation of a lifecycle rule configuration
{
"rules": [
{
"name": "Move_to_Cool_and_Archive",
"enabled": true,
"type": "versioning", // or "management"
"definition": {
"actions": {
"baseBlob": {
"tierToCool": { "daysAfterCreationGreaterThan": 30 },
"tierToArchive": { "daysAfterCreationGreaterThan": 90 }
},
"snapshot": {
"tierToCool": { "daysAfterCreationGreaterThan": 30 },
"tierToArchive": { "daysAfterCreationGreaterThan": 90 }
},
"version": {
"tierToCool": { "daysAfterCreationGreaterThan": 30 },
"tierToArchive": { "daysAfterCreationGreaterThan": 90 }
}
},
"filters": {
"prefix": [ "logs/" ], // Apply rule to blobs starting with 'logs/'
"blobTypes": [ "block" ]
}
}
}
]
}
We welcome contributions! Please refer to our Contribution Guidelines for details on how to submit bug reports, feature requests, or pull requests.
If you encounter any issues or have questions, please open an issue in this repository.