What is the total size allocated to a Storage account and the for types like Queues, tables, blobs and files.

Girish Prajwal 706 Reputation points
2023-03-23T12:59:42.8666667+00:00

Hi team,What is the total size allocated to a Storage account and the for types like Queues, tables, blobs and files.Also I would like to know consumed size for all the types abo eve using powershell or using KQL. This requirement is across our subs.

Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,542 questions
{count} vote

Accepted answer
  1. Sumarigo-MSFT 47,471 Reputation points Microsoft Employee Moderator
    2023-03-23T16:20:56.75+00:00

    @Girish Prajwal Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    To determine the total size allocated to a storage account and the consumed size for each of its storage types (queues, tables, blobs, and files), you can use either PowerShell or Kusto Query Language (KQL).

    Calculate the size/capacity of storage account and it services (Blob/Table)

    Using PowerShell, you can use the Get-AzMetric cmdlet to retrieve the total size allocated to a storage account, and the Get-AzStorageAccountUsage cmdlet to retrieve the consumed size for each storage type. Here's an example PowerShell script to achieve this:

    # Login to your Azure account
    Connect-AzAccount
    
    # Set the context to the subscription that contains your storage account
    Set-AzContext -SubscriptionId <SubscriptionId>
    
    # Retrieve the total allocated size of the storage account
    $storageAccountName = "<StorageAccountName>"
    $resourceId = "/subscriptions/<SubscriptionId>/resourceGroups/<ResourceGroupName>/providers/Microsoft.Storage/storageAccounts/$storageAccountName"
    $metric = Get-AzMetric -ResourceId $resourceId -TimeGrain PT1H -MetricName BlobCapacity -AggregationType Total -StartDate (Get-Date).AddDays(-1) -EndTime (Get-Date)
    $totalSize = $metric.Data | Select-Object -ExpandProperty Total | Select-Object -First 1
    
    # Retrieve the consumed size for each storage type
    $usage = Get-AzStorageAccountUsage -ResourceGroupName <ResourceGroupName> -Name $storageAccountName
    $blobSize = $usage | Where-Object {$_.Name.Value -eq "BlobCapacity"} | Select-Object -ExpandProperty CurrentValue
    $tableSize = $usage | Where-Object {$_.Name.Value -eq "TableCapacity"} | Select-Object -ExpandProperty CurrentValue
    $queueSize = $usage | Where-Object {$_.Name.Value -eq "QueueCapacity"} | Select-Object -ExpandProperty CurrentValue
    $fileSize = $usage | Where-Object {$_.Name.Value -eq "FileCapacity"} | Select-Object -ExpandProperty CurrentValue
    
    # Print the results
    Write-Host "Total allocated size: $totalSize bytes"
    Write-Host "Blob consumed size: $blobSize bytes"
    Write-Host "Table consumed size: $tableSize bytes"
    Write-Host "Queue consumed size: $queueSize bytes"
    Write-Host "File consumed size: $fileSize bytes"
    
    

    Using KQL, you can use the AzureStorageCapacity table to retrieve the total allocated size of the storage account, and the AzureStorageUsage table to retrieve the consumed size for each storage type. Here's an example KQL query to achieve this:

    
    
    AzureStorageCapacity
    | where ResourceId contains "/providers/Microsoft.Storage/storageAccounts/"
    | where ResourceId contains "<StorageAccountName>"
    | summarize TotalAllocatedSize = sum(TotalCapacity) by StorageType
    | join (
        AzureStorageUsage
        | where ResourceId contains "/providers/Microsoft.Storage/storageAccounts/"
        | where ResourceId contains "<StorageAccountName>"
        | summarize CurrentUsage = sum(CurrentValue) by StorageType
    ) on StorageType
    | project StorageType, TotalAllocatedSize, CurrentUsage
    
    

    This query retrieves the total allocated size and current usage for each storage type, and displays the results in a table. You can run this query in Azure Monitor Logs or Azure Data Explorer to retrieve the information for all storage accounts across your subscriptions.

    Please let us know if you have any further queries. I’m happy to assist you further.   


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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