{"id":7032,"library":"azure-mgmt-automation","title":"Azure Management Automation Client Library","description":"The `azure-mgmt-automation` library provides Python APIs for managing Azure Automation resources, including Automation Accounts, Runbooks, Jobs, Schedules, and Hybrid Runbook Workers. It is part of the Azure SDK for Python (Track 2) and is currently at version 1.0.0. Azure SDKs typically follow an 'as-needed' release cadence, with updates when new service features or bug fixes are available.","status":"active","version":"1.0.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","management","cloud","automation","sdk"],"install":[{"cmd":"pip install azure-mgmt-automation","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Provides shared primitives, exceptions, and helpers for Azure SDK libraries.","package":"azure-core","optional":false},{"reason":"Provides core management plane functionalities for Azure management SDKs.","package":"azure-mgmt-core","optional":false},{"reason":"Recommended for authentication, providing credential types like DefaultAzureCredential.","package":"azure-identity","optional":true}],"imports":[{"symbol":"AutomationClient","correct":"from azure.mgmt.automation import AutomationClient"},{"note":"DefaultAzureCredential is the modern, recommended way to authenticate across various environments. Older credential types are largely deprecated in Track 2 SDKs.","wrong":"from azure.common.credentials import ServicePrincipalCredentials","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.automation import AutomationClient\n\n# Ensure you have your Azure Subscription ID set as an environment variable\n# For example: export AZURE_SUBSCRIPTION_ID='your-subscription-id'\nsubscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', '')\nresource_group_name = 'myResourceGroup'\nautomation_account_name = 'myAutomationAccount'\n\nif not subscription_id:\n    raise ValueError(\"AZURE_SUBSCRIPTION_ID environment variable not set.\")\n\n# Authenticate using DefaultAzureCredential (supports various methods: AZURE_CLI, ENV VARS, Managed Identity, etc.)\ncredential = DefaultAzureCredential()\n\n# Create an Automation client\nautomation_client = AutomationClient(credential, subscription_id)\n\ntry:\n    # Example: List automation accounts in a resource group\n    print(f\"Listing automation accounts in resource group '{resource_group_name}':\")\n    automation_accounts = automation_client.automation_accounts.list_by_resource_group(resource_group_name)\n    for account in automation_accounts:\n        print(f\" - {account.name} (Location: {account.location})\")\n\n    # Example: Get a specific automation account\n    account = automation_client.automation_accounts.get(resource_group_name, automation_account_name)\n    print(f\"\\nRetrieved automation account: {account.name}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure the resource group and automation account exist and your credentials have permission.\")","lang":"python","description":"This quickstart demonstrates how to authenticate, create an `AutomationClient`, and perform basic operations like listing and retrieving Azure Automation accounts. It relies on environment variables for configuration and `DefaultAzureCredential` for flexible authentication."},"warnings":[{"fix":"Update import statements from `azure.mgmt.<service>` to `azure.mgmt.<service>.models` for model objects, and use `AutomationClient(credential, subscription_id)` for client instantiation. Refer to the Azure SDK migration guides for details.","message":"Migration from 'Track 1' (older) to 'Track 2' Azure SDKs involves significant breaking changes in package names, import paths, and client constructors. `azure-mgmt-automation` version 1.0.0 is a 'Track 2' SDK.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"For local development, ensure you are logged in via Azure CLI (`az login`) or set environment variables like `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. For deployed applications, use Managed Identity where possible.","message":"Authentication can be complex, especially managing credentials across development environments (local, dev, prod). `DefaultAzureCredential` attempts multiple authentication methods sequentially.","severity":"gotcha","affected_versions":"All"},{"fix":"Always verify resource group names, subscription IDs, and resource names. Use `az group list` and `az account show` via Azure CLI to confirm details.","message":"Resource group and subscription ID are crucial context for almost all Azure management operations. Incorrect IDs or names will lead to 'Resource Not Found' errors.","severity":"gotcha","affected_versions":"All"},{"fix":"Adopt `from azure.identity import DefaultAzureCredential` and configure your environment for it. This provides a unified and more secure authentication experience.","message":"Direct usage of older credential types like `ServicePrincipalCredentials` or `TokenCredential` subclasses from `msrestazure.azure_active_directory` is deprecated in favor of `azure-identity`'s `DefaultAzureCredential` or specific credential types from `azure.identity`.","severity":"deprecated","affected_versions":"<1.0.0 (for old SDKs), all (for recommended practice)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install azure-mgmt-automation` to install the library.","cause":"The `azure-mgmt-automation` package is not installed in your Python environment.","error":"ModuleNotFoundError: No module named 'azure.mgmt.automation'"},{"fix":"For local development, run `az login` in your terminal or set `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET` environment variables. Ensure the logged-in user or service principal has the necessary permissions.","cause":"The `DefaultAzureCredential` could not find any valid authentication credentials configured in your environment (e.g., Azure CLI login, environment variables, Managed Identity).","error":"CredentialUnavailableError: DefaultAzureCredential failed to retrieve a token."},{"fix":"Verify the resource group name for correctness. Use `az group list` to check existing resource groups. Ensure your Azure identity has 'Reader' or 'Contributor' permissions on the subscription or resource group.","cause":"The specified resource group name does not exist or is misspelled, or the authenticated identity lacks permissions to view it.","error":"azure.core.exceptions.ResourceNotFoundError: The resource group 'myNonExistentResourceGroup' could not be found."},{"fix":"Check the role assignments for your Azure identity in the Azure portal or via Azure CLI (`az role assignment list`). Ensure it has roles like 'Automation Contributor' or 'Contributor' on the relevant scope (subscription, resource group, or specific resource).","cause":"The authenticated identity does not have sufficient permissions to perform the requested operation on the specified subscription or resource.","error":"azure.core.exceptions.ClientAuthenticationError: Access denied to subscription 'your-subscription-id'."}]}