Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.25k stars 3.85k forks source link

Api Management - Minimum version set to newer than 2021-08-01 causes the function to throw an error. #24940

Open SebastianClaesson opened 5 months ago

SebastianClaesson commented 5 months ago

Description

Running the command "Get-AzApiManagementApi" towards an API Management instance with the attribute "Minimum API Version" set to anything newer than 2021-08-01 causes the following error:

Get-AzApiManagementApi: Error Code: MissingOrIncorrectVersionParameter Error Message: API version query parameter is not specified or was specified incorrectly. Supported versions: 2022-08-01,2022-09-01-preview,2023-03-01-preview,2023-05-01-preview,2023-09-01-preview Example query param format: api-version=SupportedVersion

As the context does not allow the api-version being set and seems it defaults to the 2021-08-01 version. According to the documentation for the rest api it's required but it's unable to be set anywhere using the PowerShell module.

ref: https://learn.microsoft.com/en-us/rest/api/apimanagement/apis/get?view=rest-apimanagement-2022-08-01&tabs=HTTP

Issue script & Debug output

Select-AzSubscription 'SubscriptionId'
$apiManagementContextParams = @{
    ResourceGroupName = 'rg-apim'
    ServiceName       = 'apim'
}
$ApiManagementContext = New-AzApiManagementContext @apiManagementContextParams
Get-AzApiManagementApi -Context $ApiManagementContext
------------------------
DEBUG: 14:02:41 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 14:02:41 - GetAzureApiManagementApi begin processing with ParameterSet 'GetAllApis'.
DEBUG: 14:02:41 - using account id '<UserID>'...
DEBUG: 14:02:41 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: '<UserID>', environment: 'AzureCloud', tenant: '<TenantId>'
DEBUG: 14:02:41 - [ConfigManager] Got nothing from [DisableInstanceDiscovery], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 14:02:41 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False]. 
DEBUG: 14:02:41 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'<TenantId>', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'<UserID>'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:    
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - eb32c762-a22e-40a8-bb4a-b6adba6c1498] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - eb32c762-a22e-40a8-bb4a-b6adba6c1498] [Region discovery] Not using a regional authority. 
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - eb32c762-a22e-40a8-bb4a-b6adba6c1498] [Region discovery] Not using a regional authority. 
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - eb32c762-a22e-40a8-bb4a-b6adba6c1498] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - eb32c762-a22e-40a8-bb4a-b6adba6c1498] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z] Found 1 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z] Returning 1 accounts       
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] MSAL MSAL.CoreCLR with assembly version '4.56.0.0'. CorrelationId(c8c89652-70ff-4ed7-b654-58b05a459e3c)
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] LoginHint provided: False
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] Account provided: True
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] ForceRefresh: False
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] 
=== 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 - c8c89652-70ff-4ed7-b654-58b05a459e3c
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured: 

DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] === Token Acquisition (SilentRequest) started:
         Scopes: https://management.core.windows.net//.default
        Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] [Region discovery] Not using a regional authority. 
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] Access token is not expired. Returning the found cache entry. [Current time (05/16/2024 12:02:41) - Expiration Time (05/16/2024 12:08:18 +00:00) - Extended Expiration Time (05/16/2024 12:08:18 +00:00)]
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] Returning access token found in cache. RefreshOn exists ? False
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] [Region discovery] Not using a regional authority. 
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c] 
        === Token Acquisition finished successfully:
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.4 Microsoft Windows 10.0.22631 [2024-05-16 12:02:41Z - c8c89652-70ff-4ed7-b654-58b05a459e3c]  AT expiration time: 2024-05-16 12:08:18 +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: 2024-05-16T12:08:18.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '<TenantId>', UserId: '<UserID>'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/<SubscriptionId>/resourceGroups/<ResourceGroupName>/providers/Microsoft.ApiManagement/service/<API Manamanget Service Name>/apis?api-version=2021-08-01

Headers:
Accept-Language               : en-US
x-ms-client-request-id        : c966bd26-3259-4e6e-b1bf-9747ce10df62

Body:

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

Status Code:
BadRequest

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
x-ms-request-id               : 188792f1-cf07-40da-a302-1daddafac37f
x-ms-throttling-version       : v1
x-ms-ratelimit-remaining-subscription-reads: 11985
x-ms-correlation-request-id   : 188792f1-cf07-40da-a302-1daddafac37f
x-ms-routing-request-id       : SWEDENCENTRAL:20240516T120242Z:188792f1-cf07-40da-a302-1daddafac37f
X-Cache                       : CONFIG_NOCACHE
X-MSEdge-Ref                  : Ref A: 48E1BA1BA4C444A2B1B9DD742133D18B Ref B: HEL01EDGE1715 Ref C: 2024-05-16T12:02:42Z
Date                          : Thu, 16 May 2024 12:02:41 GMT

Body:
{
  "error": {
    "code": "MissingOrIncorrectVersionParameter",
    "message": "API version query parameter is not specified or was specified incorrectly.  Supported versions: 2022-08-01,2022-09-01-preview,2023-03-01-preview,2023-05-01-preview,2023-09-01-preview  Example query param format: api-version=SupportedVersion",  
    "details": null
  }
}

DEBUG: 14:02:42 - [ConfigManager] Got nothing from [DisableErrorRecordsPersistence], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 14:02:42 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
Get-AzApiManagementApi: 
Error Code: MissingOrIncorrectVersionParameter
Error Message: API version query parameter is not specified or was specified incorrectly.  Supported versions: 2022-08-01,2022-09-01-preview,2023-03-01-preview,2023-05-01-preview,2023-09-01-preview  Example query param format: api-version=SupportedVersion     
Request Id: 188792f1-cf07-40da-a302-1daddafac37f
DEBUG: 14:02:42 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 14:02:42 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 14:02:42 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].   
DEBUG: AzureQoSEvent:  Module: Az.ApiManagement:4.0.2; CommandName: Get-AzApiManagementApi; PSVersion: 7.4.2; IsSuccess: False; Duration: 00:00:00.6067811; Exception: 
Error Code: MissingOrIncorrectVersionParameter
Error Message: API version query parameter is not specified or was specified incorrectly.  Supported versions: 2022-08-01,2022-09-01-preview,2023-03-01-preview,2023-05-01-preview,2023-09-01-preview  Example query param format: api-version=SupportedVersion     
Request Id: 188792f1-cf07-40da-a302-1daddafac37f
;
DEBUG: 14:02:42 - GetAzureApiManagementApi end processing.

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22631
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    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.19.0                Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-… 
Script     4.0.2                 Az.ApiManagement                    {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToP… 
Script     6.16.2                Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyA…

Error output

No response

dolauli commented 5 months ago

Please investigate why the API version is not avail for this user.

cloudcosmonaut commented 3 months ago

Hey @dolauli, any update on this?

microsoft-github-policy-service[bot] commented 2 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @solankisamir, @mikebudzynski, @KedarJoshi, @yingru97.