Skip to content

Upon ssh, ModuleNotFoundError: No module named 'msrestazure' #31769

@cmp0xff

Description

@cmp0xff

Describe the bug

When trying to ssh into an Azure VM on AzureCLI 2.75.0, I got ModuleNotFoundError: No module named 'msrestazure'.

The bug disappears on AzureCLI 2.74.0.

Related command

ssh <azure VM>

Errors

The command failed with an unexpected error. Here is the traceback:
No module named 'msrestazure'
Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 564, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/__init__.py", line 552, in load_arguments
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 321, in load_arguments
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/commands.py", line 104, in load_arguments
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 124, in arguments_loader
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 59, in get_op_handler
  File "importlib\__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\Users\Yi-FanWang\.azure\cliextensions\ssh\azext_ssh\custom.py", line 19, in <module>
    from . import ip_utils
  File "C:\Users\Yi-FanWang\.azure\cliextensions\ssh\azext_ssh\ip_utils.py", line 8, in <module>
    from msrestazure import tools
ModuleNotFoundError: No module named 'msrestazure'

Issue script & Debug output

Not applicable

Expected behavior

Successfully login to the remote server

Environment Summary

azure-cli                         2.75.0 *

core                              2.75.0 *
telemetry                          1.1.0

Extensions:
ssh                                2.0.2

Dependencies:
msal                              1.32.3
azure-mgmt-resource               23.3.0

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\UserName\.azure'
Extensions directory 'C:\Users\UserName\.azure\cliextensions'

Python (Windows) 3.12.10 (tags/v3.12.10:0cc8128, Apr  8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Additional context

AzureCLI, Python etc. are all installed by winget.

Metadata

Metadata

Assignees

No one assigned

    Labels

    SSHService AttentionThis issue is responsible by Azure service team.VM SSHbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions