Azure / Azure/azure-cli-extensions
[bastion] `az network bastion ssh` fails with KeyError checking for Native Client support
- Dominant language
- Python
- Stars
- 454
- Forks
- 1.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 64
Description
Source: https://github.com/Azure/azure-cli/issues/32845 (by @CarlOchs)
Affected extension: `bastion` (`src/bastion/`)
---
<<>>
# Issue #32845 (by @CarlOchs)
## Title
`az network bastion ssh` fails with KeyError checking for Native Client support
## Body
### Describe the bug
After deploying a bastion (Standard SKU)+VM instance, I attempted to ssh from the WSL2 command line and received the following error:
'''
The command failed with an unexpected error. Here is the traceback:
'enableTunneling'
Traceback (most recent call last):
File "/opt/az/lib/python3.13/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 669, in execute
raise ex
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 737, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 706, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
File "/home/cjochsjr/.azure/cliextensions/bastion/azext_bastion/custom.py", line 183, in ssh_bastion_host
if not _is_nativeclient_enabled(bastion):
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/home/cjochsjr/.azure/cliextensions/bastion/azext_bastion/custom.py", line 395, in _is_nativeclient_enabled
return bastion['enableTunneling']
~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'enableTunneling'
'''
Reviewing the "Automation > Export Template" output through the portal, I noticed that the generated Bicep did not include most of the properties found on the Bastion "Settings > Configuration" page. Once I enabled Native Client support, I re-generated the template, which then showed *all configuraiton properties*, even those set to false.
### Related command
`az network bastion ssh --name testcjo-bastion-dev --resource-group cjotestev2 --target-resource-id /subscriptions/fe96f029-0423-4766-93fb-bf2066356770/resourceGroups/cjotestev2/providers/Microsoft.Compute/virtualMachines/testcjo-vm-dev --auth-type "ssh-key" --ssh-key ~/.ssh/id_rsa.dev-deploy-vm --username vmadmin`
### Errors
'''
The command failed with an unexpected error. Here is the traceback:
'enableTunneling'
Traceback (most recent call last):
File "/opt/az/lib/python3.13/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 669, in execute
raise ex
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 737, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 706, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
File "/home/cjochsjr/.azure/cliextensions/bastion/azext_bastion/custom.py", line 183, in ssh_bastion_host
if not _is_nativeclient_enabled(bastion):
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/home/cjochsjr/.azure/cliextensions/bastion/azext_bastion/custom.py", line 395, in _is_nativeclient_enabled
return bastion['enableTunneling']
~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'enableTunneling'
'''
### Issue script & Debug output
`az network bastion ssh --name testcjo-bastion-dev --resource-group cjotestev2 --target-resource-id /subscriptions/fe96f029-0423-4766-93fb-bf2066356770/resourceGroups/cjotestev2/providers/Microsoft.Compute/virtualMachines/testcjo-vm-dev --auth-type "ssh-key" --ssh-key ~/.ssh/id_rsa.dev-deploy-vm --username vmadmin --debug 2>&1 | tee /tmp/az_network_ssh.debug.log`
'''
DEBUG: cli.knack.cli: Command arguments: ['network', 'bastion', 'ssh', '--name', 'testcjo-bastion-dev', '--resource-group', 'cjotestev2', '--target-resource-id', '/subscriptions/fe96f029-0423-4766-93fb-bf2066356770/resourceGroups/cjotestev2/providers/Microsoft.Compute/virtualMachines/testcjo-vm-dev', '--auth-type', 'ssh-key', '--ssh-key', '/home/cjochsjr/.ssh/id_rsa.dev-deploy-vm', '--username', 'vmadmin', '--debug']
DEBUG: cli.knack.cli: __init__ debug log:
Cannot enable color.
DEBUG: cli.knack.cli: Event: Cli.PreExecute []
DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
DEBUG: cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns', 'azext_bastion']
DEBUG: cli.azure.cli.core: Loading command modules:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands
DEBUG: cli.azure.cli.core: network 0.717 121 370
DEBUG: cli.azure.cli.core: privatedns 0.017 14 60
DEBUG: cli.azure.cli.core: Total (2) 0.734 135 430
DEBUG: cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
DEBUG: cli.azure.cli.core: Loading extensions:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands Directory
DEBUG: cli.azure.cli.core: bastion 0.007 2 9 /home/cjochsjr/.azure/cliextensions/bastion
DEBUG: cli.azure.cli.core: Total (1) 0.007 2 9
DEBUG: cli.azure.cli.core: Loaded 135 groups, 439 commands.
DEBUG: cli.azure.cli.core: Found a match in the command table.
DEBUG: cli.azure.cli.core: Raw command : network bastion ssh
DEBUG: cli.azure.cli.core: Command table: network bastion ssh
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/cjochsjr/.azure/commands/2026-02-24.16-22-19.network_bastion_ssh.3978641.log'.
INFO: az_command_data_logger: command args: network bastion ssh --name {} --resource-group {} --target-resource-id {} --auth-type {} --ssh-key {} --username {} --debug
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x75c99bfc8c20>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x75c99bfcaf20>, .add_cache_arguments at 0x75c99bfcb100>, .update_breaking_change_info at 0x75c99bfcb1a0>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x75c99bfcafc0>]
INFO: az_command_data_logger: extension name: bastion
INFO: az_command_data_logger: extension version: 1.4.2
/home/cjochsjr/.azure/cliextensions/bastion/azext_bastion/custom.py:107: UserWarning: pkg_resources is depre
... [truncated, original was 22686 chars]
## Comments
### Comment by @yonzhan
Thank you for opening this issue, we will look into it.
### Comment by @microsoft-github-policy-service[bot]
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @isamorris, @bastionsuppgithub.
### Comment by @HujinoKun
+1
### Comment by @HujinoKun
@CarlOchs
Updating the Bastion plugin fixes the issue :
''' bash
az extension update --name bastion
'''
<<>>
Contributor guide
Assessment
This issue has not been assessed yet.