Azure Storage is a robust and scalable cloud storage resolution offered by Microsoft Azure.
Monitoring the utilization of your Azure Storage accounts is essential for optimizing prices and making certain environment friendly useful resource utilization. On this weblog put up, we are going to discover how one can programmatically retrieve Azure Storage account utilization utilizing Azure PowerShell Module.
It’s simple to get the Storage Utilization for one of many accounts as you need to use the GUI however to get the storage throughout a number of accounts is considerably troublesome.
For getting the identical throughout a number of accounts I believed I can crawl via every storage account after which via Blob and add up the size property.
All the things was good till I hit an enormous storage account that had hundreds of thousands of blobs, it caught there for a day and half earlier than I needed to Kill it.
So how we will get that information, easy reply is as an alternative of utilizing Get-AzStorageContainer adopted by Get-AzStorageBlob We’ve to make the most of Get-AzMetric.
Sure, it is advisable to get that information from Azure monitor.
It is best to have Monitoring Reader function and you may extract the information from Azure Monitor.
Let me share instance command so to construct upon it.
$resourceId = “/subscriptions/$subscriptionId/resourceGroups/$($storageAccount.ResourceGroupName)/suppliers/Microsoft.Storage/storageAccounts/$($storageAccount.StorageAccountName)”
$metric = (Get-AzMetric -ResourceId $resourceId -MetricName “UsedCapacity” -StartTime “02:00:00” -EndTime “04:00:00”)
$SizeInGB = [Math]::Spherical($metric.information[0].Common / (1GB), 2)
Metric information incorporates beneath output:
$SizeInGB is only a components to transform the primary vale to Gbs.
That is what I’ve used to fetch the storage information throughout a number of accounts of an enormous group.
I hope this TIP will help you in constructing the answer in case you are additionally struggling on how one can get this data.
Thanks for studying and downloading…
Tech Wizard