ModuleNotFoundError: No module named 'azure.profiles' | Azure Runbooks | Service Principal | Python 3.8

The Flying Bollox 25 Reputation points
2025-02-12T16:04:26.6033333+00:00

Why is it that whenever I am running a test in my Azure runbook environment of my `` `vm-monitor-logging.py ``` script, do I constantly get the error:

Failed
Traceback (most recent call last):
  File "/usr/src/tmp/2e1ee55b-678c-4023-8759-4e290498c63c/runbooks/vm-monitor-logging.py", line 12, in <module>
    from azure.mgmt.compute import ComputeManagementClient, KnownProfiles, ProfileDefinition
  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 18, in <module>
    from azure.profiles import KnownProfiles, ProfileDefinition
ModuleNotFoundError: No module named 'azure.profiles'

Below are all of the relevant imported modules:

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

These are my list the relevant dependencies and their versions, I am sick to the back teeth of seeing the same error message over and over again, why does nothing work?

Package            Version
------------------ ---------
azure-core         1.32.0
azure-identity     1.19.0
azure-mgmt-compute 34.0.0
azure-mgmt-core    1.5.0
azure-mgmt-resource
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,313 questions
{count} votes

Accepted answer
  1. Rahul Podila 1,830 Reputation points Microsoft Vendor
    2025-02-13T06:33:48.43+00:00

    Hi @The Flying Bollox

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    The error you're encountering, ModuleNotFoundError: No module named 'azure.profiles', suggests that the azure.profiles module is not installed or not available in your Azure runbook environment. This can happen if the required Azure SDK packages are not properly installed or if there is a version compatibility issue.

    In your case, you are using azure-mgmt-compute version 34.0.0, which may depend on other Azure packages that are not included in your list. It's important to ensure that all required dependencies are installed and compatible with each other.

    To resolve this issue, you can try the following steps:

    1. Check Dependencies: Ensure that all necessary Azure SDK packages are installed. You may need to install additional packages that provide the azure.profiles module.
    2. Update Packages: Consider updating your Azure packages to the latest versions. This can help resolve compatibility issues. You can do this by navigating to your Automation account, selecting Modules, and then choosing Update Azure modules.
    3. Verify Package Installation: Azure-core, azure-identity, and other related packages are installed correctly. You can check their availability in your Azure Automation account.
    4. Consult Documentation: Refer to the Azure documentation for any specific requirements regarding the versions of the Azure SDK packages you are using.

    If you have any cocerns, please go through this link: -

    https://learn.microsoft.com/en-us/azure/automation/troubleshoot/runbooks#scenario-runbook-fails-with-a-task-was-canceled-error-message

    https://learn.microsoft.com/en-us/azure/automation/learn/automation-tutorial-runbook-textual-python-3#add-authentication-to-manage-azure-resources

    If you have any further queries, do let us know

    ---------------------------------------------------------------------------------------------------- If the answer is helpful, please click "Accept Answer" and "Upvote it"

    1 person found this answer helpful.

0 additional answers

Sort by: Most 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.