{"id":2883,"library":"azureml-mlflow","title":"Azure ML MLflow Integration","description":"The `azureml-mlflow` package provides integration code for connecting MLflow with Azure Machine Learning. It enables users to leverage MLflow's open-source capabilities for tracking machine learning experiments, logging metrics, parameters, and artifacts, and managing models directly within an Azure Machine Learning workspace. This facilitates centralized, secure, and scalable storage for MLflow-tracked assets, whether experiments run locally or on Azure compute. The library is actively maintained with regular updates.","status":"active","version":"1.62.0.post2","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/ml/azure-mlflow","tags":["azure","mlflow","machine-learning","experiment-tracking","model-management","cloud-ml"],"install":[{"cmd":"pip install mlflow azureml-mlflow azure-ai-ml azure-identity","lang":"bash","label":"Recommended installation with core dependencies"}],"dependencies":[{"reason":"Core MLflow functionality; tight version coupling.","package":"mlflow","optional":false},{"reason":"Required for programmatically interacting with Azure ML workspace and retrieving tracking URI (SDK v2).","package":"azure-ai-ml","optional":false},{"reason":"Used for authenticating with Azure services.","package":"azure-identity","optional":false},{"reason":"Was a dependency until 1.62.0; may need explicit install for older code.","package":"azure-common","optional":true}],"imports":[{"symbol":"mlflow","correct":"import mlflow"},{"symbol":"MLClient","correct":"from azure.ai.ml import MLClient"},{"symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nimport mlflow\nfrom azure.ai.ml import MLClient\nfrom azure.identity import DefaultAzureCredential\n\n# Replace with your Azure subscription, resource group, and workspace name\n# For local execution, ensure you are logged into Azure CLI or have appropriate env vars set\nsubscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_SUBSCRIPTION_ID')\nresource_group = os.environ.get('AZURE_RESOURCE_GROUP', 'YOUR_RESOURCE_GROUP')\nworkspace_name = os.environ.get('AZURE_ML_WORKSPACE_NAME', 'YOUR_WORKSPACE_NAME')\n\ntry:\n    # Connect to Azure ML Workspace\n    ml_client = MLClient(\n        credential=DefaultAzureCredential(),\n        subscription_id=subscription_id,\n        resource_group_name=resource_group,\n        workspace_name=workspace_name\n    )\n    azureml_tracking_uri = ml_client.workspaces.get(ml_client.workspace_name).mlflow_tracking_uri\n    mlflow.set_tracking_uri(azureml_tracking_uri)\n    print(f\"MLflow tracking URI set to: {mlflow.get_tracking_uri()}\")\n\n    # Start an MLflow run and log a metric\n    with mlflow.start_run(run_name=\"quickstart_run\") as run:\n        mlflow.log_param(\"alpha\", 0.5)\n        mlflow.log_metric(\"accuracy\", 0.95)\n        print(f\"Logged metric 'accuracy' in run: {run.info.run_id}\")\n\n    print(\"MLflow run completed. Check Azure ML Studio -> Jobs for details.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure Azure credentials are configured (e.g., via Azure CLI 'az login')\")\n    print(\"and that the subscription, resource group, and workspace names are correct.\")\n","lang":"python","description":"This quickstart demonstrates how to configure MLflow to track experiments in an Azure Machine Learning workspace from a Python script. It sets the MLflow tracking URI to your Azure ML workspace and then logs a simple parameter and metric. Ensure you have `azure-ai-ml` and `azure-identity` installed and are authenticated to Azure (e.g., via `az login`)."},"warnings":[{"fix":"Pin your MLflow version to `<=2.16.2` (e.g., `pip install 'mlflow<=2.16.2' azureml-mlflow`).","message":"Azure Machine Learning's MLflow integration is currently compatible with `mlflow<=2.16.x`. Versions `mlflow>=2.17` introduce breaking changes to artifact repository and `LoggedModels` API that are not yet supported by `azureml-mlflow`.","severity":"breaking","affected_versions":"azureml-mlflow < 1.62.0, mlflow >= 2.17.x"},{"fix":"Use separate environments for training (with compatible MLflow) and inference (with `azureml-defaults`). Do not force-downgrade Flask or remove `azureml-inference-server-http`.","message":"When combining training and inference in a single environment, `azureml-defaults` (often pulled for inference) requires `Flask>=3`, while `mlflow<2.8` requires `Flask<3`. This creates a dependency deadlock, making a single 'training + inference' environment unsupported with certain MLflow versions.","severity":"gotcha","affected_versions":"All versions combining `azureml-defaults` and `mlflow < 2.8` or `mlflow >= 2.8` (due to Azure ML tracking server API limitations)."},{"fix":"Explicitly install `azure-common` in your environment if your code requires it (e.g., `pip install azure-common`).","message":"As of `azureml-mlflow` version `1.62.0`, the `azure-common` package was removed as a dependency. Code relying on `azure-common` being transitively installed by `azureml-mlflow` will now fail with `ModuleNotFoundError`.","severity":"breaking","affected_versions":"azureml-mlflow >= 1.62.0"},{"fix":"Consider implementing custom logic to handle restarts, such as checking for existing artifacts or using a new run ID on restart if artifact overwrite is critical.","message":"When using MLflow with low-priority jobs in Azure ML that can be pre-empted and restarted, logging artifacts using `mlflow.start_run()` (without arguments, relying on Azure ML's auto-assigned run ID) can lead to failures. Azure ML's MLflow implementation does not allow overwriting existing artifacts for the same run ID upon restart.","severity":"gotcha","affected_versions":"All versions when using low-priority jobs and default MLflow run behavior."},{"fix":"Ensure `DefaultAzureCredential` is used with `MLClient` and that you are logged into Azure (e.g., `az login`) or relevant environment variables (`AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID`) are set.","message":"Remote MLflow tracking to Azure ML requires proper authentication. If running code outside an Azure ML compute instance (e.g., local machine), you must explicitly configure MLflow to use your Azure credentials, otherwise 403 (Not Authorized) errors will occur.","severity":"gotcha","affected_versions":"All versions for remote tracking."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}