Reputation: 55
Is there a way to get the total size of the blobs in a storage account blobs container without iterating over them and summing up the length?
Preferably from the Java API or CLI.
We are required to get the up to date size on a regular basis and will have a large amount of blobs in the container, and we will have a lot of containers, therefore its not feasible to iterate over the blobs every time to get the sizes.
Upvotes: 1
Views: 3042
Reputation: 442
Maybe you can use Azure Monitor API which in itself would be using Azure Metrics, so call its API via REST and it over the time keeps stats so maybe that way you can get to what you need, otherwise i do not see any other way.
Upvotes: 0
Reputation: 17800
I am afraid it's not possible to bypass blob listing and summing up operation to get the size of container(i.e. blobs inside it). All SDKs are based on REST API, which includes all operation interfaces exposed to us. According to those APIs, we can only get the list of blobs and sum up their content length.
See an official example. There's a Calculate size
on Azure portal, right click on our container and click Container properties
, we can see panel as below. Try to catch the http traffic, we can see it calls list blob operation. The Learn more
link shows a powershell script to realize the unavoidable process. (Note that once blob count is over 5000, Calculate size
displays Blob Count>5000 and Size>XXMiB).
Upvotes: 1