You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Configure MLflow for Azure Machine Learning
3
3
titleSuffix: Azure Machine Learning
4
-
description: Connect MLflow to Azure Machine Learning workspaces to log metrics, artifacts, and deploy models.
4
+
description: Find out how to connect MLflow to an Azure Machine Learning workspace to log metrics, track artifacts, and deploy models.
5
5
services: machine-learning
6
6
author: msakande
7
7
ms.author: mopeakande
8
8
ms.reviewer: fasantia
9
9
ms.service: azure-machine-learning
10
10
ms.subservice: mlops
11
-
ms.date: 01/19/2024
11
+
ms.date: 11/20/2024
12
12
ms.topic: how-to
13
13
ms.custom: mlflow, cliv2, devplatv2
14
14
ms.devlang: azurecli
15
+
# customer intent: As a developer, I want to see how to configure MLflow so that I can run MLflow training routines in Azure Machine Learning.
15
16
---
16
17
17
18
# Configure MLflow for Azure Machine Learning
18
19
19
-
This article explains how you can configure MLflow to connect to an Azure Machine Learning workspace for tracking, registries, and deployment.
20
+
This article explains how to configure MLflow to connect to an Azure Machine Learning workspace for tracking, registry management, and deployment.
20
21
21
-
Azure Machine Learning workspaces are MLflow-compatible, which means they can act as an MLflow server without any extra configuration. Each workspace has an MLflow tracking URI that MLflow can use to connect to the workspace. Azure Machine Learning workspaces **are already configured to work with MLflow** so no extra configuration is required.
22
+
Azure Machine Learning workspaces are MLflow-compatible, which means they can act as MLflow servers without any extra configuration. Each workspace has an MLflow tracking URI that MLflow can use to connect to the workspace. Azure Machine Learning workspaces **are already configured to work with MLflow**, so no extra configuration is required.
22
23
23
-
However, if you work outside of Azure Machine Learning (like your local machine, Azure Synapse Analytics, or Azure Databricks), you need to configure MLflow to point to the workspace.
24
+
However, if you work outside Azure Machine Learning, you need to configure MLflow to point to the workspace. Affected environments include your local machine, Azure Synapse Analytics, and Azure Databricks.
24
25
25
26
> [!IMPORTANT]
26
-
> When running on Azure Compute (Azure Machine Learning Notebooks, Jupyter notebooks hosted on Azure Machine Learning compute instances, or jobs running on Azure Machine Learning compute clusters), you don't have to configure the tracking URI. **It's automatically configured for you**.
27
+
> When you use Azure compute infrastructure, you don't have to configure the tracking URI. **It's automatically configured for you**. Environments with automatic configuration include Azure Machine Learning notebooks, Jupyter notebooks that are hosted on Azure Machine Learning compute instances, and jobs that run on Azure Machine Learning compute clusters.
27
28
28
29
## Prerequisites
29
30
30
-
You need the following prerequisites to follow this tutorial:
31
+
- The MLflow SDK `mlflow` package and the Azure Machine Learning `azureml-mlflow` plugin for MLflow. You can use the following command to install this software:
> Instead of `mlflow`, consider using [`mlflow-skinny`](https://github.com/mlflow/mlflow/blob/master/README_SKINNY.rst). This package is a lightweight MLflow package without SQL storage, server, UI, or data science dependencies. It's recommended for users who primarily need MLflow tracking and logging capabilities but don't want to import the full suite of features, including deployments.
34
39
35
-
## Configure MLflow tracking URI
40
+
- An Azure Machine Learning workspace. To create a workspace, see [Create resources you need to get started](quickstart-create-resources.md).
36
41
37
-
To connect MLflow to an Azure Machine Learning workspace, you need the tracking URI for the workspace. Each workspace has its own tracking URI and it has the protocol `azureml://`.
42
+
- Access permissions for performing MLflow operations in your workspace. For a list of operations and required permissions, see [MLflow operations](how-to-assign-roles.md#mlflow-operations).
43
+
44
+
## Configure the MLflow tracking URI
45
+
46
+
To do remote tracking, or track experiments running outside Azure Machine Learning, configure MLflow to point to the tracking URI of your Azure Machine Learning workspace.
47
+
48
+
To connect MLflow to an Azure Machine Learning workspace, you need the tracking URI of the workspace. Each workspace has its own tracking URI, which starts with the protocol `azureml://`.
Once the tracking is set, you also need to configure the authentication method for the associated workspace. By default, the Azure Machine Learning plugin for MLflow performs interactive authentication by opening the default browser to prompt for credentials.
54
+
After you set up tracking, you also need to configure the authentication method for the associated workspace.
55
+
56
+
By default, the Azure Machine Learning plugin for MLflow performs interactive authentication by opening the default browser to prompt for credentials. But the plugin also supports several other authentication mechanisms. The `azure-identity` package provides this support. This package is installed as a dependency of the `azureml-mlflow` plugin.
44
57
45
-
The Azure Machine Learning plugin for MLflow supports several authentication mechanisms through the package `azure-identity`, which is installed as a dependency for the plugin `azureml-mlflow`. The following authentication methods are tried one by one until one of them succeeds:
58
+
The authentication process tries the following methods, one after another, until one succeeds:
46
59
47
-
1.__Environment__: Reads account information specified via environment variables and uses it to authenticate.
48
-
1.__Managed Identity__: If the application is deployed to an Azure host with Managed Identity enabled, it authenticates with it.
49
-
1.__Azure CLI__: If a user signs in via the Azure CLI `az login` command, it authenticates as that user.
50
-
1.__Azure PowerShell__: If a user signs in via Azure PowerShell's`Connect-AzAccount` command, it authenticates as that user.
51
-
1.__Interactive browser__: Interactively authenticates a user via the default browser.
60
+
1.**Environment**: Account information that's specified via environment variables is read and used for authentication.
61
+
1.**Managed identity**: If the application is deployed to an Azure host with a managed identity enabled, the managed identity is used for authentication.
62
+
1.**Azure CLI**: If you use the Azure CLI `az login` command to sign in, your credentials are used for authentication.
63
+
1.**Azure PowerShell**: If you use the Azure PowerShell `Connect-AzAccount` command to sign in, your credentials are used for authentication.
64
+
1.**Interactive browser**: The user is interactively authenticated via the default browser.
If you'd rather use a certificate instead of a secret, you can configure the environment variables `AZURE_CLIENT_CERTIFICATE_PATH` to the path to a `PEM` or `PKCS12` certificate file (including private key) and
56
-
`AZURE_CLIENT_CERTIFICATE_PASSWORD` with the password of the certificate file, if any.
68
+
If you'd rather use a certificate than a secret, you can configure the following environment variables:
69
+
70
+
- Set `AZURE_CLIENT_CERTIFICATE_PATH` to the path of a file that contains the certificate and private key pair in Privacy Enhanced Mail (PEM) or Public-Key Cryptography Standards 12 (PKCS #12) format.
71
+
- Set `AZURE_CLIENT_CERTIFICATE_PASSWORD` to the password of the certificate file, if it uses a password.
57
72
58
73
### Configure authorization and permission levels
59
74
60
-
Some [default roles](how-to-assign-roles.md#default-roles) like *AzureML Data Scientist* or *Contributor* are already configured to perform MLflow operations in an Azure Machine Learning workspace. If using a custom role, you need the following permissions:
75
+
Some [default roles](how-to-assign-roles.md#default-roles) like AzureML Data Scientist and Contributor are already configured to perform MLflow operations in an Azure Machine Learning workspace. If you use a custom role, you need the following permissions:
To learn how to grant access for the service principal you created or user account to your workspace, see [Grant access](/azure/role-based-access-control/quickstart-assign-role-user-portal#grant-access).
84
+
To see how to grant access to your workspace to a service principal that you create or to your user account, see [Grant access](/azure/role-based-access-control/quickstart-assign-role-user-portal#grant-access).
70
85
71
-
### Troubleshooting authentication
86
+
### Troubleshoot authentication issues
72
87
73
-
MLflow tries to authenticate to Azure Machine Learning on the first operation that interacts with the service, like `mlflow.set_experiment()` or `mlflow.start_run()`. If you find issues or unexpected authentication prompts during the process, you can increase the logging level to get more details about the error:
88
+
MLflow tries to authenticate to Azure Machine Learning on the first operation that interacts with the service, like `mlflow.set_experiment()` or `mlflow.start_run()`. If you experience issues or unexpected authentication prompts during the process, you can increase the logging level to get more details about the error:
All MLflow runs are logged to the active experiment. By default, runs are logged to an experiment named `Default` that is automatically created for you. You can configure the experiment where tracking is happening.
98
+
All MLflow runs are logged to the active experiment. By default, runs are logged to an experiment named `Default` that's automatically created for you. You can configure the experiment that's used for tracking.
84
99
85
100
> [!TIP]
86
-
> When submitting jobs using Azure Machine Learning CLI v2, you can set the experiment name using the property `experiment_name` in the YAML definition of the job. You don't have to configure it on your training script. See [YAML: display name, experiment name, description, and tags](reference-yaml-job-command.md#yaml-display-name-experiment-name-description-and-tags) for details.
101
+
>
102
+
> When you use the Azure Machine Learning CLI v2 to submit jobs, you can set the experiment name by using the `experiment_name` property in the YAML definition of the job. You don't have to configure it in your training script. For more information, see [YAML: display name, experiment name, description, and tags](reference-yaml-job-command.md#yaml-display-name-experiment-name-description-and-tags).
87
103
88
104
89
105
# [MLflow SDK](#tab/mlflow)
90
106
91
-
Configure your experiment by using MLflow command [`mlflow.set_experiment()`](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.set_experiment).
107
+
Use the MLflow [`mlflow.set_experiment()`](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.set_experiment) command to configure your experiment.
92
108
93
-
```Python
94
-
experiment_name ='experiment_with_mlflow'
109
+
```python
110
+
experiment_name ="experiment_with_mlflow"
95
111
mlflow.set_experiment(experiment_name)
96
112
```
97
113
98
-
# [Using environment variables](#tab/environ)
114
+
# [Environment variables](#tab/environ)
99
115
100
-
You can also set one of the MLflow environment variables [MLFLOW_EXPERIMENT_NAME or MLFLOW_EXPERIMENT_ID](https://mlflow.org/docs/latest/cli.html#cmdoption-mlflow-run-arg-uri) with the experiment name.
116
+
Use the MLflow `MLFLOW_EXPERIMENT_NAME` or `MLFLOW_EXPERIMENT_ID` environment variable to configure your experiment. For more information, see [Command-Line Interface](https://mlflow.org/docs/latest/cli.html)or [mlflow.start_run](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.start_run).
The Azure Machine Learning plugin for MLflow is configured by default to work with the global Azure cloud. However, you can configure the Azure cloud you're using by setting the environment variable `AZUREML_CURRENT_CLOUD`.
126
+
The Azure Machine Learning plugin for MLflow is configured by default to work with the global Azure cloud. However, you can configure the Azure cloud you're using by setting the `AZUREML_CURRENT_CLOUD` environment variable:
Copy file name to clipboardExpand all lines: articles/machine-learning/includes/machine-learning-mlflow-configure-auth.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,38 +2,40 @@
2
2
author: santiagxf
3
3
ms.service: azure-machine-learning
4
4
ms.topic: include
5
-
ms.date: 08/16/2024
5
+
ms.date: 11/20/2024
6
6
ms.author: fasantia
7
7
---
8
8
9
-
For interactive jobs where there's a user connected to the session, you can rely on Interactive Authentication and hence no further action is required.
9
+
For interactive jobs where there's a user connected to the session, you can rely on interactive authentication. No further action is required.
10
10
11
11
> [!WARNING]
12
-
> *Interactive browser* authentication blocks code execution when it prompts for credentials. This approach isn't suitable for authentication in unattended environments like training jobs. We recommend that you configure a different authentication mode.
12
+
> *Interactive browser* authentication blocks code execution when it prompts for credentials. This approach isn't suitable for authentication in unattended environments like training jobs. We recommend that you configure a different authentication mode in those environments.
13
13
14
-
For those scenarios where unattended execution is required, you have to configure a service principal to communicate with Azure Machine Learning.
14
+
For scenarios that require unattended execution, you need to configure a service principal to communicate with Azure Machine Learning. For information about creating a service principal, see [Configure a service principal](../how-to-setup-authentication.md#configure-a-service-principal).
15
+
16
+
Use the tenant ID, client ID, and client secret of your service principal in the following code:
> When working on shared environments, we recommend that you configure these environment variables at the compute. As a best practice, manage them as secrets in an instance of Azure Key Vault.
39
+
> When you work in shared environments, we recommend that you configure these environment variables at the compute level. As a best practice, manage them as secrets in an instance of Azure Key Vault.
38
40
>
39
-
> For instance, in Azure Databricks you can use secrets in environment variables as follows in the cluster configuration: `AZURE_CLIENT_SECRET={{secrets/<scope-name>/<secret-name>}}`. For more information about implementing this approach in Azure Databricks, see [Reference a secret in an environment variable](/azure/databricks/security/secrets/secrets#reference-a-secret-in-an-environment-variable) or refer to documentation for your platform.
41
+
> For instance, in an Azure Databricks cluster configuration, you can use secrets in environment variables in the following way: `AZURE_CLIENT_SECRET={{secrets/<scope-name>/<secret-name>}}`. For more information about implementing this approach in Azure Databricks, see [Reference a secret in an environment variable](/azure/databricks/security/secrets/secrets#reference-a-secret-in-an-environment-variable), or refer to documentation for your platform.
0 commit comments