Right now I'm viewing the Azure NetApp volume metrics using Azure Portal metrics dashboard.I can see only one month old data. I'm planning to collect this data and save into SQL table. So that I have the history of this data (i.e. more than 30 days). Is there a powershell commands that I can use?
1 Answers
0
votes
As per Azure NetApp Files: PowerShell One-Liners, you can use Get-AzMetric
, provide StartTime
and EndTime
to get the history of data.
For example:
Get-AzResource | Where-Object {$_.ResourceType -like 'Microsoft.NetApp/netAppAccounts/capacityPools/volumes'}
| Get-AzNetAppFilesVolume | Select-Object @{Name='ShortName'; Expression={$_.Name.split('/')[2]}}, @{Name='SizeGiB';
Expression={$_.UsageThreshold / 1024 / 1024 / 1024}},
@{Name='ConsumedGiB';
Expression={[math]::Round($((Get-AzMetric -ResourceId $_.Id -MetricName 'VolumeLogicalSize'
-StartTime $(get-date).AddMinutes(-15) -EndTime $(get-date) -TimeGrain 00:5:00 -WarningAction SilentlyContinue
| Select-Object -ExpandProperty data | Select-Object -ExpandProperty Average) | Measure-Object -average).average / 1024 / 1024 / 1024, 2)}} | Format-Table
You can refer to PowerShell and CLI for Azure NetApp Files and Azure NetApp Files metrics