Skip to content

az network bastion rdp | Failure on macOS Sonoma due to--it appears--Window-isms #27523

@David-Noble-at-work

Description

@David-Noble-at-work

Describe the bug

Please help me to understand this stack and address the issue. Note the reference to this import name: WinDLL from ctypes:

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/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py)
Traceback (most recent call last):
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/custom.py", line 232, in rdp_bastion_host
    from ._process_helper import launch_and_wait
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/_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/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py)
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Related command

Here are the commands that I executed:

az login                                                                                                                                 
az account set --subscription "$bastion_subscription_id"
az network bastion rdp --name "$bastion_name" --resource-group "$bastion_resource_group" --target-resource-id "$virtual_machine_resource_id"

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/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py)
Traceback (most recent call last):
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/custom.py", line 232, in rdp_bastion_host
    from ._process_helper import launch_and_wait
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/_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/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py)
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Issue script & Debug output

az login                                                                                                                                 
az account set --subscription "$bastion_subscription_id"
az network bastion rdp --name "$bastion_name" --resource-group "$bastion_resource_group" --target-resource-id "$virtual_machine_resource_id" --debug

cli.knack.log: File logging enabled - writing logs to '/Users/david-noble/.azure/logs'.
cli.knack.cli: Command arguments: ['network', 'bastion', 'rdp', '--name', 'vivekra-vnet-bastion', '--resource-group', 'vivekra', '--target-resource-id', '/subscriptions/7fa00e3b-9d68-49e9-b660-ff8dfad141f6/resourceGroups/vivekra/providers/Microsoft.Compute/virtualMachines/cassperfeus', '--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 0x100ffca40>, <function OutputProducer.on_global_arguments at 0x10118a480>, <function CLIQuery.on_global_arguments at 0x1011cc0e0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Loading all modules and extensions
cli.azure.cli.core: Discovered command modules: ['acr', 'acs', 'advisor', 'ams', 'apim', 'appconfig', 'appservice', 'aro', 'backup', 'batch', 'batchai', 'billing', 'botservice', 'cdn', 'cloud', 'cognitiveservices', 'config', 'configure', 'consumption', 'container', 'containerapp', 'cosmosdb', 'databoxedge', 'dla', 'dls', 'dms', 'eventgrid', 'eventhubs', 'extension', 'feedback', 'find', 'hdinsight', 'identity', 'interactive', 'iot', 'keyvault', 'kusto', 'lab', 'managedservices', 'maps', 'marketplaceordering', 'monitor', 'mysql', 'netappfiles', 'network', 'policyinsights', 'privatedns', 'profile', 'rdbms', 'redis', 'relay', 'resource', 'role', 'search', 'security', 'servicebus', 'serviceconnector', 'servicefabric', 'signalr', 'sql', 'sqlvm', 'storage', 'synapse', 'util', 'vm']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: acr                       0.065        34       144
cli.azure.cli.core: acs                       0.010         7        54
cli.azure.cli.core: advisor                   0.001         3         6
cli.azure.cli.core: ams                       0.003        22       100
cli.azure.cli.core: apim                      0.002        14        68
cli.azure.cli.core: appconfig                 0.001         9        47
cli.azure.cli.core: appservice                0.033        73       260
cli.azure.cli.core: aro                       0.005         1        10
cli.azure.cli.core: backup                    0.002        16        59
cli.azure.cli.core: batch                     0.011        34       102
cli.azure.cli.core: batchai                   0.001        10        30
cli.azure.cli.core: billing                   0.003        19        52
cli.azure.cli.core: botservice                0.001        12        42
cli.azure.cli.core: cdn                       0.003        39       133
cli.azure.cli.core: cloud                     0.001         1         7
cli.azure.cli.core: cognitiveservices         0.001        10        33
cli.azure.cli.core: config                    0.001         2         7
cli.azure.cli.core: configure                 0.000         2         5
cli.azure.cli.core: consumption               0.009         8         9
cli.azure.cli.core: container                 0.004         1        11
cli.azure.cli.core: containerapp              0.043        36       115
cli.azure.cli.core: cosmosdb                  0.007        58       192
cli.azure.cli.core: databoxedge               0.002         5        27
cli.azure.cli.core: dla                       0.001        23        62
cli.azure.cli.core: dls                       0.001         7        41
cli.azure.cli.core: dms                       0.001         3        22
cli.azure.cli.core: eventgrid                 0.002        25        96
cli.azure.cli.core: eventhubs                 0.005        13        20
cli.azure.cli.core: extension                 0.000         1         7
cli.azure.cli.core: feedback                  0.000         1         2
cli.azure.cli.core: find                      0.000         1         1
cli.azure.cli.core: hdinsight                 0.003         8        39
cli.azure.cli.core: identity                  0.001         2        11
cli.azure.cli.core: interactive               0.000         1         1
cli.azure.cli.core: iot                       0.037        19        82
cli.azure.cli.core: keyvault                  0.004        22       133
cli.azure.cli.core: kusto                     0.001         3        14
cli.azure.cli.core: lab                       0.001        11        34
cli.azure.cli.core: managedservices           0.001         3         8
cli.azure.cli.core: maps                      0.001         5        13
cli.azure.cli.core: marketplaceordering       0.001         1         2
cli.azure.cli.core: monitor                   0.179        21        67
cli.azure.cli.core: mysql                     0.058        14        49
cli.azure.cli.core: netappfiles               0.003        17        96
cli.azure.cli.core: network                   0.068       115       353
cli.azure.cli.core: policyinsights            0.006         9        17
cli.azure.cli.core: privatedns                0.009        14        60
cli.azure.cli.core: profile                   0.001         2         8
cli.azure.cli.core: rdbms                     0.009        44       185
cli.azure.cli.core: redis                     0.001         5        27
cli.azure.cli.core: relay                     0.010         7         8
cli.azure.cli.core: resource                  0.006        51       227
cli.azure.cli.core: role                      0.001        17        61
cli.azure.cli.core: search                    0.001         7        22
cli.azure.cli.core: security                  0.002        48       104
cli.azure.cli.core: servicebus                0.008        12        16
cli.azure.cli.core: serviceconnector          0.037        12       182
cli.azure.cli.core: servicefabric             0.007        27        76
cli.azure.cli.core: signalr                   0.001         8        30
cli.azure.cli.core: sql                       0.006        56       215
cli.azure.cli.core: sqlvm                     0.009         4        20
cli.azure.cli.core: storage                   0.046        58       272
cli.azure.cli.core: synapse                   0.005        54       246
cli.azure.cli.core: util                      0.001         3         7
cli.azure.cli.core: vm                        0.028        57       230
cli.azure.cli.core: Total (65)                0.773      1227      4679
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: account                   0.003         4        13  /Users/david-noble/.azure/cliextensions/account
cli.azure.cli.core: azure-devops              0.057        60       192  /Users/david-noble/.azure/cliextensions/azure-devops
cli.azure.cli.core: bastion                   0.003         2         9  /Users/david-noble/.azure/cliextensions/bastion
cli.azure.cli.core: ssh                       0.006         1         4  /Users/david-noble/.azure/cliextensions/ssh
cli.azure.cli.core: Total (4)                 0.069        67       218  
cli.azure.cli.core: Loaded 1280 groups, 4897 commands.
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x10292ade0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/david-noble/.azure/commands/2023-10-04.09-04-04.network_bastion_rdp.80284.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.<locals>.add_subscription_parameter at 0x1029876a0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x102987740>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x102987880>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [<function _documentdb_deprecate at 0x1042ac0e0>]
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x10118a520>, <function CLIQuery.handle_query_parameter at 0x1011cc180>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x1029877e0>, <function handler at 0x10456b060>, <function DevCommandsLoader.post_parse_args at 0x113c3fd80>]
az_command_data_logger: extension name: bastion
az_command_data_logger: extension version: 0.2.5
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 "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/custom.py", line 232, in rdp_bastion_host
    from ._process_helper import launch_and_wait
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/_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/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/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/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py)
Traceback (most recent call last):
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/custom.py", line 232, in rdp_bastion_host
    from ._process_helper import launch_and_wait
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/_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/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py)
az_command_data_logger: cannot import name 'WinDLL' from 'ctypes' (/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py)
Traceback (most recent call last):
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/custom.py", line 232, in rdp_bastion_host
    from ._process_helper import launch_and_wait
  File "/Users/david-noble/.azure/cliextensions/bastion/azext_bastion/_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/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/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 0x10292b060>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 0.991 seconds (init: 0.118, invoke: 0.873)
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 7506 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/bin/python3 /Users/david-noble/Library/Python/3.11/lib/python/site-packages/azure/cli/telemetry/__init__.py /Users/david-noble/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

Expected behavior

The native RDP client on macOS Sonoma starts.

Environment Summary

azure-cli                         2.53.0

core                              2.53.0
telemetry                          1.1.0

Extensions:
account                            0.2.5
azure-devops                      0.26.0
bastion                            0.2.5
ssh                                2.0.2

Dependencies:
msal                            1.24.0b2
azure-mgmt-resource             23.1.0b2

Python location '/opt/local/Library/Frameworks/Python.framework/Versions/3.11/bin/python3'
Extensions directory '/Users/david-noble/.azure/cliextensions'

Python (Darwin) 3.11.5 (main, Sep  2 2023, 14:56:54) [Clang 15.0.0 (clang-1500.0.40.1)]

Legal docs and information: aka.ms/AzureCliLegal

Additional context

This problem does not manifest on Windows. It seems every version of azure-cli you release has got show stopping issues for me on Linux and macOS. Are you testing sufficiently on these platforms? Have you thought about disabling features with a note when they are untested or unsupported on non-Windows platforms?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions