{"id":1361,"library":"azure-mgmt-datafactory","title":"Azure Management Data Factory Client","description":"The azure-mgmt-datafactory library is the official Microsoft Azure Data Factory management client for Python, providing programmatic access to create, configure, and manage Data Factory resources. It is part of the larger Azure SDK for Python ecosystem and is currently at version 9.3.0, with regular updates following the Azure SDK release cadence.","status":"active","version":"9.3.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/datafactory/azure-mgmt-datafactory","tags":["azure","data factory","cloud management","adf","etl"],"install":[{"cmd":"pip install azure-mgmt-datafactory azure-identity","lang":"bash","label":"Install core library and authentication"}],"dependencies":[],"imports":[{"note":"The top-level package import is the standard and recommended way for Azure SDKs since version 2.x, avoiding deep package paths.","wrong":"from azure.mgmt.datafactory.data_factory_management_client import DataFactoryManagementClient","symbol":"DataFactoryManagementClient","correct":"from azure.mgmt.datafactory import DataFactoryManagementClient"},{"symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.datafactory import DataFactoryManagementClient\n\n# --- Authentication --- \n# Set environment variables for authentication:\n# AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID (for Service Principal)\n# or log in via Azure CLI: az login\n# or use managed identity, etc.\n\n# Retrieve subscription ID from environment variable\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"\")\nif not subscription_id:\n    print(\"Please set the AZURE_SUBSCRIPTION_ID environment variable.\")\n    exit(1)\n\n# Create a credential object using DefaultAzureCredential\n# This attempts to authenticate via various methods (environment variables, managed identity, Azure CLI, etc.)\ncredential = DefaultAzureCredential()\n\n# Create a DataFactoryManagementClient\ndata_factory_client = DataFactoryManagementClient(credential, subscription_id)\n\n# --- Example Operation: List Data Factories in a Resource Group ---\n\nresource_group_name = os.environ.get(\"AZURE_RESOURCE_GROUP\", \"\") # Replace with your resource group or set env var\n\nif not resource_group_name:\n    print(\"Please set the AZURE_RESOURCE_GROUP environment variable or provide a default.\")\n    exit(1)\n\nprint(f\"Listing data factories in resource group '{resource_group_name}':\")\ntry:\n    factories = data_factory_client.factories.list_by_resource_group(resource_group_name)\n    found_factories = False\n    for factory in factories:\n        print(f\"- Factory Name: {factory.name}, Location: {factory.location}\")\n        found_factories = True\n    if not found_factories:\n        print(\"No data factories found in this resource group.\")\nexcept Exception as e:\n    print(f\"Error listing data factories: {e}\")\n    print(\"Make sure the resource group exists and your credential has 'Contributor' or 'Data Factory Contributor' role.\")\n\nprint(\"Quickstart complete.\")","lang":"python","description":"This quickstart demonstrates how to authenticate using `DefaultAzureCredential` and initialize the `DataFactoryManagementClient`. It then performs a basic operation to list Data Factories within a specified resource group. Ensure `AZURE_SUBSCRIPTION_ID` and `AZURE_RESOURCE_GROUP` are set in your environment variables for successful execution."},"warnings":[{"fix":"Rewrite client instantiation to `DataFactoryManagementClient(credential, subscription_id)` and use `from azure.identity import DefaultAzureCredential` for authentication. Refer to Azure SDK migration guides for full details.","message":"Major breaking changes occurred between versions 8.x and 9.x. The client constructor signatures changed, authentication now primarily uses `azure.identity` credentials, and `msrestazure` specific patterns are largely replaced. Migration to `azure.identity.DefaultAzureCredential` is mandatory.","severity":"breaking","affected_versions":"8.x and earlier upgrading to 9.x+"},{"fix":"Upgrade your Python environment to 3.9 or newer before installing or running `azure-mgmt-datafactory` version 9 or higher.","message":"Version 9.0.0 and above of `azure-mgmt-datafactory` require Python 3.9 or higher. Installations on older Python versions will fail due to `Requires-Python` metadata.","severity":"breaking","affected_versions":"9.0.0+"},{"fix":"Ensure relevant environment variables (`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`) are set for service principals, or you are logged in via `az login` for user authentication, or other supported authentication methods are correctly configured for your environment.","message":"Authentication issues are common. `DefaultAzureCredential` attempts various authentication methods (environment variables, managed identity, Azure CLI, etc.). Incorrect setup will lead to `CredentialUnavailableError` or permission errors.","severity":"gotcha","affected_versions":"All versions using `azure.identity`"},{"fix":"Always double-check that required resource group names and other resource identifiers are correctly provided to the client methods. Use `os.environ.get()` to load them reliably for robust scripts.","message":"Many management operations require the Azure Resource Group name and other resource-specific names (e.g., factory name, pipeline name) as direct parameters. Forgetting or mistyping these can lead to `ResourceNotFound` or `404` errors, even with correct authentication.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}