When working with a large amount of data it should have a proper life cycle management implement to use storage capacity more effectively and cost-effectively. Data has a unique lifecycle, at the beginning data are used frequently. But the need for access drops drastically as the data ages. Azure Life Cycle policy offers customers rich storage management for Blob Storage & General Purpose V2 storage accounts.
The lifecycle management policy lets you:
- Transition blobs to a cooler storage tier (hot to cool, hot to archive, or cool to archive) to optimize for performance and cost
- Delete blobs at the end of their lifecycles
- Define rules to be run once per day at the storage account level
- Apply rules to containers or a subset of blobs (using prefixes as filters)
Following demo shows how to create a storage life cycle policy through PowerShell. Apart form PowerShell it can configure through Portal, Azure CLI and etc.
We use a $action variable to hold the life cycle policy configuration and later pass that configuration to New-AzStorageAccountManagementPolicyRule
Add-AzStorageAccountManagementPolicyAction -BaseBlobAction Delete -daysAfterModificationGreaterThan 200
The above command creates a configuration rule to delete any objects that are greater than 200 days after the last modification.
Add-AzStorageAccountManagementPolicyAction -InputObject $action -BaseBlobAction TierToArchive -daysAfterModificationGreaterThan 90
The above command used to move any object to archive mode when the last modified date is more than 90 days.
Add-AzStorageAccountManagementPolicyAction -InputObject $action -BaseBlobAction TierToCool -daysAfterModificationGreaterThan 30
Move any data to cool storage after 30 days.