by Steve Marx via Steve Marx's blog on 6/1/2010 11:48:41 PM
A question came up on the Windows Azure MSDN forum recently about how to find the total number of bytes used by a blobs in a particular container. There’s no API that retrieves that information at the container level, but you can compute it by enumerating the blobs, as in the following one-liner:
var totalBytes = (from CloudBlob blob in container.ListBlobs(new BlobRequestOptions() { UseFlatBlobListing = true }) select blob.Properties.Length ).Sum();
To go one step further, we can enumerate all the containers too. Here’s how to sum the sizes of all the blobs in a particular account (still a one-liner):
var totalBytes = (from container in blobClient.ListContainers() select (from CloudBlob blob in container.ListBlobs(new BlobRequestOptions() { UseFlatBlobListing = true }) select blob.Properties.Length ).Sum() ).Sum();
Note that this does not reflect the number of bytes you’re billed for. Things like empty pages in page blobs, uncommitted blocks in block blobs, snapshots, metadata, etc. all affect the total storage used in your account. The code snippets above simply sums the “sizes” (if you were to download them, for example) of all the blobs.
Original Post: Computing the Total Size of Your Blobs
The content of the postings is owned by the respective author. AzureFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on AzureFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.