我使用Management检索有关某些订阅的计费使用情况的信息。
我已经创建了服务主体并成功地调用了API,但是在response对象中返回的唯一列是:
{
"name": "UsageDate",
"type": "Number"
},
{
"name": "Currency",
"type": "String"
}我需要示例文档中显示的PreTaxCost列。
https://docs.microsoft.com/en-us/rest/api/cost-management/query/usage
更新
我使用的是带有订阅范围的SubscriptionQuery-遗产示例。看看我是否能像在医生那里那样检索PreTaxtColum
但是API返回了以下错误:
{
"error": {
"code": "BadRequest",
"message": "Model validation failed: Invalid dataset filter; on a QueryFilter one and only one of and/or/not/dimension/tag can be set.\r\nInvalid dataset filter; on a QueryFilter one and only one of and/or/not/dimension/tag can be set.\r\nInvalid dataset filter; on a QueryFilter one and only one of and/or/not/dimension/tag can be set.\r\n\r\n (Request ID: bf5b35cd-739a-47b2-a1fc-6db18be3a71f)"
}
}我尝试稍微更改示例查询并删除filter属性,但它没有返回PreTaxtCost列。
我的查询结果如下:
{
"type": "Usage",
"timeframe": "MonthToDate",
"dataset": {
"granularity": "Daily"
}
}具体的反应是:
{
"id": "XXX",
"name": "XXXX",
"type": "Microsoft.CostManagement/query",
"location": null,
"sku": null,
"eTag": null,
"properties": {
"nextLink": null,
"columns": [
{
"name": "UsageDate",
"type": "Number"
},
{
"name": "Currency",
"type": "String"
}
],
"rows": [
[
20200501,
"USD"
],
[
20200502,
"USD"
],
[
20200503,
"USD"
],
[
20200504,
"USD"
],
[
20200505,
"USD"
]
]
}
}我使用辅助性问题组-遗产示例,返回的对象与文档的相同。
有什么意见能帮我理解这里的行为吗?医生已经过时了?
发布于 2020-06-04 00:46:38
我使用了请求体,如下所示,它起了作用。
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}发布于 2020-08-10 17:54:55
我遇到了同样的问题,解决方案是使用dimensions而不是dimension。是的,它需要s在最后。
https://serverfault.com/questions/1015182
复制相似问题