Skip to content

Get-AzConsumptionUsageDetail does not honor 'Tag' parameter #8971

@Oechiih

Description

@Oechiih

Description

Related #8876

When using Get-AzConsumptionUsageDetail with the 'Tag' parameter it is still returning all resources. According to documentation the parameter should be a string value. Digging a little deeper, into the REST API documentation I found out it should be a simple key-value pair separated by a colon i.e. 'key:value'. In the source code of Get-AzConsumptionUsageDetail on line 167 I noted how it handled my input. However the API completely ignores my filter and just returns all my resources instead. As we can see the PS module prepares the request with the filter 'properties/tags eq ' however the API example is using just 'tags'. I tried both variations in Postman and got mixed results:

filter result
tags eq 'dev:tool' Empty array
tags eq ' Array containing all resources
properties/tags eq 'dev:tool' Array containing all resources
properties/tags eq ' Array containing all resources
  • Which is the correct property name declaration? 'properties/tags' or just 'tags'
  • Is 'Key:Value' the correct format ?
  • I think it should return no resources if the filter does not match any.

Steps to reproduce

Get-AzConsumptionUsageDetail -Tag 'dev:tool'

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.0
PSEdition                      Core
GitCommitId                    6.2.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Script     1.4.0      Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDa…
Script     1.3.1      Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDa…
Script     1.2.1      Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDa…
Script     1.0.1      Az.Aks                              Core,Desk {Get-AzAks, New-AzAks, Remove-AzAks, Import-AzAksCredential…}
Script     1.0.2      Az.AnalysisServices                 Core,Desk {Resume-AzAnalysisServicesServer, Suspend-AzAnalysisServicesServe…
Script     1.0.1      Az.AnalysisServices                 Core,Desk {Resume-AzAnalysisServicesServer, Suspend-AzAnalysisServicesServe…
Script     1.0.0      Az.ApiManagement                    Core,Desk {Add-AzApiManagementRegion, Get-AzApiManagementSsoToken, New-AzAp…
Script     1.0.0      Az.ApplicationInsights              Core,Desk {Get-AzApplicationInsights, New-AzApplicationInsights, Remove-AzA…
Script     1.2.0      Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHybridWork…
Script     1.1.2      Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHybridWork…
Script     1.1.1      Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHybridWork…
Script     1.1.0      Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHybridWork…
Script     1.0.0      Az.Batch                            Core,Desk {Remove-AzBatchAccount, Get-AzBatchAccount, Get-AzBatchAccountKey…
Script     1.0.0      Az.Billing                          Core,Desk {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-AzEnrollmentAccou…
Script     0.1.0      Az.Blueprint                        Core,Desk {Get-AzBlueprint, Get-AzBlueprintAssignment, New-AzBlueprintAssig…
Script     1.1.0      Az.Cdn                              Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzCdnProfile, Remo…
Script     1.0.1      Az.Cdn                              Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzCdnProfile, Remo…
Script     1.0.1      Az.CognitiveServices                Core,Desk {Get-AzCognitiveServicesAccount, Get-AzCognitiveServicesAccountKe…
Script     1.0.0      Az.CognitiveServices                Core,Desk {Get-AzCognitiveServicesAccount, Get-AzCognitiveServicesAccountKe…
Script     1.6.0      Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAvailabil…
Script     1.5.0      Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAvailabil…
Script     1.4.0      Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAvailabil…
Script     1.2.0      Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAvailabil…
Script     1.0.0      Az.ContainerInstance                Core,Desk {New-AzContainerGroup, Get-AzContainerGroup, Remove-AzContainerGr…
Script     1.0.1      Az.ContainerRegistry                Core,Desk {New-AzContainerRegistry, Get-AzContainerRegistry, Update-AzConta…
Script     1.0.2      Az.DataFactory                      Core,Desk {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-AzDataFactoryV2…
Script     1.0.1      Az.DataFactory                      Core,Desk {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-AzDataFactoryV2…
Script     1.0.0      Az.DataLakeAnalytics                Core,Desk {Get-AzDataLakeAnalyticsDataSource, New-AzDataLakeAnalyticsCatalo…
Script     1.1.0      Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDataLakeStoreTrus…
Script     1.0.2      Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDataLakeStoreTrus…
Script     1.0.0      Az.DevTestLabs                      Core,Desk {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolicy, Get-…
Script     1.0.0      Az.Dns                              Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove-AzDnsRecordSet…
Script     1.1.0      Az.EventGrid                        Core,Desk {New-AzEventGridTopic, Get-AzEventGridTopic, Set-AzEventGridTopic…
Script     1.0.1      Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzEventHub…
Script     1.0.0      Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzEventHub…
Script     1.0.0      Az.HDInsight                        Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefinition, Wait-AzHD…
Script     1.0.2      Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGroup, Get-AzIotHub…
Script     1.1.0      Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, Stop-Az…
Script     1.0.2      Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, Stop-Az…
Script     1.0.1      Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, Stop-Az…
Script     1.2.1      Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get-AzIntegrationAccountAssem…
Script     1.2.0      Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get-AzIntegrationAccountAssem…
Script     1.1.0      Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get-AzIntegrationAccountCallb…
Script     1.0.0      Az.MachineLearning                  Core,Desk {Move-AzMlCommitmentAssociation, Get-AzMlCommitmentAssociation, G…
Script     1.0.0      Az.MarketplaceOrdering              Core,Desk {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script     1.0.0      Az.Media                            Core,Desk {Sync-AzMediaServiceStorageKeys, Set-AzMediaServiceKey, Get-AzMed…
Script     1.0.1      Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile, Get-A…
Script     1.0.0      Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile, Get-A…
Script     1.6.0      Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzApplica…
Script     1.3.0      Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzApplica…
Script     1.2.1      Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzApplica…
Script     1.1.0      Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzApplica…
Script     1.0.0      Az.NotificationHubs                 Core,Desk {Get-AzNotificationHub, Get-AzNotificationHubAuthorizationRules, …
Script     1.1.0      Az.OperationalInsights              Core,Desk {New-AzOperationalInsightsAzureActivityLogDataSource, New-AzOpera…
Script     1.0.0      Az.OperationalInsights              Core,Desk {New-AzOperationalInsightsAzureActivityLogDataSource, New-AzOpera…
Script     1.0.0      Az.PolicyInsights                   Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPolicyStateSummary, …
Script     1.0.0      Az.PowerBIEmbedded                  Core,Desk {Remove-AzPowerBIWorkspaceCollection, Get-AzPowerBIWorkspaceColle…
Script     1.2.0      Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, Get-AzRecoveryServicesVaul…
Script     1.1.0      Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, Get-AzRecoveryServicesVaul…
Script     1.0.1      Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, Get-AzRecoveryServicesVaul…
Script     1.0.0      Az.RedisCache                       Core,Desk {Remove-AzRedisCachePatchSchedule, New-AzRedisCacheScheduleEntry,…
Script     1.0.0      Az.Relay                            Core,Desk {New-AzRelayNamespace, Get-AzRelayNamespace, Set-AzRelayNamespace…
Script     1.2.1      Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssi…
Script     1.2.0      Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssi…
Script     1.1.3      Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssi…
Script     1.1.1      Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssi…
Script     1.0.0      Az.ServiceBus                       Core,Desk {New-AzServiceBusNamespace, Get-AzServiceBusNamespace, Set-AzServ…
Script     1.0.1      Az.ServiceFabric                    Core,Desk {Add-AzServiceFabricApplicationCertificate, Add-AzServiceFabricCl…
Script     1.0.2      Az.SignalR                          Core,Desk {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey, New-AzSignalRKey…
Script     1.7.0      Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatabaseTra…
Script     1.5.0      Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatabaseTra…
Script     1.4.0      Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatabaseTra…
Script     1.3.0      Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatabaseTra…
Script     1.1.0      Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatabaseTra…
Script     1.1.0      Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStorageAcco…
Script     1.0.3      Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStorageAcco…
Script     1.0.2      Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStorageAcco…
Script     1.0.0      Az.StreamAnalytics                  Core,Desk {Get-AzStreamAnalyticsFunction, Get-AzStreamAnalyticsDefaultFunct…
Script     1.0.1      Az.TrafficManager                   Core,Desk {Add-AzTrafficManagerCustomHeaderToEndpoint, Remove-AzTrafficMana…
Script     1.1.2      Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServicePlan…
Script     1.1.1      Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServicePlan…
Script     1.1.0      Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServicePlan…

Debug output

DEBUG: 13:59:46 - GetAzureRmConsumptionUsageDetail begin processing with ParameterSet 'Subscription'.
DEBUG: 13:59:46 - using account id 
DEBUG: [Common.Authentication]: Authenticating using Account: , environment: 'AzureCloud', tenant: 
DEBUG: [ADAL]: Information: 2019-04-09T11:59:46.8283648Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: ADAL PCL.CoreCLR with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is running...

DEBUG: [ADAL]: Information: 2019-04-09T11:59:46.8307993Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: === Token Acquisition started:
        CacheType: null
        Authentication Target: User
        , Authority Host: login.microsoftonline.com

DEBUG: [ADAL]: Verbose: 2019-04-09T11:59:46.8327445Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: Loading from cache.

DEBUG: [ADAL]: Information: 2019-04-09T11:59:46.8341396Z: 00000000-0000-0000-0000-000000000000 - LoggerBase.cs: Deserialized 3 items to token cache.

DEBUG: [ADAL]: Verbose: 2019-04-09T11:59:46.8347726Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: Looking up cache for a token...

DEBUG: [ADAL]: Information: 2019-04-09T11:59:46.8352557Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: An item matching the requested resource was found in the cache

DEBUG: [ADAL]: Information: 2019-04-09T11:59:46.8357250Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: An expired or near expiry token was found in the cache

DEBUG: [ADAL]: Information: 2019-04-09T11:59:46.8361758Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache

DEBUG: [ADAL]: Verbose: 2019-04-09T11:59:46.8366912Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: Refreshing access token...

DEBUG: [ADAL]: Verbose: 2019-04-09T11:59:47.0942602Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: Storing token in the cache...

DEBUG: [ADAL]: Verbose: 2019-04-09T11:59:47.0955651Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: An item was stored in the cache

DEBUG: [ADAL]: Information: 2019-04-09T11:59:47.0966466Z: 641b5c3f-2f56-4cc9-a231-5490cf7ab57c - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 09/04/2019 12:59:47 +00:00

DEBUG: [ADAL]: Information: 2019-04-09T11:59:47.0974112Z: 00000000-0000-0000-0000-000000000000 - LoggerBase.cs: Serializing token cache with 3 items.

DEBUG: [ADAL]: Information: 2019-04-09T11:59:47.1025804Z: 34dab5d9-eee3-4c63-b536-173555fb91ba - LoggerBase.cs: ADAL PCL.CoreCLR with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is running...

DEBUG: [ADAL]: Information: 2019-04-09T11:59:47.1038365Z: 34dab5d9-eee3-4c63-b536-173555fb91ba - LoggerBase.cs: === Token Acquisition started:
        CacheType: null
        Authentication Target: User
        , Authority Host: login.microsoftonline.com

DEBUG: [ADAL]: Verbose: 2019-04-09T11:59:47.1047263Z: 34dab5d9-eee3-4c63-b536-173555fb91ba - LoggerBase.cs: Loading from cache.

DEBUG: [ADAL]: Information: 2019-04-09T11:59:47.1055161Z: 00000000-0000-0000-0000-000000000000 - LoggerBase.cs: Deserialized 3 items to token cache.

DEBUG: [ADAL]: Verbose: 2019-04-09T11:59:47.1060366Z: 34dab5d9-eee3-4c63-b536-173555fb91ba - LoggerBase.cs: Looking up cache for a token...

DEBUG: [ADAL]: Information: 2019-04-09T11:59:47.1065051Z: 34dab5d9-eee3-4c63-b536-173555fb91ba - LoggerBase.cs: An item matching the requested resource was found in the cache

DEBUG: [ADAL]: Information: 2019-04-09T11:59:47.1070403Z: 34dab5d9-eee3-4c63-b536-173555fb91ba - LoggerBase.cs: 59,9997827283333 minutes left until token in cache expires

DEBUG: [ADAL]: Information: 2019-04-09T11:59:47.1074978Z: 34dab5d9-eee3-4c63-b536-173555fb91ba - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache

DEBUG: [ADAL]: Information: 2019-04-09T11:59:47.1080910Z: 34dab5d9-eee3-4c63-b536-173555fb91ba - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 09/04/2019 12:59:47 +00:00

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/<my subscription>/providers/Microsoft.Consumption/usageDetails?$filter=properties%2Ftags eq %27dev%3Atool%27&$top=1000&api-version=2018-01-31

Headers:
x-ms-client-request-id        : a273ab3b-c347-4e12-af87-e651bfafca58
Accept-Language               : en-US

Body:



DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
session-id                    : 2315be1b-e72b-46d9-bf01-22b7d9cdcd41
x-ms-request-id               : c8556bc8-4b09-4ac3-aec5-ebbe8744a568
x-ms-correlation-request-id   : badf3b40-45c3-4ad9-8bd9-cf62a16f0ff6
x-ms-client-request-id        : 367e9115-fb9d-412c-98d1-0a8de405bbb3
OData-Version                 : 4.0
Access-Control-Allow-Origin   : *
X-Content-Type-Options        : nosniff
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-routing-request-id       : UKSOUTH:20190409T115952Z:badf3b40-45c3-4ad9-8bd9-cf62a16f0ff6
Date                          : Tue, 09 Apr 2019 11:59:51 GMT

Body:
{
  "value": [
    {
<Many resources>
    }
  ]
}



DEBUG: AzureQoSEvent: CommandName - Get-AzConsumptionUsageDetail; IsSuccess - True; Duration - 00:00:09.8367261; Exception - ;
DEBUG: Finish sending metric.
DEBUG: 13:59:56 - GetAzureRmConsumptionUsageDetail end processing.
DEBUG: 13:59:56 - GetAzureRmConsumptionUsageDetail end processing.

Error output

No error only unexpected results.

Metadata

Metadata

Assignees

Labels

Consumption - UsageDetailsAndExportAll issues in cost management and Consumption for usage details api and exportService AttentionThis issue is responsible by Azure service team.customer-reportedfeature-requestThis issue requires a new behavior in the product in order be resolved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions