Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.82k forks source link

Invoke-AzCostManagementQuery fails when DatasetFilter is based on tags #22326

Open dohughes-msft opened 1 year ago

dohughes-msft commented 1 year ago

Description

Cmdlet Invoke-AzCostManagementQuery can be invoked with parameter -DatasetFilter to filter the data returned. Besides logical operators And/Or/Not, the filter options are Dimensions or Tag. Filtering on a dimension is successful but filter on a tag fails.

When invoking the API directly via PowerShell both types of filtering work, leading me to conclude that there is a bug in PowerShell module Az.CostManagement.

Issue script & Debug output

PS> $DebugPreference = 'Continue'
PS> $tagName = "team"
PS> $tagValues = @("team1")
PS> $startDate = (Get-Date).AddMonths(-6).ToString("yyyy-MM-01")
PS> $endDate = (Get-Date).AddDays(-1 * (Get-Date).Day).ToString("yyyy-MM-dd")
PS> $timeframe = "Custom"
PS> $granularity = "Monthly"
PS> $type = "AmortizedCost"
PS> $scope = "/subscriptions/f3bd1cf9-6b3f-4fda-b3f9-83e9467674cf"
PS> $grouping = @(
>>     @{
>>         type = "Dimension"
>>         name = "ResourceId"
>>     }
>> )
PS> $aggregation = @{
>>     PreTaxCost = @{
>>         function = "Sum"
>>         name = "PreTaxCost"
>>     }
>> }
PS> $azContext = Get-AzContext
DEBUG: 13:10:39 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 13:10:39 - GetAzureRMContextCommand end processing.
PS> $azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
PS> $profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)
PS> $token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId)
DEBUG: 13:10:39 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
PS> $authHeader = @{
>>    'Content-Type'='application/json'
>>    'Authorization'='Bearer ' + $token.AccessToken
>> }
PS>
PS> $tags = New-AzCostManagementQueryComparisonExpressionObject -Name $tagName -Value $tagValues -Operator 'In'
DEBUG: AzureQoSEvent:  Module: Az.CostManagement:0.3.1; CommandName: New-AzCostManagementQueryComparisonExpressionObject; PSVersion: 7.2.12; IsSuccess: True; Duration: 00:00:00.0019289
PS> $filter = New-AzCostManagementQueryFilterObject -Tag $tags
DEBUG: AzureQoSEvent:  Module: Az.CostManagement:0.3.1; CommandName: New-AzCostManagementQueryFilterObject; PSVersion: 7.2.12; IsSuccess: True; Duration: 00:00:00.0003948
PS>
PS> $queryResult = Invoke-AzCostManagementQuery `
>>     -Scope $scope `
>>     -Timeframe $timeframe `
>>     -Type $type `
>>     -DatasetFilter $filter `
>>     -TimePeriodFrom $startDate `
>>     -TimePeriodTo $endDate `
>>     -DatasetGrouping $grouping `
>>     -DatasetAggregation $aggregation `
>>     -DatasetGranularity $granularity `
>>     -Debug
DEBUG: 13:10:39 - InvokeAzRestMethodCommand begin processing with ParameterSet 'ByPath'.
DEBUG: 13:10:39 - using account id 'dohughes@microsoft.com'...
DEBUG: 13:10:39 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: 'dohughes@microsoft.com', environment: 'AzureCloud', tenant: '16b3c013-d300-468d-ac64-7eda0820b6d3'
DEBUG: 13:10:39 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 13:10:39 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'16b3c013-d300-468d-ac64-7eda0820b6d3', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'dohughes@microsoft.com'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78ad40db-d1c7-45b3-9b4b-5d6b017cbdc1] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78ad40db-d1c7-45b3-9b4b-5d6b017cbdc1] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78ad40db-d1c7-45b3-9b4b-5d6b017cbdc1] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78ad40db-d1c7-45b3-9b4b-5d6b017cbdc1] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78ad40db-d1c7-45b3-9b4b-5d6b017cbdc1] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z] Found 1 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z] Returning 1 accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] MSAL MSAL.NetCore with assembly version '4.49.1.0'. CorrelationId(78cc8ae2-61b2-48a4-982e-617277d10aa7)
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] LoginHint provided: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] Account provided: True
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] ForceRefresh: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 78cc8ae2-61b2-48a4-982e-617277d10aa7
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:

DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] === Token Acquisition (SilentRequest) started:
         Scopes: https://management.core.windows.net//.default
        Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] Access token is not expired. Returning the found cache entry. [Current time (07/14/2023 11:10:39) - Expiration Time (07/14/2023 11:21:36 +00:00) - Extended Expiration Time (07/14/2023 11:21:36 +00:00)]
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] Returning access token found in cache. RefreshOn exists ? False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7]
        === Token Acquisition finished successfully:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.19 Microsoft Windows 10.0.22621 [2023-07-14 11:10:39Z - 78cc8ae2-61b2-48a4-982e-617277d10aa7]  AT expiration time: 2023-07-14 11:21:36 +00:00, scopes: https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default. source: Cache
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:  ExpiresOn: 2023-07-14T11:21:36.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '16b3c013-d300-468d-ac64-7eda0820b6d3', UserId: 'dohughes@microsoft.com'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
POST

Absolute Uri:
https://management.azure.com/subscriptions/f3bd1cf9-6b3f-4fda-b3f9-83e9467674cf/providers/Microsoft.CostManagement/query?api-version=2019-11-01

Headers:
x-ms-client-request-id        : ca7f983c-2dde-4d40-a138-04434c8fa46b
Accept-Language               : en-US

Body:
{
  "timePeriod": {
    "from": "2023-01-01T00:00:00",
    "to": "2023-06-30T00:00:00"
  },
  "dataset": {
    "granularity": "Monthly",
    "aggregation": {
      "PreTaxCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceId"
      }
    ],
    "filter": {
      "tag": {
        "name": "team",
        "operator": "In",
        "values": [
          "team1"
        ]
      }
    }
  },
  "type": "AmortizedCost",
  "timeframe": "Custom"
}

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

Status Code:
BadRequest

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
session-id                    : 08c20a63-024d-48ff-92a0-3487f7386f02
x-ms-request-id               : fd1a6d8e-4ac9-42e2-bcf3-be48a5d22156
x-ms-correlation-request-id   : d0abdcb5-a35e-496a-9d06-793122ac660a
x-ms-client-request-id        : ca7f983c-2dde-4d40-a138-04434c8fa46b
X-Powered-By                  : ASP.NET
x-ms-ratelimit-remaining-subscription-resource-requests: 99
x-ms-routing-request-id       : SWEDENCENTRAL:20230714T111140Z:d0abdcb5-a35e-496a-9d06-793122ac660a
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Date                          : Fri, 14 Jul 2023 11:11:39 GMT

Body:
{
  "error": {
    "code": "BadRequest",
    "message": "Invalid query definition: Invalid dataset filter; on a QueryFilter one and only one of and/or/not/dimension/tag can be set.\r\n\r\n (Request ID: fd1a6d8e-4ac9-42e2-bcf3-be48a5d22156)"
  }
}

DEBUG: 13:10:41 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 13:10:41 - InvokeAzRestMethodCommand end processing.
DEBUG: AzureQoSEvent:  Module: Az.CostManagement:0.3.1; CommandName: Invoke-AzCostManagementQuery; PSVersion: 7.2.12; IsSuccess: True; Duration: 00:00:01.6746242
PS>

Environment data

PS> $PSVersionTable

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

Module versions

PS> Get-Module Az*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.12.4                Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte…
Script     0.3.1                 Az.CostManagement                   {Get-AzCostManagementExport, Get-AzCostManagement…

Error output

PS> Resolve-AzError
DEBUG: 13:12:39 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 13:12:39 - using account id 'dohughes@microsoft.com'...
DEBUG: 13:12:39 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].

   HistoryId: -1

Message        : 'Operator' is a ReadOnly property.
StackTrace     :    at CallSite.Target(Closure , CallSite , Object , Object )
                    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
                    at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.RuntimeException
InvocationInfo : {}
Line           : $filter.Dimensions.Operator = $null
Position       : At line:1 char:1
                 + $filter.Dimensions.Operator = $null
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : -1

Message        : 'Operator' is a ReadOnly property.
StackTrace     :
Exception      : System.Management.Automation.SetValueException
InvocationInfo : {}
Line           : $filter.Dimensions.Operator = $null
Position       : At line:1 char:1
                 + $filter.Dimensions.Operator = $null
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : -1

   HistoryId: 49

Message        : Cannot process argument transformation on parameter 'Dimensions'. Cannot convert the "" value of type "System.String" to type "Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20211001.IQueryComparisonExpression".
StackTrace     :    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindNamedParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter)
                    at System.Management.Automation.ParameterBinderController.BindNamedParameters(UInt32 parameterSets, Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location ---
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections,
                 FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParameterBindingArgumentTransformationException
InvocationInfo : {New-AzCostManagementQueryFilterObject}
Line           : $filter = New-AzCostManagementQueryFilterObject -Tag $tags -Dimensions ""
Position       : At line:1 char:72
                 + … ter = New-AzCostManagementQueryFilterObject -Tag $tags -Dimensions ""
                 +                                                                      ~~
HistoryId      : 49

Message        : Cannot convert the "" value of type "System.String" to type "Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20211001.IQueryComparisonExpression".
StackTrace     :    at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet)
                    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
Exception      : System.Management.Automation.ArgumentTransformationMetadataException
InvocationInfo : {New-AzCostManagementQueryFilterObject}
Line           : $filter = New-AzCostManagementQueryFilterObject -Tag $tags -Dimensions ""
Position       : At line:1 char:72
                 + … ter = New-AzCostManagementQueryFilterObject -Tag $tags -Dimensions ""
                 +                                                                      ~~
HistoryId      : 49

Message        : Cannot convert the "" value of type "System.String" to type "Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20211001.IQueryComparisonExpression".
StackTrace     :    at System.Management.Automation.LanguagePrimitives.ConvertCheckingForCustomConverter.Convert(Object valueToConvert, Type resultType, Boolean recursion, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable
                 backupTable)
                    at System.Management.Automation.LanguagePrimitives.ConversionData`1.Invoke(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
                    at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, Boolean recursion, IFormatProvider formatProvider, TypeTable backupTypeTable)
                    at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet)
Exception      : System.Management.Automation.PSInvalidCastException
InvocationInfo : {New-AzCostManagementQueryFilterObject}
Line           : $filter = New-AzCostManagementQueryFilterObject -Tag $tags -Dimensions ""
Position       : At line:1 char:72
                 + … ter = New-AzCostManagementQueryFilterObject -Tag $tags -Dimensions ""
                 +                                                                      ~~
HistoryId      : 49

   HistoryId: 24

Message        : The term 'team' is not recognized as a name of a cmdlet, function, script file, or executable program.
                 Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
StackTrace     :    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
                    at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
                    at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections,
                 FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.CommandNotFoundException
InvocationInfo : {}
Line           : $tagName = team
Position       : At line:1 char:12
                 + $tagName = team
                 +            ~~~~
HistoryId      : 24

   HistoryId: 19

Message        : Response status code does not indicate success: 401 (Unauthorized).
StackTrace     :    at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
Exception      : Microsoft.PowerShell.Commands.HttpResponseException
InvocationInfo : {Invoke-RestMethod}
Line           : $queryResult = Invoke-RestMethod -Uri $uri -Method Post -Headers $authHeader -Body $body

Position       : At\get_cost_history_api_tag.ps1:160 char:16
                 + … eryResult = Invoke-RestMethod -Uri $uri -Method Post -Headers $authHe …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 19

   HistoryId: 17

Message        : Cannot validate argument on parameter 'Uri'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
StackTrace     :    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindNamedParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter)
                    at System.Management.Automation.ParameterBinderController.BindNamedParameters(UInt32 parameterSets, Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location ---
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections,
                 FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParameterBindingValidationException
InvocationInfo : {Invoke-RestMethod}
Line           : $queryResult = Invoke-RestMethod -Uri $uri -Method Post -Headers $authHeader -Body $body

Position       : At\get_cost_history_tag.ps1:149 char:39
                 + $queryResult = Invoke-RestMethod -Uri $uri -Method Post -Headers $aut …
                 +                                       ~~~~
HistoryId      : 17

Message        : The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
StackTrace     :    at System.Management.Automation.ValidateNotNullOrEmptyAttribute.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
                    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
Exception      : System.Management.Automation.ValidationMetadataException
InvocationInfo : {Invoke-RestMethod}
Line           : $queryResult = Invoke-RestMethod -Uri $uri -Method Post -Headers $authHeader -Body $body

Position       : At\get_cost_history_tag.ps1:149 char:39
                 + $queryResult = Invoke-RestMethod -Uri $uri -Method Post -Headers $aut …
                 +                                       ~~~~
HistoryId      : 17

DEBUG: 13:12:40 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent:  Module: Az.Accounts:2.12.4; CommandName: Resolve-AzError; PSVersion: 7.2.12; IsSuccess: True; Duration: 00:00:00.1046671
DEBUG: 13:12:40 - [ConfigManager] Got [True] from [EnableDataCollection], Module = [], Cmdlet = [].
DEBUG: 13:12:40 - ResolveError end processing.
isra-fel commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ccmaxpcrew