azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

InvalidApiVersionParameter if the resource group is empty

Open progxaker opened this issue 6 months ago • 12 comments

Describe the bug

Hello. I accidentally discovered that if the resource group is empty, the command returns InvalidApiVersionParameter.

Related command

First: az identity show -g '' --name anyname. but tried with the following commands and got the same error:

  • az postgres flexible-server show -g '' --name anyname;
  • az aks show -g '' --name anyname;
  • az network application-gateway show -g '' --name anyname;

Errors

(InvalidApiVersionParameter) The api-version '<version>' is invalid. The supported versions are '<version>,<version>,<version>'.
Code: InvalidApiVersionParameter
Message: The api-version '<version>' is invalid. The supported versions are '<version>,<version>,<version>'.

Issue script & Debug output

cli.knack.cli: Command arguments: ['network', 'application-gateway', 'show', '-g', '', '--name', 'anyname', '--debug']
cli.knack.cli: _init_debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser. OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7fdde9a9d3a0>, <function Output Producer.on_global_arguments at 0x7fdde9a41da0>,
function CLIQuery.on_global_arguments at 0x7fdde9857880>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns', 'azext_firewall']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name	Load Time	Groups	Commands
cli.azure.cli.core: network     0.672		116	361
cli.azure.cli.core: privatedns	0.021		14	60
cli.azure.cli.core: Total (2)	0.693		130	421
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name		Load Time 	Groups	Commands	Directory
cli.azure.cli.core: azure-firewall	0.018		16	46		/root/.azure/cliextensions/azure-firewall
cli.azure.cli.core: Total (1)		0.018		16	46		/root/.azure/cliextensions/azure-firewall
cli.azure.cli.core: Loaded 144 groups, 467 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : network application-gateway show
cli.azure.cli.core: Command table: network application-gateway show
cli.knack.cli: Event: CommandInvoker.OnPreCommandTable Truncate [<function AzCliLogging.init_command_file_logging at 0x7fdde8d20c20>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/root/.azure/commands/2023-12-15.10-40-43.network_application-gateway_show.1711.log'.
az_command_data_logger: command args: network application-gateway show -g {}-name {}-debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7fdde8b3cea0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgument Load []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7fdde8b3cf40>, <function register_cache_arguments.<locals>.ad
d_cache_arguments at 0x7fdde8b3d080>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function Output Producer.handle_output_argument at 0x7fdde9a41e40>, <function CLIQuery.handle_query_parameter at 0x7fdde9857920>, <fun
ction register_ids_argument.<locals>.parse_ids_arguments at 0x7fdde8b3cfe0>]
cli.azure.cli.core.auth.persistence: build_persistence: location="/root/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /root/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 Retry (total=1, connect=None, read=None, redirect=None, status=None)
'response_modes_supp
msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/<tenant-id>/discovery/v2.0/keys',orted': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'l, 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/<tenant-id>/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/<tenant-id>/kerberos', 'tenant_region_scope': 'NA', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? False
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes= ('https://management.core.windows.net//.default',),
kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes= ('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 4d8c06c6-0fff-4cb9-89b6-bb3cc1c8cf20
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/<subscription-id>/resourceGroups//providers/Microsoft.Network/applicationGateways/anyname?api-version-2023-02-01'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 	'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 	'x-ms-client-request-id': 654285a2-9b36-11ee-aceb-00155deab31c'
cli.azure.cli.core.sdk.policies: 	'CommandName': 'network application-gateway show"
cli.azure.cli.core.sdk.policies:	'ParameterSetName': '-g --name-debug'
cli.azure.cli.core.sdk.policies:	'User-Agent': 'AZURECLI/2.55.0 (DEB) (AAZ) azsdk-python-core/1.26.0 Python/3.11.5 (Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.31)'
cli.azure.cli.core.sdk.policies:	'Authorization': '******'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/<subscription-id>/resourceGroups//providers/Microsoft.Network/applicationGateways/anyname?api-version=2023-02-01 HTTP/1.1" 400 761
cli.azure.cli.core.sdk.policies: Response status: 400
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:	'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies:	'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies:	'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies:	'Expires': '-1'
cli.azure.cli.core.sdk.policies:	'x-ms-failure-cause': 'gateway'
cli.azure.cli.core.sdk.policies:	'x-ms-request-id': 'c25614ec-b76c-49a1-bbb3-5b71e0c4ae68'
cli.azure.cli.core.sdk.policies:	'x-ms-correlation-request-id': 'c25614ec-b76c-49a1-bbb3-5b71e0c4ae68'
cli.azure.cli.core.sdk.policies:	'x-ms-routing-request-id': 'EASTUS: 20231215T104043Z:c25614ec-b76c-49a1-bbb3-5b71e0c4ae68'
cli.azure.cli.core.sdk.policies:	'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:	'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:	'Date': 'Fri, 15 Dec 2023 10:40:43 GMT'
cli.azure.cli.core.sdk.policies:	'Content-Length': '761'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"error":{"code":"InvalidApiVersionParameter", "message": "The api-version 2023-02-01' is invalid. The supported versions are '2023-07-01, 2023-07-01-preview, 2023-03-01-preview, 2022-12-01, 2022-11-01-preview, 2022-09-01, 2022-06-01, 2022-05-01, 2022-03-01-preview, 2022-01-01, 2021-04-01, 2021-01-01, 2020-10-01, 2020-09-01, 2020-08-01, 2020-07-01, 2020-06-01,2020-05-01, 2020-01-01, 2019-11-01, 2019-10-01, 2019-09-01, 2019-08-01, 2019-07-01, 2019-06-01, 2019-05-10, 2019-05-01, 2019-03-01, 2018-11-01, 2018-09-01, 2018-08-01, 2018-07-01, 2018-06-01, 2018-05-01,2018-02-01, 2018-01-01, 2017-12-01, 2017-08-01, 2017-06-01,2017-05-10, 2017-05-01, 2017-03-01, 2016-09-01, 2016-07-01, 2016-06-01, 2016-02-01, 2015-11-01, 2015-01-01, 2014-04-01-preview, 2014-04-01, 2014-01-01, 2013-03-01, 2014-02-26, 2014-04'."}}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job (expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy (params)
             ^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/aaz/_command.py", line 155, in _call____
    return self._handler (*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/network/aaz/latest/network/application_gateway/_show.py", line 33, in _handler
    self._execute_operations()
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/network/aaz/latest/network/application_gateway/_show.py", line 60, in _execute_operations
    self. ApplicationGatewaysGet(ctx=self.ctx) ()
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/network/aaz/latest/network/application_gateway/_show.py", line 84, in _call____
    return self.on_error(session.http_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/aaz/_operation.py", line 332, in on_error
    raise HttpResponseError (response-response, error_format=error_format)
azure.core.exceptions.HttpResponseError: (InvalidApiVersionParameter) The api-version 2023-02-01' is invalid. The supported versions are '2023-07-01, 2023-07-01-preview, 2023-03-01-preview, 2022-12-01, 2022-11-01-preview, 2022-09-01, 2022-06-01, 2022-05-01, 2022-03-01-preview, 2022-01-01, 2021-04-01, 2021-01-01, 2020-10-01, 2020-09-01, 2020-08-01, 2020-07-01, 2020-06-01, 2020-05-01, 2020-01-01, 2019-11-01, 2019-10-01, 2019-09-01, 2019-08-01, 2019-07-01, 2019-06-01, 2019-05-10, 2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01, 2018-02-01, 2018-01-01, 2017-12-01, 2017-08-01, 2017-06-01, 2017-05-10, 2017-05-01, 2017-03-01, 2016-09-01, 2016-07-01, 2016-06-01, 2016-02-01, 2015-11-01, 2015-01-01, 2014-04-01-preview, 2014-04-01, 2014-01-01, 2013-03-01, 2014-02-26, 2014-04'.
Code: InvalidApiVersionParameter
Message: The api-version '2023-02-01' is invalid. The supported versions are '2023-07-01, 2023-07-01-preview, 2023-03-01-preview, 2022-12-01, 2022-11-01-preview, 2022-09-01, 2022-06-01, 2022-05-01,2022-03-01-preview, 2022-01-01, 2021-04-01, 2021-01-01, 2020-10-01, 2020-09-01, 2020-08-01, 2020-07-01, 2020-06-01, 2020-05-01, 2020-01-01, 2019-11-01, 2019-10-01, 2019-09-01, 2019-08-01, 2019-07-01, 2019-06-01, 2019-05-10, 2019-05-01, 2019-03-01, 2018-11-01,2018-09-01, 2018-08-01, 2018-07-01,2018-06-01, 2018-05-01,2018-02-01, 2018-01-01, 2017-12-01, 2017-08-01, 2017-06-01, 2017-05-10, 2017-05-01, 2017-03-01, 2016-09-01, 2016-07-01, 2016-06-01, 2016-02-01, 2015-11-01, 2015-01-01, 2014-04-01-preview, 2014-04-01, 2014-01-01, 2013-03-01, 2014-02-26, 2014-04'.

cli.azure.cli.core.azclierror: (InvalidApiVersionParameter) The api-version '2023-02-01' is invalid. The supported versions are '2023-07-01, 2023-07-01-preview, 2023-03-01-preview, 2022-12-01,2022-11-01-preview, 2022-09-01, 2022-06-01, 2022-05-01, 2022-03-01-preview, 2022-01-01, 2021-04-01, 2021-01-01, 2020-10-01, 2020-09-01, 2020-08-01, 2020-07-01, 2020-06-01, 2020-05-01, 2020-01-01, 2019-11-01,2019-10-01, 2019-09-01, 2019-08-01, 2019-07-01, 2019-06-01,2019-05-10, 2019-05-01,2019-03-01, 2018-11-01,2018-09-01,2018-08-01, 2018-07-01,2018-06-01,2018-05-01,2018-02-01, 2018-01-01, 2017-12-01,2017-08-01,2017-06-01,2017-05-10, 2017-05-01,2017-03-01, 2016-09-01,2016-07-01,2016-06-01, 2016-02-01, 2015-11-01, 2015-01-01,2014-04-01-preview, 2014-04-01, 2014-01-01, 2013-03-01, 2014-02-26,2014-04'.
Code: InvalidApiVersionParameter
Message: The api-version '2023-02-01' is invalid. The supported versions are '2023-07-01, 2023-07-01-preview, 2023-03-01-preview, 2022-12-01,2022-11-01-preview, 2022-09-01, 2022-06-01, 2022-05-01,2022-03-01-preview, 2022-01-01, 2021-04-01, 2021-01-01, 2020-10-01, 2020-09-01, 2020-08-01, 2020-07-01, 2020-06-01, 2020-05-01, 2020-01-01, 2019-11-01, 2019-10-01, 2019-09-01, 2019-08-01, 2019-07-01, 2019-06-01, 2019-05-10, 2019-05-01,2019-03-01, 2018-11-01, 2018-09-01,2018-08-01,2018-07-01,2018-06-01, 2018-05-01, 2018-02-01,2018-01-01, 2017-12-01, 2017-08-01, 2017-06-01,2017-05-10, 2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01, 2016-02-01, 2015-11-01, 2015-01-01,2014-04-01-preview, 2014-04-01, 2014-01-01,2013-03-01,2014-02-26, 2014-04'.
az_command_data_logger: (InvalidApiVersionParameter) The api-version 2023-02-01' is invalid. The supported versions are '2023-07-01, 2023-07-01-preview, 2023-03-01-preview, 2022-12-01, 2022-11-01-preview, 2022-09-01, 2022-06-01,2022-05-01, 2022-03-01-preview, 2022-01-01, 2021-04-01, 2021-01-01, 2020-10-01, 2020-09-01, 2020-08-01, 2020-07-01, 2020-06-01, 2020-05-01, 2020-01-01,2019-11-01, 2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01, 2019-05-10, 2019-05-01, 2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01, 2018-06-01, 2018-05-01, 2018-02-01,2018-01-01,2017-12-01, 2017-08-01,2017-06-01,2017-05-10, 2017-05-01, 2017-03-01, 2016-09-01, 2016-07-01, 2016-06-01, 2016-02-01,2015-11-01, 2015-01-01, 2014-04-01-preview, 2014-04-01, 2014-01-01, 2013-03-01, 2014-02-26, 2014-04'
Code: InvalidApiVersionParameter
Message: The api-version 2023-02-01' is invalid. The supported versions are '2023-07-01, 2023-07-01-preview, 2023-03-01-preview, 2022-12-01, 2022-11-01-preview, 2022-09-01, 2022-06-01, 2022-05-01,2022-03-01-preview, 2022-01-01, 2021-04-01,2021-01-01, 2020-10-01, 2020-09-01, 2020-08-01, 2020-07-01, 2020-06-01, 2020-05-01, 2020-01-01,2019-11-01, 2019-10-01,2019-09-01, 2019-08-01,2019-07-01, 2019-06-01,2019-05-10, 2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01, 2017-12-01,2017-08-01, 2017-06-01,2017-05-10, 2017-05-01, 2017-03-01, 2016-09-01, 2016-07-01,2016-06-01, 2016-02-01, 2015-11-01, 2015-01-01, 2014-04-01-preview, 2014-04-01, 2014-01-01, 2013-03-01, 2014-02-26, 2014-04'.
cli.knack.cli: Event: Cli. PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fdde8d20ea0>]
az_command_data_logger: exit code: 1
cli. __main: Command ran in 1.058 seconds (init: 0.185, invoke: 0.873)

Expected behavior

Show the error: "resource group is empty".

Environment Summary

azure-cli 2.55.0
core 2.55.0
telemetry 1.1.0

Extensions:
aks-preview 0.5.173
azure-firewall 1.0.0

Dependencies:
msal 1.24.0b2
azure-mgmt-resource 23.1.0b2

Python location '/opt/az/bin/python3'
Extensions directoty '/root/.azure/cliextensions'

Python (Linux) 3.11.5 (main, Nov 29 2023, 03:41:49) [GCC 10.2.1 20210110]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

Additional context

Based on the debug logs, this isn't covered on the server side. As a workaround you can add a condition to az-cli, but I hope that side will be fixed as well.

progxaker avatar Dec 15 '23 11:12 progxaker

Thank you for opening this issue, we will look into it.

yonzhan avatar Dec 15 '23 11:12 yonzhan

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

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

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sunilagarwal, @sr-msft, @niklarin.

This issue needs to be assigned to ARM

RamyaElangovanP avatar Jan 09 '24 00:01 RamyaElangovanP

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dyu1208, @FumingZhang, @andyliuliming.

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @josephkwchan, @jennyhunter-msft.

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

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

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sunilagarwal, @sr-msft, @niklarin.

Agree with @RamyaElangovanP, the error is returned by ARM gateway, the request is not routed to resource provider yet.

FumingZhang avatar Jan 09 '24 03:01 FumingZhang

Hello team. Is there any ETA, issues/internal tickets or updates?

progxaker avatar Mar 02 '24 12:03 progxaker

Hello. Are there any updates?

progxaker avatar Apr 05 '24 06:04 progxaker