Seeing error "from azure.mgmt.compute import ComputeManagementClient ModuleNotFoundError: No module named 'azure.profiles'

bonle 10 Reputation points
2024-01-30T07:28:07.14+00:00

Hi, I have added two Azure SDK packages to my python script:

from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient

I uninstalling and then reinstalling the packages azure_mgmt_compute 30.4.0 or azure_mgmt_compute 30.5.0, but error still I run in Test Runbook AzureUser's image

text error :

Failed
Traceback (most recent call last):
  File "/usr/src/tmp/58a16b11-2cba-47c2-9e0f-8875b7c11f4c/runbooks/FlexiblePosgerSQLServerStartStopWeekend.py", line 5, in <module>
    from azure.mgmt.compute import ComputeManagementClient
  File "C:\userenv\lib\site-packages\azure\mgmt\compute\__init__.py", line 9, in <module>
    from ._compute_management_client import ComputeManagementClient
  File "C:\userenv\lib\site-packages\azure\mgmt\compute\_compute_management_client.py", line 15, in <module>
    from azure.profiles import KnownProfiles, ProfileDefinition
ModuleNotFoundError: No module named 'azure.profiles'

User's image

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,255 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 18,756 Reputation points
    2024-03-20T11:25:58.78+00:00

    @bonle @Kumar, Madhu Sudan @Nicole Stevens @Dhruv Kinger This is known issue and Product team is working on this. You may notice this issue, when utilizing Azure modules in Python 3.8 with an error message similar to "ModuleNotFoundError: No module named 'azure.profiles'".

    Product team identified it as a limitation in Py3.8 jobs running on ACI. As of now we have only seen this happening for azure.keyvaults but this applies to Azure packages in general.

    Here is workaround for the same:

    1. Try upgrading the Azure modules to the latest versions.
    2. Alternatively, if upgrading is not feasible, users can install the azure.common module version 1.1.23 as a user module in their automation account.
    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.