Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3.01k forks source link

az network bastion ssh fails with "Missing required field: -n" #29943

Open rolandstirnimann opened 2 months ago

rolandstirnimann commented 2 months ago

Describe the bug

The command to start ssh bastion fails with "Missing required field: -n" even if --name/-n is specified.

Related command

az network bastion ssh --name xxxx --resource-group xxxx --target-ip-address xx.xx.xx.xx --auth-type password --username vmadmin

Errors

InvalidArgumentValue: Missing required field: -n

Issue script & Debug output

cli.knack.cli: Command arguments: ['network', 'bastion', 'ssh', '--name', 'xxxxxx', '--resource-group', 'yyyyyyyyy', '--target-ip-address', 'xx.xx.xx.xx', '--auth-type', 'password', '--username', 'vmadmin', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
Enable VT mode.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x034BC988>, <function OutputProducer.on_global_arguments at 0x035E8A78>, <function CLIQuery.on_global_arguments at 0x03808848>]
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_bastion']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: network                   1.764       117       459
cli.azure.cli.core: privatedns                0.049        14        60
cli.azure.cli.core: Total (2)                 1.813       131       519
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: bastion                   0.031         2         9  C:\Users\firstname.name\.azure\cliextensions\bastion
cli.azure.cli.core: Total (1)                 0.031         2         9
cli.azure.cli.core: Loaded 131 groups, 528 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : network bastion ssh
cli.azure.cli.core: Command table: network bastion ssh
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x0401E3E8>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\firstname.name\.azure\commands\2024-09-20.13-56-58.network_bastion_ssh.17752.log'.
az_command_data_logger: command args: network bastion ssh --name {} --resource-group {} --target-ip-address {} --auth-type {} --username {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x040443E8>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x0405D988>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x04073C08>, <function register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x04073C58>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x035E8AC8>, <function CLIQuery.handle_query_parameter at 0x03808898>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x04073BB8>]
az_command_data_logger: extension name: bastion
az_command_data_logger: extension version: 1.2.0
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command_ctx.py", line 53, in format_args
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_arg_fmt.py", line 415, in __call__
azure.cli.core.aaz.exceptions.AAZInvalidArgValueError: InvalidArgumentValue: Missing required field: -n

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "C:\Users\firstname.name\.azure\cliextensions\bastion\azext_bastion\custom.py", line 146, in ssh_bastion_host
    bastion = Show(cli_ctx=cmd.cli_ctx)(command_args={
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command.py", line 155, in __call__
  File "C:\Users\firstname.name\.azure\cliextensions\bastion\azext_bastion\aaz\latest\network\bastion\_show.py", line 32, in _handler
    super()._handler(command_args)
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command.py", line 165, in _handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command_ctx.py", line 55, in format_args
azure.cli.core.azclierror.InvalidArgumentValueError: InvalidArgumentValue: Missing required field: -n

cli.azure.cli.core.azclierror: InvalidArgumentValue: Missing required field: -n
az_command_data_logger: InvalidArgumentValue: Missing required field: -n
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x0401E528>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 2.848 seconds (init: 0.738, invoke: 2.110)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3836 in cache file under C:\Users\firstname.name\.azure\telemetry\20240920135659369
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry\__init__.pyc C:\Users\firstname.name\.azure C:\Users\firstname.name\.azure\telemetry\20240920135659369"
telemetry.process: Return from creating process 21724
telemetry.main: Finish creating telemetry upload process.

Expected behavior

SSH connection to the target IP should be opened.

Environment Summary

PS C:\Users> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.5
PSEdition                      Core
GitCommitId                    7.3.5
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

PS C:\Users> az version
{
  "azure-cli": "2.64.0",
  "azure-cli-core": "2.64.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {
    "bastion": "1.2.0",
    "ssh": "2.0.5"
  }
}

Additional context

No response

yonzhan commented 2 months ago

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

ThatCheck commented 2 months ago

Same situation here. Unable to put in production now.

Do you have any ETA ?

rolandstirnimann commented 2 months ago

Do you have any ETA ?

Not really. As a workaround, I use the bastion via browser. However, it would be more comfortable to use it via Powershell CLI also for tunneling... Thank you.

kaymaylove commented 2 months ago

Same situation here. Maybe i can downgrade to a previous version like 2.53.0 where it was working 🤔

HeyangQin commented 2 months ago

Downgrading the bastion extension to 1.1.1 fixes the issue for me

az extension remove -n bastion
az extension add --name bastion --version 1.1.1
labiol commented 2 months ago

The same problem with "az network bastion tunnel". Tested on MacOs and LInux.

rolandstirnimann commented 2 months ago

@HeyangQin: Thanks for your hint. I have just downgraded the bastion extension and it works.

luisbunuel commented 2 months ago

Hi guys, still no new release to solve this issue?

thecosmictrickster commented 1 month ago

Piling on here, have the same error, @HeyangQin thanks for that tip, worked for me as well.

kaymaylove commented 1 month ago

I was able to do this and get it working: pip install azure-cli==2.53.0

This didn't work for me :(

Downgrading the bastion extension to 1.1.1 fixes the issue for me

az extension remove -n bastion
az extension add --name bastion --version 1.1.1