Share via

Is there any way to see sizes of individual prefixes within Storage Account containers?

Michael Alexander 20 Reputation points
2026-03-24T20:02:36.03+00:00

Is there any way to see sizes of individual prefixes within Storage Account containers?

We need a way to identify which prefixes are taking up the most storage.

Azure Blob Storage
Azure Blob Storage

An Azure service that stores unstructured data in the cloud as blobs.


Answer accepted by question author
  1. Venkatesan S 6,115 Reputation points Microsoft External Staff Moderator
    2026-03-24T20:16:14.0133333+00:00

    Hi Michael Alexander,

    Thanks for reaching out in Microsoft Q&A forum,

    Is there any way to see sizes of individual prefixes within Storage Account containers?

    Yes, you can check sizes of individual prefixes (virtual folders) in Azure Blob Storage containers, but it requires scripting since the portal lacks native prefix-level metrics. Use Azure CLI or PowerShell to list blobs per prefix and sum their sizes—this identifies the largest space consumers efficiently.

    Azure CLI Approach

    Run az storage blob list with --prefix to target a folder, then aggregate sizes in a script. For example:

    az storage blob list --account-name <storage-account> --container-name <container> --prefix "your/prefix/" --query "[].{Name:name, Size:properties.contentLength}" -o table --auth-mode login
    

    User's image

    Loop over prefixes in Bash/Python for a full report; enable hierarchical namespace on the account for better directory handling.

    Metrics show container totals only (via Monitor > Capacity); for visuals, Azure Storage Explorer displays folder sizes on refresh. Inventory reports (Blob service > Data management) enable CSV exports for Synapse analysis at prefix level.

    Update:

    I need a way to see a summary of the sizes of the prefixes themselves, not of the individual files within them. I would also like to know the size of any nested prefixes.

    Azure Blob Storage doesn't provide native prefix-level size metrics in the portal, but you can use this PowerShell script to get a complete breakdown of all prefixes (including nested folders) and their total sizes:

    Script:

    Azure PowerShell

    $account = "venkattest326"
    $container = "test"
    $rgName = "v-venkatesan"
    # Get context with RG specified
    $ctx = (Get-AzStorageAccount -ResourceGroupName $rgName -Name $account).Context
    # Get all blobs and calculate prefix sizes recursively
    $prefixSizes = @{}
    Get-AzStorageBlob -Container $container -Context $ctx | ForEach-Object {
        $pathParts = $_.Name -split '/'
        $currentPrefix = ""
        
        for ($i = 0; $i -lt $pathParts.Count -1; $i++) {  # Stop before filename
            $currentPrefix += if ($currentPrefix -eq "") { $pathParts[$i] } else { "/$($pathParts[$i])" }
            $prefixKey = "$currentPrefix/"
            if (-not $prefixSizes.ContainsKey($prefixKey)) {
                $prefixSizes[$prefixKey] = 0
            }
            $prefixSizes[$prefixKey] += $_.Length
        }
    }
    # Convert to objects, sort by size, display
    $prefixSizes.GetEnumerator() | ForEach-Object {
        [PSCustomObject]@{
            Prefix = $_.Key
            SizeGB = [math]::Round($_.Value / 1GB, 2)
        }
    } | Sort-Object SizeGB -Descending | Format-Table -AutoSize
    
    

    Output:User's image

    Azure PowerShell

    Prefix       SizeGB
    ------       ------
    sample/       0.250
    sample/data/  0.110
    data/         0.000
    

    Reference:

    Kindly let us know if the above helps or you need further assistance on this issue.

    Please do not forget to 210246-screenshot-2021-12-10-121802.pngand “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.