Query - Usage

定義されたスコープの使用状況データに対してクエリを実行します。

POST https://management.azure.com/{scope}/providers/Microsoft.CostManagement/query?api-version=2023-03-01

URI パラメーター

Name / 必須 説明
scope
path True

string

クエリ操作とエクスポート操作に関連付けられているスコープ。 これには、サブスクリプション スコープの場合は '/subscriptions/{subscriptionId}/'、resourceGroup スコープの場合は '/subscriptionId}/resourceGroup}/{resourceGroupName}' が含まれます。 '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners.

api-version
query True

string

この操作に使用する API バージョン。

要求本文

Name 必須 説明
dataset True

QueryDataset

Has definition for data in this query.

timeframe True

TimeframeType

The time frame for pulling data for the query. If custom, then a specific time period must be provided.

type True

ExportType

The type of the query.

timePeriod

QueryTimePeriod

Has time period for pulling data for the query.

応答

Name 説明
200 OK

QueryResult

OK です。 要求は成功しました。

204 No Content

コンテンツがありません。 リソースは使用できません。

Other Status Codes

ErrorResponse

操作に失敗した理由を説明するエラー応答。

セキュリティ

azure_auth

Azure Active Directory OAuth2 フロー。

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name 説明
user_impersonation ユーザー アカウントを偽装する

BillingAccountQuery-Legacy
BillingAccountQuery-MCA
BillingAccountQueryGrouping-Legacy
BillingAccountQueryGrouping-MCA
BillingProfileQuery-MCA
BillingProfileQueryGrouping-MCA
CustomerQuery-MCA
CustomerQueryGrouping-MCA
DepartmentQuery-Legacy
DepartmentQueryGrouping-Legacy
EnrollmentAccountQuery-Legacy
EnrollmentAccountQueryGrouping-Legacy
InvoiceSectionQuery-MCA
InvoiceSectionQueryGrouping-MCA
ManagementGroupQuery-Legacy
ManagementGroupQueryGrouping-Legacy
ResourceGroupQuery-Legacy
ResourceGroupQueryGrouping-Legacy
SubscriptionQuery-Legacy
SubscriptionQueryGrouping-Legacy

BillingAccountQuery-Legacy

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

BillingAccountQuery-MCA

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

BillingAccountQueryGrouping-Legacy

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

BillingAccountQueryGrouping-MCA

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

BillingProfileQuery-MCA

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

BillingProfileQueryGrouping-MCA

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

CustomerQuery-MCA

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

CustomerQueryGrouping-MCA

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

DepartmentQuery-Legacy

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

DepartmentQueryGrouping-Legacy

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

EnrollmentAccountQuery-Legacy

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

EnrollmentAccountQueryGrouping-Legacy

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "Daily",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ]
    ]
  }
}

InvoiceSectionQuery-MCA

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

InvoiceSectionQueryGrouping-MCA

Sample Request

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Sample Response

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

ManagementGroupQuery-Legacy

Sample Request

POST https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

ManagementGroupQueryGrouping-Legacy

Sample Request

POST https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Sample Response

{
  "id": "providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ]
    ]
  }
}

ResourceGroupQuery-Legacy

Sample Request

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "subscriptions/55312978-ba1b-415c-9304-c4b9c43c0481/resourcegroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/Query/9af9459d-441d-4055-9ed0-83d4c4a363fb",
  "name": "9af9459d-441d-4055-9ed0-83d4c4a363fb",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": null,
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        2.10333307059661,
        "ScreenSharingTest-peer",
        20180417,
        "USD"
      ],
      [
        20.10333307059661,
        "ScreenSharingTest-peer",
        20180418,
        "USD"
      ]
    ]
  }
}

ResourceGroupQueryGrouping-Legacy

Sample Request

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "Daily",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceType"
      }
    ]
  }
}

Sample Response

