Query - Usage By External Cloud Provider Type
查詢已定義的外部雲端提供者類型使用量數據。
POST https://management.azure.com/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query?api-version=2025-03-01
URI 參數
| 名稱 | 位於 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
external
|
path | True |
string |
鏈接帳戶的 '{externalSubscriptionId}' 或 '{externalBillingAccountId}' 可用於維度/查詢作業的合併帳戶。 |
|
external
|
path | True |
與維度/查詢作業相關聯的外部雲端提供者類型。 這包括鏈接帳戶的 'externalSubscriptions',以及合併帳戶的 'externalBillingAccounts'。 |
|
|
api-version
|
query | True |
string minLength: 1 |
要用於這項作業的 API 版本。 |
要求本文
| 名稱 | 必要 | 類型 | Description |
|---|---|---|---|
| dataset | True |
具有此查詢中數據的定義。 |
|
| timeframe | True |
提取查詢數據的時間範圍。 如果為 custom,則必須提供特定的時間週期。 |
|
| type | True |
查詢的類型。 |
|
| timePeriod |
有提取查詢數據的時間週期。 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
要求已成功。 |
|
| Other Status Codes |
未預期的錯誤回應。 |
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
| 名稱 | Description |
|---|---|
| user_impersonation | 模擬您的用戶帳戶 |
範例
|
External |
|
External |
ExternalBillingAccountQueryList
範例要求
POST https://management.azure.com/providers/Microsoft.CostManagement/externalBillingAccounts/100/query?api-version=2025-03-01
{
"type": "Usage",
"dataset": {
"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"
]
}
}
]
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
}
範例回覆
{
"name": "6dc7b06a-d90a-4df5-b655-ce6cf1c0814d",
"type": "Microsoft.CostManagement/query",
"id": "/providers/Microsoft.CostManagement/externalBillingAccounts/100/query/6dc7b06a-d90a-4df5-b655-ce6cf1c0814d",
"properties": {
"columns": [
{
"name": "PreTaxCost",
"type": "Number"
},
{
"name": "ServiceName",
"type": "String"
},
{
"name": "Currency",
"type": "String"
}
],
"nextLink": null,
"rows": [
[
0,
"abc db",
"USD"
],
[
30.2572751438,
"abc compute cloud",
"USD"
],
[
0.07675760200000002,
"abc file system",
"USD"
],
[
50.43096419040001,
"abc elasticache",
"USD"
]
]
}
}
ExternalSubscriptionsQuery
範例要求
POST https://management.azure.com/providers/Microsoft.CostManagement/externalSubscriptions/100/query?api-version=2025-03-01
{
"type": "Usage",
"dataset": {
"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"
]
}
}
]
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
}
範例回覆
{
"name": "d99477af-7510-40ee-aca2-e59bdca0d10d",
"type": "Microsoft.CostManagement/query",
"id": "/providers/Microsoft.CostManagement/externalSubscriptions/100/query/d99477af-7510-40ee-aca2-e59bdca0d10d",
"properties": {
"columns": [
{
"name": "PreTaxCost",
"type": "Number"
},
{
"name": "UsageDate",
"type": "Number"
},
{
"name": "Currency",
"type": "String"
}
],
"nextLink": null,
"rows": []
}
}
定義
| 名稱 | Description |
|---|---|
|
Error |
錯誤的詳細數據。 |
|
Error |
錯誤回應表示服務無法處理傳入要求。 錯誤訊息中會提供原因。 \n\n一些錯誤回應:\n\n * 429 TooManyRequests - 請求被限速。 等候 「x-ms-ratelimit-microsoft.consumption-retry-after」 標頭中指定的時間後重試。 \n\n * 503 服務不可用 - 服務暫時無法使用。 等候 「Retry-After」 標頭中指定的時間後重試。 |
|
Export |
匯出的類型。 請注意,『Usage』 相當於 『ActualCost』,而且適用於尚未提供服務保留費用或攤銷數據的導出。 |
|
External |
|
|
Function |
要使用的聚合函數名稱。 |
|
Granularity |
匯出中的數據列粒度。 大部分情況下目前支援「每日」。 |
|
Query |
要用於查詢的匯總表達式。 |
|
Query |
QueryColumn 屬性 |
|
Query |
報告中欄位的類型。 |
|
Query |
要在查詢中使用的比較表達式。 |
|
Query |
查詢中存在的數據定義。 |
|
Query |
查詢中數據集的組態。 |
|
Query |
查詢的定義。 |
|
Query |
要用於導出的篩選表達式。 |
|
Query |
要用於查詢中的依表示式分組。 |
|
Query |
要用於比較的運算符。 |
|
Query |
查詢的結果。 它包含群組和匯總下所列的所有數據行。 |
|
Query |
用於提取查詢數據的開始和結束日期。 |
|
Timeframe |
提取匯出數據的時間範圍。 如果為 custom,則必須提供特定的時間週期。 |
ErrorDetails
錯誤的詳細數據。
| 名稱 | 類型 | Description |
|---|---|---|
| code |
string |
錯誤碼。 |
| message |
string |
錯誤訊息,指出作業失敗的原因。 |
ErrorResponse
錯誤回應表示服務無法處理傳入要求。 錯誤訊息中會提供原因。 \n\n一些錯誤回應:\n\n * 429 TooManyRequests - 請求被限速。 等候 「x-ms-ratelimit-microsoft.consumption-retry-after」 標頭中指定的時間後重試。 \n\n * 503 服務不可用 - 服務暫時無法使用。 等候 「Retry-After」 標頭中指定的時間後重試。
| 名稱 | 類型 | Description |
|---|---|---|
| error |
錯誤的詳細數據。 |
ExportType
匯出的類型。 請注意,『Usage』 相當於 『ActualCost』,而且適用於尚未提供服務保留費用或攤銷數據的導出。
| 值 | Description |
|---|---|
| Usage | |
| ActualCost | |
| AmortizedCost | |
| FocusCost | |
| PriceSheet | |
| ReservationTransactions | |
| ReservationRecommendations | |
| ReservationDetails |
ExternalCloudProviderType
| 值 | Description |
|---|---|
| externalSubscriptions | |
| externalBillingAccounts |
FunctionType
要使用的聚合函數名稱。
| 值 | Description |
|---|---|
| Sum |
GranularityType
匯出中的數據列粒度。 大部分情況下目前支援「每日」。
| 值 | Description |
|---|---|
| Daily | |
| Monthly |
QueryAggregation
要用於查詢的匯總表達式。
| 名稱 | 類型 | Description |
|---|---|---|
| function |
要使用的聚合函數名稱。 |
|
| name |
string |
要匯總的數據行名稱。 |
QueryColumn
QueryColumn 屬性
| 名稱 | 類型 | Description |
|---|---|---|
| name |
string |
數據行的名稱。 |
| type |
string |
數據行的類型。 |
QueryColumnType
報告中欄位的類型。
| 值 | Description |
|---|---|
| TagKey |
與成本數據相關聯的標記。 |
| Dimension |
成本數據的維度。 |
QueryComparisonExpression
要在查詢中使用的比較表達式。
| 名稱 | 類型 | Description |
|---|---|---|
| name |
string |
要用於比較的數據行名稱。 |
| operator |
要用於比較的運算符。 |
|
| values |
string[] |
要用於比較的值陣列 |
QueryDataset
查詢中存在的數據定義。
| 名稱 | 類型 | Description |
|---|---|---|
| aggregation |
<string,
Query |
要用於查詢的匯總表示式字典。 字典中每個專案的索引鍵是匯總數據行的別名。 Query 最多可以有 2 個聚合子句。 |
| configuration |
具有匯出中數據的組態資訊。 如果提供匯總和群組,將會忽略組態。 |
|
| filter |
要在查詢中使用的篩選條件表達式。 請參閱我們的查詢 API REST 文件,瞭解如何正確設置篩檢程式的格式。 |
|
| granularity |
查詢中數據列的數據粒度。 |
|
| grouping |
要用於查詢的依表示式分組陣列。 Query 最多可以有 2 個 group 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 |
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 (date-time) |
要從中提取數據的開始日期。 |
| to |
string (date-time) |
要提取數據的結束日期。 |
TimeframeType
提取匯出數據的時間範圍。 如果為 custom,則必須提供特定的時間週期。
| 值 | Description |
|---|---|
| MonthToDate | |
| BillingMonthToDate | |
| TheLastMonth | |
| TheLastBillingMonth | |
| WeekToDate | |
| Custom | |
| TheCurrentMonth |