Storage Life Cycle Management

Life-cycle management of Azure blob gives you ability to manage your blobs as per the blob requirement or data use by which you can transition your data from Hot tier >> cold  >> archive and delete eventually.

Life management policy :

Transition blobs to hot to cold and cold to archive in order to optimize performance and cost.
Delete blobs at the end of their life-cycles
Define up to 100 rules
Run rule automatically once a day
Apply rules to containers or specific blobs or folders up to 10 prefixes per rule.


Life Cycle  Management policy is available for GPv2 and Blob storage accounts only.
You can upgrade GPv1 to GPv2 and utilize the policies.

This is free of cost service and available in all regions.

Below is the code by which you can easily create and apply your rule or policies.

#Initialize the following with your resource group and storage account names
$rgname = "brg"
$accountName = "lifecyclepol"

#Create a new action object
$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction Delete -daysAfterModificationGreaterThan 30
$action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -BaseBlobAction TierToArchive -daysAfterModificationGreaterThan 2
$action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -BaseBlobAction TierToCool -daysAfterModificationGreaterThan 1
$action = Add-AzStorageAccountManagementPolicyAction -InputObject $action -SnapshotAction Delete -daysAfterCreationGreaterThan 3

# Create a new filter object
# PowerShell automatically sets BlobType as “blockblob” because it is the only available option currently
$filter = New-AzStorageAccountManagementPolicyFilter -PrefixMatch ab,cd

#Create a new rule object
#PowerShell automatically sets Type as “Lifecycle” because it is the only available option currently
$rule1 = New-AzStorageAccountManagementPolicyRule -Name Test -Action $action -Filter $filter

#Set the policy
$policy = Set-AzStorageAccountManagementPolicy -ResourceGroupName $rgname -StorageAccountName $accountName -Rule $rule1


Once you run above code you need to go to the Storage account >> Blob service >> Lifecycle management and you can see your rule. You can also create rule from there as well. Below are the snippets -









1 comment:

  1. Now it is known to me that articles is nothing but inspiring is everything to do something great. This is a great article for the people who want to come in freelancing.
    Asset Management Software
    Fixed Asset Management Software
    Asset Tracking Software
    Asset Management System
    Asset Management Software Dubai

    ReplyDelete

Azure DevOps

Azure DevOps is a suite of development tools provided by Microsoft, designed to support the entire development lifecycle of a software proje...