Back to blog

Windows Azure Storage Capacity Metrics with Powershell


Windows Azure Storage Account provide highly competitive rates for storing vast amounts of data. As inexpensive as it is once we are storing data for tens of thousands of users these costs can start to mount up. Fortunately for us the Windows Azure Storage Team have given us some insight into these the usage of a storage accounts through the storage capacity API, all be it only Blob storage; not Table Storage or Queues.

We will need to take two steps to get metrics from your storage accounts there are several ways of doing this; however as we are likely to need to do this more than once we shall use PowerShell to script the change:

The command is self explanatory, although it is worth noting that all that has been done at this point is to mark the specified storage account as being enabled for storage analytics metrics.

It is important to note; you will not be able to retrieve storage analytics until 00:00 UTC the following day!

A task is executed once a day to calculate the used capacity of each storage account the results of these calculations is stored in a table within the same storage account named $MetricsCapacityBlob.

We can export the contents of this table to a file for any number of storage account with the following script:

This will result in the $results variable containing a list of buckets and the used capacity in bytes. The count of bytes isn’t particularly useful when it is in the billions, we can use PowerShell to output the same number in in a variety of units to cover all bases.

The above script will result in the following output.

The full source for this script can be found on in this Gist.

New call-to-action

Leave a Reply

Your email address will not be published. Required fields are marked *

The browser you're using is out of date. Please update for better security, speed and experience on this site.