Editar

Compartilhar via


Invoke-AzCostManagementQuery

Query the usage data for scope defined.

Syntax

Invoke-AzCostManagementQuery
      -Scope <String>
      -Timeframe <TimeframeType>
      -Type <ExportType>
      [-ConfigurationColumn <String[]>]
      [-DatasetAggregation <Hashtable>]
      [-DatasetFilter <IQueryFilter>]
      [-DatasetGranularity <GranularityType>]
      [-DatasetGrouping <IQueryGrouping[]>]
      [-TimePeriodFrom <DateTime>]
      [-TimePeriodTo <DateTime>]
      [-DefaultProfile <PSObject>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Invoke-AzCostManagementQuery
      -ExternalCloudProviderId <String>
      -ExternalCloudProviderType <ExternalCloudProviderType>
      -Timeframe <TimeframeType>
      -Type <ExportType>
      [-ConfigurationColumn <String[]>]
      [-DatasetAggregation <Hashtable>]
      [-DatasetFilter <IQueryFilter>]
      [-DatasetGranularity <GranularityType>]
      [-DatasetGrouping <IQueryGrouping[]>]
      [-TimePeriodFrom <DateTime>]
      [-TimePeriodTo <DateTime>]
      [-DefaultProfile <PSObject>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

Query the usage data for scope defined.

Examples

Example 1: Invoke AzCostManagementQuery by Scope

Invoke-AzCostManagementQuery -Scope "/subscriptions/***********" -Timeframe MonthToDate -Type Usage -DatasetGranularity 'Daily'

Column                Row
------                ---
{UsageDate, Currency} {20201101 USD, 20201102 USD, 20201103 USD, 20201104 USD…}

Invoke AzCostManagementQuery by Scope

Example 2: Invoke AzCostManagementQuery by Scope with Dimensions

$dimensions = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Value 'API'
$filter = New-AzCostManagementQueryFilterObject -Dimensions $dimensions
Invoke-AzCostManagementQuery -Type Usage -Scope "subscriptions/***********" -DatasetGranularity 'Monthly' -DatasetFilter $filter -Timeframe MonthToDate -Debug

Column                   Row
------                   ---
{BillingMonth, Currency} {}

Invoke AzCostManagementQuery by Scope with Dimensions

Parameters

-ConfigurationColumn

Array of column names to be included in the query.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DatasetAggregation

Dictionary of aggregation expression to use in the query.

Type:Hashtable
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DatasetFilter

Has filter expression to use in the query. To construct, see NOTES section for DATASETFILTER properties and create a hash table.

Type:IQueryFilter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DatasetGranularity

The granularity of rows in the query.

Type:GranularityType
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DatasetGrouping

Array of group by expression to use in the query. To construct, see NOTES section for DATASETGROUPING properties and create a hash table.

Type:IQueryGrouping[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:PSObject
Aliases:AzureRMContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ExternalCloudProviderId

This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ExternalCloudProviderType

The external cloud provider type associated with dimension/query operations.

Type:ExternalCloudProviderType
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Scope

This includes 'subscriptions/{subscriptionId}/' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '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.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Timeframe

The time frame for pulling data for the query.

Type:TimeframeType
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-TimePeriodFrom

The start date to pull data from.

Type:DateTime
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-TimePeriodTo

The end date to pull data to.

Type:DateTime
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Type

The type of the query.

Type:ExportType
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Outputs

IQueryResult