-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Describe the bug
Bastion Tunnel command produces error, even after updating Bastion.
Related command
az network bastion rdp --name "YourBastionName" --resource-group "ResourceGroupName" --target-resource-id "YourVMResourceId"
Errors
The command failed with an unexpected error. Here is the traceback:
cannot import name 'WinDLL' from 'ctypes' (/usr/lib/python3.12/ctypes/init.py)
Traceback (most recent call last):
File "/usr/lib64/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute
raise ex
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/home/azureuser/.azure/cliextensions/bastion/azext_bastion/custom.py", line 285, in rdp_bastion_host
from ._process_helper import launch_and_wait
File "/home/azureuser/.azure/cliextensions/bastion/azext_bastion/_process_helper.py", line 9, in
from ctypes import WinDLL, c_int, c_size_t, Structure, WinError, sizeof, pointer
ImportError: cannot import name 'WinDLL' from 'ctypes' (/usr/lib/python3.12/ctypes/init.py)
Issue script & Debug output
cli.knack.cli: Command arguments: ['network', 'bastion', 'rdp', '--name', 'RachelTest-vnet-bastion', '--resource-group', 'sbox-rachelgrimes-dev-rg', '--target-resource-id', '/subscriptions/900a266e-8e11-47e1-a8e8-ba3ccfa9f292/resourceGroups/sbox-rachelgrimes-dev-rg/providers/Microsoft.Compute/virtualMachines/RachelTest', '--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 0x7f9c76c6a020>, <function OutputProducer.on_global_arguments at 0x7f9c7696b740>, <function CLIQuery.on_global_arguments at 0x7f9c769a8cc0>]
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 0.571 118 361
cli.azure.cli.core: privatedns 0.013 14 60
cli.azure.cli.core: Total (2) 0.583 132 421
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: ai-examples 0.045 1 1 /usr/lib/python3.12/site-packages/azure-cli-extensions/ai-examples
cli.azure.cli.core: bastion 0.005 2 9 /home/azureuser/.azure/cliextensions/bastion
cli.azure.cli.core: Total (2) 0.051 3 10
cli.azure.cli.core: Loaded 133 groups, 431 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : network bastion rdp
cli.azure.cli.core: Command table: network bastion rdp
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f9c75aac720>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/azureuser/.azure/commands/2025-05-29.20-12-48.network_bastion_rdp.5787.log'.
az_command_data_logger: command args: network bastion rdp --name {} --resource-group {} --target-resource-id {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x7f9c75b00e00>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x7f9c75b240e0>, <function register_cache_arguments..add_cache_arguments at 0x7f9c75b24220>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x7f9c75b242c0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f9c7696b7e0>, <function CLIQuery.handle_query_parameter at 0x7f9c769a8d60>, <function register_ids_argument..parse_ids_arguments at 0x7f9c75b24180>]
az_command_data_logger: extension name: bastion
az_command_data_logger: extension version: 1.4.0
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/usr/lib64/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute
raise ex
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/home/azureuser/.azure/cliextensions/bastion/azext_bastion/custom.py", line 285, in rdp_bastion_host
from ._process_helper import launch_and_wait
File "/home/azureuser/.azure/cliextensions/bastion/azext_bastion/_process_helper.py", line 9, in
from ctypes import WinDLL, c_int, c_size_t, Structure, WinError, sizeof, pointer
ImportError: cannot import name 'WinDLL' from 'ctypes' (/usr/lib/python3.12/ctypes/init.py)
cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
cli.azure.cli.core.azclierror: cannot import name 'WinDLL' from 'ctypes' (/usr/lib/python3.12/ctypes/init.py)
Traceback (most recent call last):
File "/usr/lib64/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute
raise ex
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/home/azureuser/.azure/cliextensions/bastion/azext_bastion/custom.py", line 285, in rdp_bastion_host
from ._process_helper import launch_and_wait
File "/home/azureuser/.azure/cliextensions/bastion/azext_bastion/_process_helper.py", line 9, in
from ctypes import WinDLL, c_int, c_size_t, Structure, WinError, sizeof, pointer
ImportError: cannot import name 'WinDLL' from 'ctypes' (/usr/lib/python3.12/ctypes/init.py)
az_command_data_logger: cannot import name 'WinDLL' from 'ctypes' (/usr/lib/python3.12/ctypes/init.py)
Traceback (most recent call last):
File "/usr/lib64/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute
raise ex
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/home/azureuser/.azure/cliextensions/bastion/azext_bastion/custom.py", line 285, in rdp_bastion_host
from ._process_helper import launch_and_wait
File "/home/azureuser/.azure/cliextensions/bastion/azext_bastion/_process_helper.py", line 9, in
from ctypes import WinDLL, c_int, c_size_t, Structure, WinError, sizeof, pointer
ImportError: cannot import name 'WinDLL' from 'ctypes' (/usr/lib/python3.12/ctypes/init.py)
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f9c75aac9a0>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 0.945 seconds (init: 0.242, invoke: 0.702)
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 8388 in cache file under /home/azureuser/.azure/telemetry/20250529201248265
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/usr/bin/python3.12 /usr/lib/az/lib/python3.12/site-packages/azure/cli/telemetry/init.py /home/azureuser/.azure /home/azureuser/.azure/telemetry/20250529201248265"
telemetry.process: Return from creating process 5796
telemetry.main: Finish creating telemetry upload process.
Expected behavior
The az command should get executed and creates a tunnel for RDP and then connect to the local host on the specified port
Environment Summary
azure-cli 2.71.0 *
core 2.71.0 *
telemetry 1.1.0
Extensions:
ai-examples 0.2.5
bastion 1.4.0
ml 2.36.4
ssh 2.0.6
Dependencies:
msal 1.31.2b1
azure-mgmt-resource 23.1.1
Python location '/usr/bin/python3.12'
Config directory '/home/azureuser/.azure'
Extensions directory '/home/azureuser/.azure/cliextensions'
Extensions system directory '/usr/lib/python3.12/site-packages/azure-cli-extensions'
Python (Linux) 3.12.9 (main, Mar 11 2025, 15:30:57) [GCC 13.2.0]
Legal docs and information: aka.ms/AzureCliLegal
You have 2 update(s) available. They will be updated with the next build of Cloud Shell.
Additional context
I have referenced this solution, but I am still getting the same error. Seems like the same issue.