azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

Cannot use bastion rdp command on MacOS

Open sbussetti opened this issue 2 years ago • 4 comments

This is autogenerated. Please review and update as needed.

Describe the bug

Not sure if this is to be expected, but if it is, it could be better documented. Other bastion subcommands work fine.

Command Name az network bastion rdp

Errors:

The command failed with an unexpected error. Here is the traceback:
cannot import name 'WinDLL' from 'ctypes' (/opt/homebrew/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/__init__.py)
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.44.1/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.44.1/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.44.1/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.44.1/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.44.1/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.44.1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/homebrew/Cellar/azure-cli/2.44.1/libexec/lib/python3.10/site-packages/azure/cli/command_modules/network/custom.py", line 8323, in rdp_bastion_host
    from ._process_helper import launch_and_wait
  File "/opt/homebrew/Cellar/azure-cli/2.44.1/libexec/lib/python3.10/site-packages/azure/cli/command_modules/network/_process_helper.py", line 9, in <module>
    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.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/__init__.py)

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here...
  • az network bastion rdp --name {} --resource-group {} --target-resource-id {}

Expected Behavior

Environment Summary

macOS-13.0.1-arm64-arm-64bit, Darwin 22.1.0
Python 3.10.9
Installer: HOMEBREW

azure-cli 2.44.1

Additional Context

sbussetti avatar Jan 17 '23 20:01 sbussetti

route to CXP team

yonzhan avatar Jan 17 '23 23:01 yonzhan

@sbussetti Thanks for reaching out to us and reporting this issue. Could you please confirm if you are running this from a cloudshell ? If Yes, it wont be able to open the RDP on your local machine. For this reason, we recommend using powershell with az cli (on Windows machine).

Also, note that RDP command works best on Windows, for other OS’ (like Linux or Mac) you can do the tunnel command and then use the client of your choice.

Connect to a VM using the az network bastion tunnel command. This lets you do the following:

  • Use native clients on non-Windows local computers (example: a Linux PC).
  • Use the native client of your choice. (This includes the Windows native client.)
  • Connect using SSH or RDP.
  • Set up concurrent VM sessions with Bastion.
  • Upload files to your target VM from your local computer. File download from the target VM to the local client is currently not supported for this command.

Currently, this feature has the following limitation: Signing in using an SSH private key stored in Azure Key Vault isn’t supported with this feature. Before signing in to your Linux VM using an SSH key pair, download your private key to a file on your local machine.

Hope this helps.

navba-MSFT avatar Jan 18 '23 08:01 navba-MSFT

Was running this from a macos desktop, will try the other options, just wasn’t clear!

~ Steve

On Wed, Jan 18, 2023 at 3:29 AM, navba-MSFT @.***> wrote:

@.***(https://github.com/sbussetti) Thanks for reaching out to us and reporting this issue. Could you please confirm if you are running this from a cloudshell ? If Yes, it wont be able to open the RDP on your local machine. For this reason, we recommend using powershell with az cli (on Windows machine).

Also, note that RDP command works best on Windows, for other OS’ (like Linux or Mac) you can do the tunnel command and then use the client of your choice.

Connect to a VM using the az network bastion tunnel command. This lets you do the following:

  • Use native clients on non-Windows local computers (example: a Linux PC).
  • Use the native client of your choice. (This includes the Windows native client.)
  • Connect using SSH or RDP.
  • Set up concurrent VM sessions with Bastion.
  • Upload files to your target VM from your local computer. File download from the target VM to the local client is currently not supported for this command.

Currently, this feature has the following limitation: Signing in using an SSH private key stored in Azure Key Vault isn’t supported with this feature. Before signing in to your Linux VM using an SSH key pair, download your private key to a file on your local machine.

Hope this helps.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

sbussetti avatar Jan 18 '23 12:01 sbussetti

@sbussetti Thanks for your reply. Please let us know once you have an update.

navba-MSFT avatar Jan 19 '23 05:01 navba-MSFT

@sbussetti I wanted to do quick follow-up to check if you had a chance to look at my above comment. Also please try to update your bastion extension to the most recent version:

az extension update -n bastion

Please let us know if you had any updates on this. Awaiting your reply.

navba-MSFT avatar Jan 23 '23 04:01 navba-MSFT

@sbussetti The action is currently pending on you to try the above suggestion. Please feel free to reopen this thread, if you need any further assistance. We would be happy to help.

navba-MSFT avatar Jan 30 '23 04:01 navba-MSFT

For anyone else who stumbles across this, you probably want the tunnel command for non-Windows: https://learn.microsoft.com/en-us/azure/bastion/connect-native-client-windows#connect-tunnel

rayterrill avatar May 06 '23 00:05 rayterrill

Duplicate of #23143

jiasli avatar Aug 30 '23 06:08 jiasli

any news ?

vparmeland avatar Jun 20 '24 11:06 vparmeland