Sas*_*sra 0 azure azure-storage azure-cli azure-blob-storage azure-metrics-advisor
我想在不使用门户(指标)的情况下检索天蓝色存储帐户的大小。如何通过 azure CLI 或 bash 脚本获取存储帐户的指标?有没有办法通过 azure CLI 或任何 bash 脚本来实现这一点?
查看 AZ CLI 命令,我相信当前没有可用的命令可以直接为您提供此信息。
您需要做的是使用az rest并调用Metrics - ListREST API 并解析响应。
这是您想要执行的命令:
az rest --uri https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>/providers/Microsoft.Insights/metrics?api-version=2018-01-01&metricnames=UsedCapacity&aggregation=Average
Run Code Online (Sandbox Code Playgroud)
您将得到如下响应:
{
"cost": 59,
"interval": "PT1H",
"namespace": "Microsoft.Storage/storageAccounts",
"resourceregion": "resource-location",
"timespan": "2021-10-27T05:12:06Z/2021-10-27T06:12:06Z",
"value": [
{
"displayDescription": "The amount of storage used by the storage account. For standard storage accounts, it's the sum of capacity used by blob, table, file, and queue. For premium storage accounts and Blob storage accounts, it is the same as BlobCapacity or FileCapacity.",
"errorCode": "Success",
"id": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>/providers/Microsoft.Insights/metrics/UsedCapacity",
"name": {
"localizedValue": "Used capacity",
"value": "UsedCapacity"
},
"resourceGroup": "cerebrata",
"timeseries": [
{
"data": [
{
"average": 9078827149.0,//This is the value you would want to extract
"timeStamp": "2021-10-27T05:12:00Z"
}
],
"metadatavalues": []
}
],
"type": "Microsoft.Insights/metrics",
"unit": "Bytes"
}
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3174 次 |
| 最近记录: |