首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure Cost Management API不允许我选择列

Azure Cost Management API不允许我选择列
EN

Stack Overflow用户
提问于 2020-11-10 20:45:48
回答 1查看 188关注 0票数 0

我尝试使用Azure Cost Management - Query Usage API来获取给定订阅的所有成本的详细信息(某些列)。我用于请求的主体是

代码语言:javascript
复制
{
"type": "Usage",
"timeframe": " BillingMonthToDate ",
"dataset": {
    "granularity": "Daily",
    "configuration": {
        "columns": [
            "MeterCategory",
            "CostInBillingCurrency",
            "ResourceGroup"
        ]
    }
}

但我得到的回应是:

代码语言:javascript
复制
{  
"id": "xxxx",  
"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": [
  [
    20201101,
    "EUR"
  ],
  [
    20201102,
    "EUR"
  ],
  [
    20201103,
    "EUR"
  ], 
...    
]
}

JSON继续列出该货币的所有日期。

当我在JSON中使用dataset.aggregation或dataset.grouping子句时,我确实在JSON中得到了返回的成本,但是我没有得到我想要的详细列信息。当然,不可能将这两个子句与dataset.columns子句结合使用。有人知道我做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2020-11-11 00:14:05

我找到了一个不使用dataset.columns子句的解决方案(这可能只是一个错误的子句?)。通过根据我想要的列对数据进行分组,我还可以获得这些列值的数据:

代码语言:javascript
复制
{
  "type": "Usage",
  "timeframe": "BillingMonthToDate",
  "dataset": {
"granularity": "Daily",
"aggregation": {
  "totalCost": {
    "name": "PreTaxCost",
    "function": "Sum"
  }
},
"grouping": [
  {
    "type": "Dimension",
    "name": "SubscriptionName"
  },
        {
    "type": "Dimension",
    "name": "ResourceGroupName"
  }
  ,
        {
    "type": "Dimension",
    "name": "meterSubCategory"
  }
  ,
        {
    "type": "Dimension",
    "name": "MeterCategory"
  }
]

}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64769203

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档