azure - 在 Azure Monitor 工作簿中针对资源管理器创建查询时出现错误消息

标签 azure azure-billing-api azure-monitor-workbooks

我正在尝试将查询添加到 Azure Monitor 中的工作簿中,以查询我的 Azure 订阅的当月至今的使用费用。

当我构造查询并运行它时,我收到以下错误消息:

BadRequest: Invalid query definition, Dataset is invalid or not supplied.

但是,此 REST API 调用的文档明确指出正文的 datasets 属性不是必需的。

文档:https://learn.microsoft.com/en-us/rest/api/cost-management/query/usage

文档截图:

enter image description here

这是我的查询在工作簿中的屏幕截图:

enter image description here

问题:当文档没有正确解释该请求时,我如何正确构建该请求的正文?

最佳答案

其实这个api-doc提供了很多示例,您可以点击任意示例查看请求正文详细信息。

BillingAccountQuery-Modern例如,请求体如下(您可以根据需要修改):

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimension": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tag": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimension": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

关于azure - 在 Azure Monitor 工作簿中针对资源管理器创建查询时出现错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63768665/

相关文章:

azure - az rest 命令获取前几个月/日期的使用详细信息。 (微软.消费)

azure - Get-UsageAggregates PowerShell cmdlet 出现 'continuationtoken' 问题

具有多个动态标记筛选器的 Azure 资源管理器查询

azure - 在azure日志门户的工作簿中添加参数

azure - 让我们加密: ClientID reqistered under application settings differs from what I entered?

azure - GetAccessPolicyAsync/SetAccessPolicyAsync 不适用于托管标识

c# - 当用户增加 SQL 数据库大小时接收通知

azure - 如何在 Azure 虚拟机中禁用自动日期时间?

azure - 保护消费计划中 APIM(Azure API 管理)中的后端 API