Is there a way to use the Get-Azmetrics command to get the UsedCapacity for a Storage Account for a specific date or between dates?
I can use the below command to get it for a specific timespan but what about on a specific date?
(Get-AzMetric -ResourceId "your_resource_id" -MetricName "UsedCapacity" -AggregationType Average -StartTime "02:00:00" -EndTime "04:00:00").Data
CodePudding user response:
To get data for a specific date and time period, you just need to specify date/time value in yyyy-MM-ddTHH:mm:ssZ
format in -StartTime
and -EndTime
parameters. For example, look the command below. It fetches the data for 1st of July 2022 between midnight and 2:00 AM UTC.
(Get-AzMetric -ResourceId "resource-id" -MetricName "UsedCapacity" -StartTime 2022-07-01T00:00:00Z -EndTime 2022-07-01T02:00:00Z).Data
and here's the output it produced:
TimeStamp : 7/31/2022 12:00:00 AM
Average : 4093594
Minimum :
Maximum :
Total :
Count :
TimeStamp : 7/31/2022 1:00:00 AM
Average : 4094605
Minimum :
Maximum :
Total :
Count :