Azure / Azure/azure-cli

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

Open
#29,943 10 comments 8 reactions 0 assignees View on GitHub
act-quality-productivity-squad Auto-Assign bug customer-reported Network - Bastion Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### 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 [, , ]
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 []
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 [.add_subscription_parameter at 0x040443E8>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x0405D988>, .add_cache_arguments at 0x04073C08>, .update_breaking_change_info at 0x04073C58>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .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 []
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

```powershell
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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.