Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'az network bastion tunnel' crashes with "cannot import name 'WinDLL' on MacOS #6350

Closed
SolidJuho opened this issue May 31, 2023 · 5 comments
Assignees
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. CXP Attention This issue is handled by CXP team. needs-author-feedback More information is needed from author to address the issue. Network - Bastion Network
Milestone

Comments

@SolidJuho
Copy link

SolidJuho commented May 31, 2023

Describe the bug

When trying to connect to VM through bastion with Microsoft Remote Desktop on MacOS, It errors to WinDLL can't be loaded so RDP connection does not work.

Issue #26298 seems to be similar, but does not have solution.

Related command

az network bastion rdp --name bastion-prod --resource-group prod --target-resource-id 1-prod

Errors

Command group 'az network' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
The command failed with an unexpected error. Here is the traceback:
cannot import name 'WinDLL' from 'ctypes' (/opt/homebrew/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/init.py)
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/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/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call
return self.handler(*args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/Users/juho.vatanen/.azure/cliextensions/bastion/azext_bastion/custom.py", line 232, in rdp_bastion_host
from ._process_helper import launch_and_wait
File "/Users/juho.vatanen/.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' (/opt/homebrew/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/init.py)

Issue script & Debug output

cli.knack.cli: Command arguments: ['network', 'bastion', 'rdp', '--name', 'bastion-prod', '--resource-group', 'prod', '--target-resource-id', '1-prod', '--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 0x101c31c60>, <function OutputProducer.on_global_arguments at 0x101cbe9e0>, <function CLIQuery.on_global_arguments at 0x101d2fe20>]
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 6.098 112 348
cli.azure.cli.core: privatedns 0.028 14 66
cli.azure.cli.core: Total (2) 6.126 126 414
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.070 2 9 /Users/juho/.azure/cliextensions/bastion
cli.azure.cli.core: Total (1) 0.070 2 9
cli.azure.cli.core: Loaded 126 groups, 423 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 0x102720ca0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/juho/.azure/commands/2023-05-31.14-54-21.network_bastion_rdp.904.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 0x102749630>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x10276f2e0>, <function register_cache_arguments..add_cache_arguments at 0x10276f400>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x101cbea70>, <function CLIQuery.handle_query_parameter at 0x101d2feb0>, <function register_ids_argument..parse_ids_arguments at 0x10276f370>]
az_command_data_logger: extension name: bastion
az_command_data_logger: extension version: 0.2.4
Command group 'az network' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/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/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call
return self.handler(*args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/Users/juho/.azure/cliextensions/bastion/azext_bastion/custom.py", line 232, in rdp_bastion_host
from ._process_helper import launch_and_wait
File "/Users/juho/.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' (/opt/homebrew/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/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' (/opt/homebrew/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/init.py)
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/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/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call
return self.handler(*args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/Users/juho/.azure/cliextensions/bastion/azext_bastion/custom.py", line 232, in rdp_bastion_host
from ._process_helper import launch_and_wait
File "/Users/juho/.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' (/opt/homebrew/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/init.py)
az_command_data_logger: cannot import name 'WinDLL' from 'ctypes' (/opt/homebrew/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/init.py)
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/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/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call
return self.handler(*args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.47.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/Users/juho/.azure/cliextensions/bastion/azext_bastion/custom.py", line 232, in rdp_bastion_host
from ._process_helper import launch_and_wait
File "/Users/juho/.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' (/opt/homebrew/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/init.py)

Expected behavior

Connects native RDP (Microsoft Remote Desktop) to Windows VM.
This command works without issues on windows PC.

Environment Summary

azure-cli 2.49.0

core 2.49.0
telemetry 1.0.8

Extensions:
bastion 0.2.4

Dependencies:
msal 1.20.0
azure-mgmt-resource 22.0.0

Python location '/opt/homebrew/Cellar/azure-cli/2.49.0/libexec/bin/python'
Extensions directory '/Users/juho/.azure/cliextensions'

Python (Darwin) 3.10.11 (main, Apr 7 2023, 07:24:53) [Clang 14.0.0 (clang-1400.0.29.202)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

@SolidJuho SolidJuho added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label May 31, 2023
@ghost ghost added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. labels May 31, 2023
@yonzhan
Copy link
Collaborator

yonzhan commented May 31, 2023

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

@ghost ghost added the Network label May 31, 2023
@ghost ghost added this to the Backlog milestone May 31, 2023
@ghost ghost assigned necusjz May 31, 2023
@ghost ghost added Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team CXP Attention This issue is handled by CXP team. Network - Bastion labels May 31, 2023
@yonzhan yonzhan removed the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label May 31, 2023
@navba-MSFT navba-MSFT self-assigned this Jun 1, 2023
@navba-MSFT
Copy link
Contributor

@SolidJuho Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

@navba-MSFT
Copy link
Contributor

@SolidJuho With MACOS, we don’t support RDP. Please use tunnel instead.

az network bastion tunnel --name MyBastionHost --resource-group MyResourceGroup --target-resource-id vmResourceId --resource-port 22 --port 50022

Then you will be able to use any RDP application. More Info here.

@navba-MSFT navba-MSFT added the needs-author-feedback More information is needed from author to address the issue. label Jun 1, 2023
@navba-MSFT
Copy link
Contributor

@SolidJuho I wanted to do quick follow-up to check if you had a chance to look at my above comment. Please let us know if you have any follow-up questions. Awaiting your reply.

@navba-MSFT
Copy link
Contributor

@SolidJuho The action is currently pending on you to try the above suggestion to use tunnel. If you need any further assistance on this issue in future, please feel free to reopen this thread. We would be happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. CXP Attention This issue is handled by CXP team. needs-author-feedback More information is needed from author to address the issue. Network - Bastion Network
Projects
None yet
Development

No branches or pull requests

4 participants