Azure Tip 11: View Blob (Container) Storage in Azure Storage Account by Storage Tier (hot, cool, archive)

Sometimes you need to know how many blobs are in your storage account by storage tier (hot, cool, archive).

Of course, you can just open the Azure portal and look at your container. And you will see the storage tier there:

But if you are looking for a summary or have many blobs, that does not work. Here are 2 solutions:

Option 1: Storage Account Metrics

Just go to your storage account, select metrics from the menu and set the following filters:

  • Scope: <your storage account>
  • Metric Namespace: “Blob”
  • Metric: “Blob Count”

Then apply a split by clicking the “Apply Splitting” button and select “Blob Tier”. Voilà:

Note: Keep in mind that it might take some time to update the visualization to accurately depict the state of your blobs.

Option 2: Powershell

Just run this powershell script to get a summary:

#This script goes through your all the containers in your storage account and summarizes the storage tiers (hot, cool, blob) for every container.
#written by Manuel Meyer, 2021
clear
$connection_string = "<your storage account connection string>"
$storage_account = New-AzStorageContext -ConnectionString $connection_string
$containers = Get-AzStorageContainer -Context $storage_account

Write-Host 'Starting'

foreach ($container in $containers) {

    Write-Host -NoNewline "Container: " $container.Name
    $blobsArchive = 0;
    $blobsCool = 0;
    $blobsHot = 0;
    $blobsNone = 0;

    $blobs = Get-AzStorageBlob -Container $container.Name -Context $storage_account -IncludeDeleted -IncludeVersion

    foreach ($blob in $blobs)
    {        
        $prop = Get-AzStorageBlobCopyState -Blob $blob -Container $container
        Write-Host $blob.AccessTier $blob.Name $prop
    }  
}
Write-Host 'Analysis complete.'

Option 3: Azure Storage Explorer

Of course you can as well look at the Azure Storage Explorer, the Desktop application that lets you connect to your storage account. But that will not help (yet?) if you are looking for a summary.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.