Hello cloudteam
Thank you for posting your query on Microsoft Q&A platform.
Blob Container Count (ContainerCount) in Azure Monitor appears to show half the actual number of containers when you use the Average aggregation in Metrics Explorer.
- For the resource type
Microsoft.Storage/storageAccounts/blobServices, the metricContainerCountis defined with Aggregation = Average and Time grain = PT1H (hourly). It can also be split by theAccessLeveldimension. - In Azure Monitor, Average is calculated over the selected time grain. If your container count changes mid‑hour (e.g., from 0 to 5 at the 30‑minute mark), the hour’s Average becomes the time‑weighted mean:
(0 for 30 min + 5 for 30 min) / 60 min = 2.5. That’s why you observed 1 (for 2 created halfway through the hour) and 2.5 (for 5 created halfway through). This is the documented aggregation behavior of Azure Monitor metrics.
The Metrics Explorer value is an hourly average, not a “point‑in‑time” snapshot. It will only equal your current container count when the count is stable for the entire hour.
Reference: https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/metrics-aggregation-explained
As a resolution:
If you need the precise current count (not an hour‑average):
Use the Storage (data‑plane) API – List Containers Call List Containers on the Blob service and count the returned items. This returns the exact container count at query time.
- REST: List Containers (Blob service)
- SDK examples: List blob containers (.NET), List blob containers (JavaScript/TypeScript)
Reference: https://learn.microsoft.com/en-us/rest/api/storageservices/list-containers2?tabs=microsoft-entra-id
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-containers-list
Use the Resource Provider (management‑plane) API If you prefer the ARM path, Blob Containers – List under the Storage Resource Provider lists containers for the account.
If you must use Metrics Explorer Plot ContainerCount with time grain = 1 hour and select an hour window during which your number of containers did not change. The Average for that hour will match the actual count.
About using total (Sum) aggregation in the Metrics REST API:
- The Metrics List REST API does accept an
aggregationparameter (e.g.,average, minimum, maximum, total), but each metric publishes the aggregations it actually supports via its definition. You should only request supported types for that metric. - For
ContainerCountspecifically, the supported aggregation is onlyAverage(per the Storage Blob Services supported metrics table). Usingtotalmay return data today, but it’s not documented for this metric and therefore not guaranteed.
Use only documented aggregations from the metric’s definition. For an exact count, use the List Containers API rather than relying on an undocumented aggregation.
https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-storage-storageaccounts-blobservices-metrics and https://learn.microsoft.com/en-us/rest/api/storageservices/list-containers2?tabs=microsoft-entra-id
To answer to your questions:
1.How is ContainerCount (Average) calculated? Why does it show half?
It’s the time‑weighted average over the one‑hour time grain. If the count changes halfway through the hour, the hour’s average can be ~half of the final value. This is by design.
2.Is it safe to use total aggregation for this metric?
No. ContainerCount only lists Average as supported. Requests for total are undocumented for this metric and not guaranteed to be correct or stable. Use Average (with a stable hour) or use List Containers for an exact count.
3.Has behavior changed recently?
There is no published change that adds total support to ContainerCount. Current documentation still shows Average‑only with PT1H sampling.
4.Could total stop working in the future since it’s not officially supported?
Yes. Because it’s not a documented aggregation for ContainerCount, Azure can change or reject such requests at any time. Stick to supportedAggregationTypes and the metric definition
If you have any other queries, please do let us know.
Thanks,
Suchitra.