{
  "id": "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/Query/9af9459d-441d-4055-9ed0-83d4c4a363fb",
  "name": "9af9459d-441d-4055-9ed0-83d4c4a363fb",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": null,
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceType",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        2.10333307059661,
        "Microsoft.SqlServer",
        20180417,
        "USD"
      ],
      [
        20.10333307059661,
        "Microsoft.Compute",
        20180418,
        "USD"
      ]
    ]
  }
}

SubscriptionQuery-Legacy

Sample Request

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/query?api-version=2023-03-01

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

Sample Response

{
  "id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/Query/00000000-0000-0000-0000-000000000000",
  "name": "55312978-ba1b-415c-9304-cfd9c43c0481",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": null,
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        2.10333307059661,
        "ScreenSharingTest-peer",
        20180331,
        "USD"
      ],
      [
        218.68795741935486,
        "Ict_StratAndPlan_GoldSprova_Prod",
        20180331,
        "USD"
      ],
      [
        0.14384913581657052,
        "ssbciotelement01",
        20180401,
        "USD"
      ],
      [
        0.009865586851323632,
        "ict_stratandplan_goldsprova_prod",
        20180429,
        "USD"
      ]
    ]
  }
}

SubscriptionQueryGrouping-Legacy

Sample Request

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/query?api-version=2023-03-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Sample Response

{
  "id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/Query/00000000-0000-0000-0000-000000000000",
  "name": "55312978-ba1b-415c-9304-cfd9c43c0481",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": null,
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        0.009865586851323632,
        "Ict_StratAndPlan_GoldSprova_Prod_0",
        "USD"
      ],
      [
        218.68795741935486,
        "Ict_StratAndPlan_GoldSprova_Prod_1",
        "USD"
      ],
      [
        2.10333307059661,
        "ScreenSharingTest-peer1",
        "USD"
      ],
      [
        0.14384913581657052,
        "Ssbciotelement01",
        "USD"
      ]
    ]
  }
}

定義

Name 説明
ErrorDetails

The details of the error.

ErrorResponse

エラー応答は、サービスが受信要求を処理できないことを示します。 理由は、エラー メッセージに示されています。

いくつかのエラー応答:

  • 429 TooManyRequests - 要求が調整されました。 "x-ms-ratelimit-microsoft.consumption-retry-after" ヘッダーで指定された時間を待ってから再試行します。

  • 503 ServiceUnavailable - サービスは一時的に使用できません。 "Retry-After" ヘッダーで指定された時刻まで待ってから、再試行してください。

ExportType

The type of the query.

FunctionType

The name of the aggregation function to use.

GranularityType

予測内の行の粒度。

QueryAggregation

クエリで使用する集計式。

QueryColumn

QueryColumn プロパティ

QueryColumnType

エクスポートの列の型。

QueryComparisonExpression

クエリで使用する比較式。

QueryDataset

クエリに存在するデータの定義。

QueryDatasetConfiguration

クエリ内のデータセットの構成。

QueryDefinition

クエリの定義。

QueryFilter

エクスポートで使用するフィルター式。

QueryGrouping

クエリで使用する式によるグループ化。

QueryOperatorType

The operator to use for comparison.

QueryResult

クエリの結果。 グループ化と集計の下に一覧表示されるすべての列が含まれます。

QueryTimePeriod

クエリのデータをプルするための開始日と終了日。

TimeframeType

The time frame for pulling data for the query. If custom, then a specific time period must be provided.

ErrorDetails

The details of the error.

Name 説明
code

string

エラー コード。

message

string

操作が失敗した理由を示すエラー メッセージ。

ErrorResponse

エラー応答は、サービスが受信要求を処理できないことを示します。 理由は、エラー メッセージに示されています。

いくつかのエラー応答:

  • 429 TooManyRequests - 要求が調整されました。 "x-ms-ratelimit-microsoft.consumption-retry-after" ヘッダーで指定された時間を待ってから再試行します。

  • 503 ServiceUnavailable - サービスは一時的に使用できません。 "Retry-After" ヘッダーで指定された時刻まで待ってから、再試行してください。

