Yes, you can get a CSV export of the total size of each container in your Azure storage accounts without having to go into each container individually. You can use Azure PowerShell or Azure CLI to automate this task.
I'll give you sample commands below for powershell and also Azure CLI, use whichever is comfortable.
# Login to your Azure account
Connect-AzAccount
# Specify your Azure storage account names
$storageAccountNames = "storageAccount1", "storageAccount2", "storageAccount3"
# Initialize an array to store the results
$containerSizes = @()
# Loop through the storage accounts
foreach ($storageAccountName in $storageAccountNames) {
$containers = Get-AzStorageContainer -Context (Get-AzStorageAccount -ResourceGroupName <YourResourceGroupName> -Name $storageAccountName).Context
foreach ($container in $containers) {
$containerSize = Get-AzStorageContainerStatistics -Context $container.Context
$containerInfo = [PSCustomObject]@{
StorageAccountName = $storageAccountName
ContainerName = $container.Name
TotalSizeInBytes = $containerSize.TotalSize
}
$containerSizes += $containerInfo
}
}
# Export the results to a CSV file
$containerSizes | Export-Csv -Path "container_sizes.csv" -NoTypeInformation
# Log in to your Azure account
az login
# Set your Azure subscription
az account set --subscription "<put YourSubscriptionName>"
# Specify your Azure storage account names
storageAccountNames=("storageAccount1" "storageAccount2" "storageAccount3")
# Initialize an array to store the results
containerSizes=()
# Loop through the storage accounts
for storageAccountName in "${storageAccountNames[@]}"; do
containers=$(az storage container list --account-name "$storageAccountName" --query "[].name" --output tsv)
for container in $containers; do
containerSize=$(az storage container show --name "$container" --account-name "$storageAccountName" --query "properties | {Name: name, TotalSize: properties | {TotalSize: properties.metadata.TotalSize}}" --output json)
containerSizes+=("$storageAccountName,$container,$containerSize")
done
done
# Export the results to a CSV file
echo "StorageAccountName,ContainerName,TotalSizeInBytes" > container_sizes.csv
for size in "${containerSizes[@]}"; do
echo "$size" >> container_sizes.csv
done
If you find this answer useful kindly accept it, thanks very much.