Azure / Azure/azure-powershell
Api Management - Minimum version set to newer than 2021-08-01 causes the function to throw an error.
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### 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
```PowerShell
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 ''...
DEBUG: 14:02:41 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: '', environment: 'AzureCloud', tenant: ''
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:'', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', 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: '', UserId: ''
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.ApiManagement/service//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
```PowerShell
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
```PowerShell
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_
Contributor guide
Research direction
Start with the Get-AzApiManagementApi entry point and the request URL shown in the debug output, then compare its fixed API version with the supported versions returned by Azure. Done means the command succeeds for an API Management instance whose minimum API version is newer than 2021-08-01, with coverage for the reported failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100