Name 説明
error

ErrorDetails

エラーの詳細。

ExportType

The type of the query.

Name 説明
ActualCost

string

AmortizedCost

string

Usage

string

FunctionType

The name of the aggregation function to use.

Name 説明
Sum

string

GranularityType

予測内の行の粒度。

Name 説明
Daily

string

QueryAggregation

クエリで使用する集計式。

Name 説明
function

FunctionType

使用する集計関数の名前。

name

string

集計する列の名前。

QueryColumn

QueryColumn プロパティ

Name 説明
name

string

列の名前。

type

string

列の型。

QueryColumnType

エクスポートの列の型。

Name 説明
Dimension

string

コスト データのディメンション。

TagKey

string

コスト データに関連付けられているタグ。

QueryComparisonExpression

クエリで使用する比較式。

Name 説明
name

string

比較に使用する列の名前。

operator

QueryOperatorType

比較に使用する演算子。

values

string[]

比較に使用する値の配列

QueryDataset

クエリに存在するデータの定義。

Name 説明
aggregation

<string,  QueryAggregation>

クエリで使用する集計式のディクショナリ。 ディクショナリ内の各項目のキーは、集計列の別名です。 クエリには、最大 2 つの集計句を含めることができます。

configuration

QueryDatasetConfiguration

エクスポート内のデータの構成情報があります。 集計とグループ化が指定されている場合、構成は無視されます。

filter

QueryFilter

クエリで使用するフィルター式。 フィルターを適切に書式設定する方法については、クエリ API REST のドキュメントを参照してください。

granularity

GranularityType

クエリ内の行の粒度。

grouping

QueryGrouping[]

クエリで使用する式によるグループの配列。 クエリには、句ごとに最大 2 つのグループを含めることができます。

QueryDatasetConfiguration

クエリ内のデータセットの構成。

Name 説明
columns

string[]

クエリに含める列名の配列。 有効なクエリ列名は許可されます。 指定されていない場合は、クエリにすべての列が含まれます。

QueryDefinition

クエリの定義。

Name 説明
dataset

QueryDataset

このクエリにデータの定義があります。

timePeriod

QueryTimePeriod

クエリのデータをプルするための期間があります。

timeframe

TimeframeType

クエリのデータをプルするための時間枠。 カスタムの場合は、特定の期間を指定する必要があります。

type

ExportType

クエリの型。

QueryFilter

エクスポートで使用するフィルター式。

Name 説明
and

QueryFilter[]

論理 "AND" 式。 少なくとも 2 つの項目が必要です。

dimensions

QueryComparisonExpression

ディメンションの比較式がある

or

QueryFilter[]

論理 "OR" 式。 Must have at least 2 items.

tags

QueryComparisonExpression

タグの比較式がある

QueryGrouping

クエリで使用する式によるグループ化。

Name 説明
name

string

グループ化する列の名前。

type

QueryColumnType

グループ化する列の型を持っています。

QueryOperatorType

The operator to use for comparison.

Name 説明
In

string

QueryResult

クエリの結果。 グループ化と集計の下に一覧表示されるすべての列が含まれます。

Name 説明
eTag

string

リソースの ETag。

id

string

リソース ID。

location

string

リソースの場所。

name

string

リソース名。

properties.columns

QueryColumn[]

列の配列

properties.nextLink

string

結果の次のページへのリンク (URL)。

properties.rows

array[]

行の配列

sku

string

リソースの SKU。

tags

object

リソース タグ。

type

string

リソースの種類。

QueryTimePeriod

クエリのデータをプルするための開始日と終了日。

Name 説明
from

string

データをプルする開始日。

to

string

データをプルする終了日。

TimeframeType

The time frame for pulling data for the query. If custom, then a specific time period must be provided.

Name 説明
BillingMonthToDate

string

Custom

string

MonthToDate

string

TheLastBillingMonth

string

TheLastMonth

string

WeekToDate

string