azure-cli: Error running az apim command

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az apim show

Errors:

No module named 'azure.mgmt.apimanagement.models.api_management_client_enums'
Traceback (most recent call last):
pip-install-qxmmnr17\knack\knack\cli.py, ln 206, in invoke
cli\core\commands\__init__.py, ln 523, in execute
azure\cli\core\__init__.py, ln 291, in load_arguments
cli\core\commands\__init__.py, ln 290, in load_arguments
pip-install-qxmmnr17\knack\knack\commands.py, ln 97, in load_arguments
cli\core\commands\arm.py, ln 709, in generic_show_arguments_loader
...
<frozen importlib._bootstrap_external>, ln 678, in exec_module
<frozen importlib._bootstrap>, ln 219, in _call_with_frames_removed
cli\command_modules\apim\custom.py, ln 9, in <module>
ModuleNotFoundError: No module named 'azure.mgmt.apimanagement.models.api_management_client_enums'

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 apim show

Expected Behavior

Environment Summary

Windows-10-10.0.18975-SP0
Python 3.6.6
Shell: powershell.exe

azure-cli 2.0.72
azure-cli-iot-ext 0.7.1

Extensions:
alias 0.5.2
azure-cli-iot-ext 0.7.1
azure-devops 0.12.0
interactive 0.4.3
storage-preview 0.2.7
vm-repair 0.1.1
webapp 0.2.19

Additional Context

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

The custom.py file seems to reference a file called azure\mgmt\apimanagement\models\api_management_client_enums.py however if we look in the azure\mgmt\apimanagement\models directory we see that the file is actually called _api_management_client_enums.py.

Removing the underscore in the filename seems to work. But in order to not break anything else I advice you to copy the file and remove the underscore from the copy, so that programs that reference the file with the underscore don’t break.

Disclaimer: I’m not familiar with the source, but this is a work around until it is officially fixed. I wouldn’t use this in any production environment.

@ the azure team,
In the custom.py file, shouldn’t the line

from azure.mgmt.apimanagement.models.api_management_client_enums import VirtualNetworkType, SkuType

just be

from azure.mgmt.apimanagement.models import VirtualNetworkType, SkuType

?
Those two classes are already exposed by the init file.

Same issue: azure-cli 2.0.80

command-modules-nspkg 2.0.3 core 2.0.80 nspkg 3.0.4 telemetry 1.0.4

Used workaround above: api_management_client_enums.py _api_management_client_enums.py

When should we expect a fix for this issue?

@lprichar Sure. We have fixed this one and merged a PR. The new version will be available in the next week. Currently, you can use our edge build version. https://github.com/Azure/azure-cli#edge-builds

Great that it works, but that’s exactly what I said in my earlier comment 😉

But in order to not break anything else I advice you to copy the file and remove the underscore from the copy, so that programs that reference the file with the underscore don’t break.

@wshamroukh I don’t think you should edit the custom.pyc file, since it’s a compiled python file, but it’s file location for me is is C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\command_modules\apim\.

For the work-around you can find the api_management_client_enums file in C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\mgmt\apimanagement\models\

For me not to get it working i had to have two files with the following names under C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\mgmt\apimanagement\models\:

api_management_client_enums.py
_api_management_client_enums.py

Because when I renamed the file from _api_management_client_enums.py to api_management_client_enums.py the init.py was still looking for _api_management_client_enums.py

@wshamroukh I don’t think you should edit the custom.pyc file, since it’s a compiled python file, but it’s file location for me is is C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\command_modules\apim\.

For the work-around you can find the api_management_client_enums file in C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\mgmt\apimanagement\models\