Azure – Get Storage Account Lifecycle Management Policy Rules

By Saad Khamis

October 12, 2023

44830 views

In this blog I will share one way to get Azure Storage Account Lifecycle Management Policy Rules.

What is Azure Storage Account Lifecycle Management Policy?

According to Microsoft, Azure Storage lifecycle management offers a rule-based policy that you can use to transition blob data to the appropriate access tiers or to expire data at the end of the data lifecycle. A lifecycle management policy is a collection of rules in a JSON document.

More information can be found in Configure a lifecycle management policy and Optimize costs by automatically managing the data lifecycle.

Prerequisites

  1. First thing to remember is to install Azure PowerShell. Otherwise, you can use Cloud Shell if you prefer to stay within Azure Portal.
  2. Secondly, connect to Azure using Connect-AzAccount.

PowerShell Cmdlets

  1. Connect-AzAccount Connect to Azure with an authenticated account for use with cmdlets from the Az PowerShell modules.
  2. Get-AzStorageAccountManagementPolicy Gets the management policy of an Azure Storage account.

Lifecycle Management Policy Rules for a Storage Account

  1. First we will identify a storage account by its name a its resource group.
  2. Second, we will use Get-AzStorageAccountManagementPolicy to get the storage account management policy.
  3. Last step is to get the policy rules.

Get Lifecycle Management Policy Rules for a Storage Account

Output of the last command if the storage has a lifecycle management policy:

Output of the last command if the storage does not have a lifecycle management policy:

Get Lifecycle Management Policy Rules for All Storage Accounts

  1. First, we will get all existing Azure storage accounts.
  2. Second, For each storage account, we will get lifecycle management policy.
  3. Last, we will get rules for the storage account lifecycle management policy.

Note the usage of -ErrorAction SilentlyContinue to suppress displaying errors when the storage account does not have a lifecycle management policy.

Import Lifecycle Management Policy Rules for All Storage Accounts to CSV File

Conclusion

Did you find this blog easy to follow and helpful to you? Let me know in the comments below.

Disclaimer

Purpose of the code contained in blog is solely for learning and demo purposes. Author will not be held responsible for any failure or damages caused due to any other usage.

Comments

There's no comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

List all AWS Certificate Manager certificates

By Saad Khamis 15969 views July 31, 2024

Get all AWS EBS snapshots across all profiles and regions

By Saad Khamis 20334 views June 26, 2024