Query - Usage
查詢所定義範圍的使用量數據。
POST https://management.azure.com/{scope}/providers/Microsoft.CostManagement/query?api-version=2024-08-01
URI 參數
名稱 | 位於 | 必要 | 類型 | Description |
---|---|---|---|---|
scope
|
path | True |
string |
與查詢和匯出作業相關聯的範圍。 這包括訂用帳戶範圍的 '/subscriptions/{subscriptionId}/' 、'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' 資源群組範圍、 計費帳戶範圍的 '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' 和 '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{EnrollmentAccount 範圍的 enrollmentAccount 範圍,'/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, billingProfile 範圍的 '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}'、'/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfileId}/{billingProfileId}/invoiceSections/{invoiceSectionId}' 和 '/providers/Microsoft。Billing/billingAccounts/{billingAccountId}/customers/{customerId}' 特定合作夥伴。 |
api-version
|
query | True |
string |
要用於這項作業的 API 版本。 |
要求本文
名稱 | 必要 | 類型 | Description |
---|---|---|---|
dataset | True |
具有此查詢中數據的定義。 |
|
timeframe | True |
提取查詢數據的時間範圍。 如果為 custom,則必須提供特定的時間週期。 |
|
type | True |
查詢的類型。 |
|
timePeriod |
有提取查詢數據的時間週期。 |
回應
名稱 | 類型 | Description |
---|---|---|
200 OK |
還行。 要求已成功。 |
|
204 No Content |
沒有內容。 無法使用資源。 |
|
Other Status Codes |
描述作業失敗原因的錯誤回應。 |
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
名稱 | Description |
---|---|
user_impersonation | 模擬您的用戶帳戶 |
範例
BillingAccountQuery-Legacy
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "Daily",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "Daily",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceType"
}
]
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/query?api-version=2024-08-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"
]
}
}
]
}
}
}
範例回覆
{
"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
範例要求
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/query?api-version=2024-08-01
{
"type": "Usage",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
範例回覆
{
"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"
]
]
}
}
定義
名稱 | Description |
---|---|
Error |
錯誤的詳細數據。 |
Error |
錯誤回應表示服務無法處理傳入要求。 錯誤訊息中會提供原因。 某些錯誤回應:
|
Export |
查詢的類型。 |
Function |
要使用的聚合函數名稱。 |
Granularity |
預測中的數據列粒度。 |
Query |
要用於查詢的匯總表達式。 |
Query |
QueryColumn 屬性 |
Query |
匯出中數據行的類型。 |
Query |
要在查詢中使用的比較表達式。 |
Query |
查詢中存在的數據定義。 |
Query |
查詢中數據集的組態。 |
Query |
查詢的定義。 |
Query |
要用於導出的篩選表達式。 |
Query |
要用於查詢中的依表示式分組。 |
Query |
要用於比較的運算符。 |
Query |
查詢的結果。 它包含群組和匯總下所列的所有數據行。 |
Query |
用於提取查詢數據的開始和結束日期。 |
Timeframe |
提取查詢數據的時間範圍。 如果為 custom,則必須提供特定的時間週期。 |
ErrorDetails
錯誤的詳細數據。
名稱 | 類型 | Description |
---|---|---|
code |
string |
錯誤碼。 |
message |
string |
錯誤訊息,指出作業失敗的原因。 |
ErrorResponse
錯誤回應表示服務無法處理傳入要求。 錯誤訊息中會提供原因。
某些錯誤回應:
429 TooManyRequests - 要求已節流。 等候 「x-ms-ratelimit-microsoft.consumption-retry-after」 標頭中指定的時間後重試。
503 ServiceUnavailable - 服務暫時無法使用。 等候 「Retry-After」 標頭中指定的時間後重試。
名稱 | 類型 | Description |
---|---|---|
error |
錯誤的詳細數據。 |
ExportType
查詢的類型。
名稱 | 類型 | Description |
---|---|---|
ActualCost |
string |
|
AmortizedCost |
string |
|
Usage |
string |
FunctionType
要使用的聚合函數名稱。
名稱 | 類型 | Description |
---|---|---|
Sum |
string |
GranularityType
預測中的數據列粒度。
名稱 | 類型 | Description |
---|---|---|
Daily |
string |
QueryAggregation
要用於查詢的匯總表達式。
名稱 | 類型 | Description |
---|---|---|
function |
要使用的聚合函數名稱。 |
|
name |
string |
要匯總的數據行名稱。 |
QueryColumn
QueryColumn 屬性
名稱 | 類型 | Description |
---|---|---|
name |
string |
數據行的名稱。 |
type |
string |
數據行的類型。 |
QueryColumnType
匯出中數據行的類型。
名稱 | 類型 | Description |
---|---|---|
Dimension |
string |
成本數據的維度。 |
TagKey |
string |
與成本數據相關聯的標記。 |
QueryComparisonExpression
要在查詢中使用的比較表達式。
名稱 | 類型 | Description |
---|---|---|
name |
string |
要用於比較的數據行名稱。 |
operator |
要用於比較的運算符。 |
|
values |
string[] |
要用於比較的值陣列 |
QueryDataset
查詢中存在的數據定義。
名稱 | 類型 | Description |
---|---|---|
aggregation |
<string,
Query |
要用於查詢的匯總表示式字典。 字典中每個專案的索引鍵是匯總數據行的別名。 查詢最多可以有 2 個匯總子句。 |
configuration |
具有匯出中數據的組態資訊。 如果提供匯總和群組,將會忽略組態。 |
|
filter |
要用於查詢的篩選表達式。 如需如何正確格式化篩選條件,請參閱我們的查詢 API REST 檔。 |
|
granularity |
查詢中數據列的數據粒度。 |
|
grouping |
要用於查詢的依表示式分組陣列。 查詢最多可以有2個群組 by 子句。 |
QueryDatasetConfiguration
查詢中數據集的組態。
名稱 | 類型 | Description |
---|---|---|
columns |
string[] |
要包含在查詢中的數據行名稱陣列。 允許任何有效的查詢數據行名稱。 如果未提供,則查詢會包含所有數據行。 |
QueryDefinition
查詢的定義。
名稱 | 類型 | Description |
---|---|---|
dataset |
具有此查詢中數據的定義。 |
|
timePeriod |
有提取查詢數據的時間週期。 |
|
timeframe |
提取查詢數據的時間範圍。 如果為 custom,則必須提供特定的時間週期。 |
|
type |
查詢的類型。 |
QueryFilter
要用於導出的篩選表達式。
名稱 | 類型 | Description |
---|---|---|
and |
邏輯 「AND」 表達式。 必須至少有2個專案。 |
|
dimensions |
具有維度的比較表達式 |
|
or |
邏輯 「OR」 表達式。 必須至少有2個專案。 |
|
tags |
具有標記的比較表達式 |
QueryGrouping
要用於查詢中的依表示式分組。
名稱 | 類型 | Description |
---|---|---|
name |
string |
要分組的數據行名稱。 |
type |
具有要分組的數據行類型。 |
QueryOperatorType
要用於比較的運算符。
名稱 | 類型 | Description |
---|---|---|
In |
string |
QueryResult
查詢的結果。 它包含群組和匯總下所列的所有數據行。
名稱 | 類型 | Description |
---|---|---|
eTag |
string |
資源的 ETag。 |
id |
string |
資源標識碼。 |
location |
string |
資源的位置。 |
name |
string |
資源名稱。 |
properties.columns |
數據列陣列 |
|
properties.nextLink |
string |
結果下一頁的連結(url)。 |
properties.rows |
Rows[] |
數據列陣列 |
sku |
string |
資源的 SKU。 |
tags |
object |
資源標籤。 |
type |
string |
資源類型。 |
QueryTimePeriod
用於提取查詢數據的開始和結束日期。
名稱 | 類型 | Description |
---|---|---|
from |
string |
要從中提取數據的開始日期。 |
to |
string |
要提取數據的結束日期。 |
TimeframeType
提取查詢數據的時間範圍。 如果為 custom,則必須提供特定的時間週期。
名稱 | 類型 | Description |
---|---|---|
BillingMonthToDate |
string |
|
Custom |
string |
|
MonthToDate |
string |
|
TheLastBillingMonth |
string |
|
TheLastMonth |
string |
|
WeekToDate |
string |