【问题标题】:Azure Cost Management API does not allow me to select columnsAzure 成本管理 API 不允许我选择列
【发布时间】:2020-11-10 12:45:48
【问题描述】:

我尝试使用 Azure 成本管理 - 查询使用 API 来获取给定订阅的所有成本的详细信息(某些列)。我用于请求的正文是

{
"type": "Usage",
"timeframe": " BillingMonthToDate ",
"dataset": {
    "granularity": "Daily",
    "configuration": {
        "columns": [
            "MeterCategory",
            "CostInBillingCurrency",
            "ResourceGroup"
        ]
    }
}

但是我得到的回复是这样的:

{  
"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 子句结合起来。有人知道我做错了什么吗?

【问题讨论】:

    标签: json azure api


    【解决方案1】:

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

    {
      "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"
      }
    ]
    

    }

    【讨论】:

      猜你喜欢
      • 2021-12-28
      • 2019-07-26
      • 2021-07-05
      • 1970-01-01
      • 1970-01-01
      • 2017-10-26
      • 2011-07-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多