azure-cli-extensions: az grafana create command fails with no module found

az grafana create command creates a grafana instance, but fails with the following error: Grafana instance of ‘mygrafana’ was created. Now creating default role assignments for its managed identity, and current CLI account unless --principal-ids are provided The command failed with an unexpected error. Here is the traceback: No module named ‘azure.mgmt.authorization.v2020_04_01_preview’

Command Name az grafana create Extension Name: amg. Version: 1.2.3.

Errors:

Grafana instance of 'mygrafana' was created. Now creating default role assignments for its managed identity, and current CLI account unless --principal-ids are provided
The command failed with an unexpected error. Here is the traceback:
No module named 'azure.mgmt.authorization.v2020_04_01_preview'
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 663, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "C:\Users\venuvvul.REDMOND\.azure\cliextensions\amg\azext_amg\custom.py", line 68, in create_grafana
    _create_role_assignment(cmd.cli_ctx, p, t, grafana_admin_role_id, resource.id)
  File "C:\Users\venuvvul.REDMOND\.azure\cliextensions\amg\azext_amg\custom.py", line 116, in _create_role_assignment
    api_version="2020-04-01-preview").role_assignments
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt./authorization/_authorization_management_client.py", line 784, in role_assignments
ModuleNotFoundError: No module named 'azure.mgmt.authorization.v2020_04_01_preview'

To Reproduce:

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

  • Install latest az cli and install amg extension
  • az grafana create --name {} --resource-group {} --location {}

Expected Behavior

Grafana instance is created, and the system managed identity should also be created. In addition, this system managed identity should have a monitoring data reader role at the subscription level.

Environment Summary

Windows-10-10.0.22624-SP0
Python 3.10.10
Installer: 

azure-cli 2.47.0

Extensions:
aks-preview 0.5.137
amg 1.2.3
azure-devops 0.26.0

Dependencies:
msal 1.20.0
azure-mgmt-resource 22.0.0

Additional Context

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

We are aware of this issue. @ABZhang0 is on it

Hi there, i have same issue on Azure devops pipelines.