Query - Usage By External Cloud Provider Type
Query the usage data for external cloud provider type defined.
POST https://management.azure.com/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query?api-version=2023-11-01
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
external
|
path | True |
string |
This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. |
external
|
path | True |
The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. |
|
api-version
|
query | True |
string |
The API version to use for this operation. |
Request Body
Name | Required | Type | Description |
---|---|---|---|
dataset | True |
Has definition for data in this query. |
|
timeframe | True |
The time frame for pulling data for the query. If custom, then a specific time period must be provided. |
|
type | True |
The type of the query. |
|
timePeriod |
Has time period for pulling data for the query. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
OK. The request has succeeded. |
|
Other Status Codes |
Error response describing why the operation failed. |
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name | Description |
---|---|
user_impersonation | impersonate your user account |
Examples
External |
External |
ExternalBillingAccountQueryList
Sample Request
POST https://management.azure.com/providers/Microsoft.CostManagement/externalBillingAccounts/100/query?api-version=2023-11-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.CostManagement/externalBillingAccounts/100/query/6dc7b06a-d90a-4df5-b655-ce6cf1c0814d",
"name": "6dc7b06a-d90a-4df5-b655-ce6cf1c0814d",
"type": "Microsoft.CostManagement/query",
"properties": {
"nextLink": null,
"columns": [
{
"name": "PreTaxCost",
"type": "Number"
},
{
"name": "ServiceName",
"type": "String"
},
{
"name": "Currency",
"type": "String"
}
],
"rows": [
[
0,
"abc db",
"USD"
],
[
30.2572751438,
"abc compute cloud",
"USD"
],
[
0.07675760200000002,
"abc file system",
"USD"
],
[
50.43096419040001,
"abc elasticache",
"USD"
]
]
}
}
ExternalSubscriptionsQuery
Sample Request
POST https://management.azure.com/providers/Microsoft.CostManagement/externalSubscriptions/100/query?api-version=2023-11-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.CostManagement/externalSubscriptions/100/query/d99477af-7510-40ee-aca2-e59bdca0d10d",
"name": "d99477af-7510-40ee-aca2-e59bdca0d10d",
"type": "Microsoft.CostManagement/query",
"properties": {
"nextLink": null,
"columns": [
{
"name": "PreTaxCost",
"type": "Number"
},
{
"name": "UsageDate",
"type": "Number"
},
{
"name": "Currency",
"type": "String"
}
],
"rows": []
}
}
Definitions
Name | Description |
---|---|
Error |
The details of the error. |
Error |
Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. Some Error responses:
|
Export |
The type of the query. |
external |
The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. |
Function |
The name of the aggregation function to use. |
Granularity |
The granularity of rows in the forecast. |
Query |
The aggregation expression to be used in the query. |
Query |
QueryColumn properties |
Query |
The type of the column in the export. |
Query |
The comparison expression to be used in the query. |
Query |
The definition of data present in the query. |
Query |
The configuration of dataset in the query. |
Query |
The definition of a query. |
Query |
The filter expression to be used in the export. |
Query |
The group by expression to be used in the query. |
Query |
The operator to use for comparison. |
Query |
Result of query. It contains all columns listed under groupings and aggregation. |
Query |
The start and end date for pulling data for the query. |
Timeframe |
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 | Type | Description |
---|---|---|
code |
string |
Error code. |
message |
string |
Error message indicating why the operation failed. |
ErrorResponse
Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message.
Some Error responses:
429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" header.
503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header.
Name | Type | Description |
---|---|---|
error |
The details of the error. |
ExportType
The type of the query.
Name | Type | Description |
---|---|---|
ActualCost |
string |
|
AmortizedCost |
string |
|
Usage |
string |
externalCloudProviderType
The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account.
Name | Type | Description |
---|---|---|
externalBillingAccounts |
string |
|
externalSubscriptions |
string |
FunctionType
The name of the aggregation function to use.
Name | Type | Description |
---|---|---|
Sum |
string |
GranularityType
The granularity of rows in the forecast.
Name | Type | Description |
---|---|---|
Daily |
string |
QueryAggregation
The aggregation expression to be used in the query.
Name | Type | Description |
---|---|---|
function |
The name of the aggregation function to use. |
|
name |
string |
The name of the column to aggregate. |
QueryColumn
QueryColumn properties
Name | Type | Description |
---|---|---|
name |
string |
The name of column. |
type |
string |
The type of column. |
QueryColumnType
The type of the column in the export.
Name | Type | Description |
---|---|---|
Dimension |
string |
The dimension of cost data. |
TagKey |
string |
The tag associated with the cost data. |
QueryComparisonExpression
The comparison expression to be used in the query.
Name | Type | Description |
---|---|---|
name |
string |
The name of the column to use in comparison. |
operator |
The operator to use for comparison. |
|
values |
string[] |
Array of values to use for comparison |
QueryDataset
The definition of data present in the query.
Name | Type | Description |
---|---|---|
aggregation |
<string,
Query |
Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the aggregated column. Query can have up to 2 aggregation clauses. |
configuration |
Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping are provided. |
|
filter |
The filter expression to use in the query. Please reference our Query API REST documentation for how to properly format the filter. |
|
granularity |
The granularity of rows in the query. |
|
grouping |
Array of group by expression to use in the query. Query can have up to 2 group by clauses. |
QueryDatasetConfiguration
The configuration of dataset in the query.
Name | Type | Description |
---|---|---|
columns |
string[] |
Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns. |
QueryDefinition
The definition of a query.
Name | Type | Description |
---|---|---|
dataset |
Has definition for data in this query. |
|
timePeriod |
Has time period for pulling data for the query. |
|
timeframe |
The time frame for pulling data for the query. If custom, then a specific time period must be provided. |
|
type |
The type of the query. |
QueryFilter
The filter expression to be used in the export.
Name | Type | Description |
---|---|---|
and |
The logical "AND" expression. Must have at least 2 items. |
|
dimensions |
Has comparison expression for a dimension |
|
or |
The logical "OR" expression. Must have at least 2 items. |
|
tags |
Has comparison expression for a tag |
QueryGrouping
The group by expression to be used in the query.
Name | Type | Description |
---|---|---|
name |
string |
The name of the column to group. |
type |
Has type of the column to group. |
QueryOperatorType
The operator to use for comparison.
Name | Type | Description |
---|---|---|
In |
string |
QueryResult
Result of query. It contains all columns listed under groupings and aggregation.
Name | Type | Description |
---|---|---|
eTag |
string |
ETag of the resource. |
id |
string |
Resource Id. |
location |
string |
Location of the resource. |
name |
string |
Resource name. |
properties.columns |
Array of columns |
|
properties.nextLink |
string |
The link (url) to the next page of results. |
properties.rows |
Rows[] |
Array of rows |
sku |
string |
SKU of the resource. |
tags |
object |
Resource tags. |
type |
string |
Resource type. |
QueryTimePeriod
The start and end date for pulling data for the query.
Name | Type | Description |
---|---|---|
from |
string |
The start date to pull data from. |
to |
string |
The end date to pull data to. |
TimeframeType
The time frame for pulling data for the query. If custom, then a specific time period must be provided.
Name | Type | Description |
---|---|---|
BillingMonthToDate |
string |
|
Custom |
string |
|
MonthToDate |
string |
|
TheLastBillingMonth |
string |
|
TheLastMonth |
string |
|
WeekToDate |
string |