Skip to content

Commit d75aab6

Browse files
committed
Update code and text
1 parent 09fc146 commit d75aab6

File tree

3 files changed

+71
-56
lines changed

3 files changed

+71
-56
lines changed
Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
---
22
title: Configure MLflow for Azure Machine Learning
33
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.
55
services: machine-learning
66
author: msakande
77
ms.author: mopeakande
88
ms.reviewer: fasantia
99
ms.service: azure-machine-learning
1010
ms.subservice: mlops
11-
ms.date: 01/19/2024
11+
ms.date: 11/20/2024
1212
ms.topic: how-to
1313
ms.custom: mlflow, cliv2, devplatv2
1414
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.
1516
---
1617

1718
# Configure MLflow for Azure Machine Learning
1819

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.
2021

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.
2223

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.
2425

2526
> [!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.
2728
2829
## Prerequisites
2930

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:
3132

32-
[!INCLUDE [mlflow-prereqs](includes/machine-learning-mlflow-prereqs.md)]
33+
```bash
34+
pip install mlflow azureml-mlflow
35+
```
36+
37+
> [!TIP]
38+
> 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.
39+
40+
- An Azure Machine Learning workspace. To create a workspace, see [Create resources you need to get started](quickstart-create-resources.md).
41+
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).
3343

3444
## Configure the MLflow tracking URI
3545

@@ -39,37 +49,41 @@ To connect MLflow to an Azure Machine Learning workspace, you need the tracking
3949

4050
## Configure authentication
4151

42-
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.
52+
After you set up tracking, you also need to configure the authentication method for the associated workspace.
53+
54+
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.
4355

44-
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:
56+
The authentication process tries the following methods, one after another, until one of them succeeds:
4557

46-
1. __Environment__: Reads account information specified via environment variables and uses it to authenticate.
47-
1. __Managed Identity__: If the application is deployed to an Azure host with Managed Identity enabled, it authenticates with it.
48-
1. __Azure CLI__: If a user signs in via the Azure CLI `az login` command, it authenticates as that user.
49-
1. __Azure PowerShell__: If a user signs in via Azure PowerShell's `Connect-AzAccount` command, it authenticates as that user.
50-
1. __Interactive browser__: Interactively authenticates a user via the default browser.
58+
1. **Environment**: Account information that's specified via environment variables is read and used for authentication.
59+
1. **Managed Identity**: If the application is deployed to an Azure host with a managed identity enabled, the managed identity is used for authentication.
60+
1. **Azure CLI**: If you use the Azure CLI `az login` command to sign in, your credentials are used for authentication.
61+
1. **Azure PowerShell**: If you use the Azure PowerShell `Connect-AzAccount` command to sign in, your credentials are used for authentication.
62+
1. **Interactive browser**: The user is interactively authenticated via the default browser.
5163

5264
[!INCLUDE [mlflow-configure-auth](includes/machine-learning-mlflow-configure-auth.md)]
5365

54-
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
55-
`AZURE_CLIENT_CERTIFICATE_PASSWORD` with the password of the certificate file, if any.
66+
If you'd rather use a certificate instead of a secret, you can configure the following environment variables:
67+
68+
- 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.
69+
- Set `AZURE_CLIENT_CERTIFICATE_PASSWORD` to the password of the certificate file, if it uses a password.
5670

5771
### Configure authorization and permission levels
5872

59-
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:
73+
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:
6074

61-
* **To use MLflow tracking:**
62-
* `Microsoft.MachineLearningServices/workspaces/experiments/*`
63-
* `Microsoft.MachineLearningServices/workspaces/jobs/*`
75+
- **To use MLflow tracking:**
76+
- `Microsoft.MachineLearningServices/workspaces/experiments/*`
77+
- `Microsoft.MachineLearningServices/workspaces/jobs/*`
6478

65-
* **To use MLflow model registry:**
66-
* `Microsoft.MachineLearningServices/workspaces/models/*/*`
79+
- **To use the MLflow model registry:**
80+
- `Microsoft.MachineLearningServices/workspaces/models/*/*`
6781

68-
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).
82+
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).
6983

70-
### Troubleshooting authentication
84+
### Troubleshoot authentication issues
7185

72-
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:
86+
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:
7387

7488
```python
7589
import logging
@@ -79,44 +93,45 @@ logging.getLogger("azure").setLevel(logging.DEBUG)
7993

8094
## Set experiment name (optional)
8195

82-
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.
96+
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.
8397

8498
> [!TIP]
85-
> 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.
99+
>
100+
> 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).
86101
87102

88103
# [MLflow SDK](#tab/mlflow)
89104

90-
Configure your experiment by using MLflow command [`mlflow.set_experiment()`](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.set_experiment).
105+
Use the MLflow [`mlflow.set_experiment()`](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.set_experiment) command to configure your experiment.
91106

92-
```Python
107+
```python
93108
experiment_name = 'experiment_with_mlflow'
94109
mlflow.set_experiment(experiment_name)
95110
```
96111

97-
# [Using environment variables](#tab/environ)
112+
# [Environment variables](#tab/environ)
98113

99-
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.
114+
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).
100115

101116
```bash
102117
export MLFLOW_EXPERIMENT_NAME="experiment_with_mlflow"
103118
```
104119

105120
---
106121

107-
## Nonpublic Azure Clouds support
122+
## Configure support for a nonpublic Azure cloud
108123

109-
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`.
124+
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:
110125

111126
# [MLflow SDK](#tab/mlflow)
112127

113-
```Python
128+
```python
114129
import os
115130

116131
os.environ["AZUREML_CURRENT_CLOUD"] = "AzureChinaCloud"
117132
```
118133

119-
# [Using environment variables](#tab/environ)
134+
# [Environment variables](#tab/environ)
120135

121136
```bash
122137
export AZUREML_CURRENT_CLOUD="AzureChinaCloud"
@@ -136,7 +151,7 @@ The current cloud has the value `IsActive` set to `True`.
136151

137152
Now that your environment is connected to your workspace in Azure Machine Learning, you can start to work with it.
138153

139-
- [Track ML experiments and models with MLflow](how-to-use-mlflow-cli-runs.md)
140-
- [Manage models registries in Azure Machine Learning with MLflow](how-to-manage-models-mlflow.md)
141-
- [Train with MLflow Projects (Preview)](how-to-train-mlflow-projects.md)
154+
- [Track experiments and models with MLflow](how-to-use-mlflow-cli-runs.md)
155+
- [Manage models registry in Azure Machine Learning with MLflow](how-to-manage-models-mlflow.md)
156+
- [Train with MLflow Projects in Azure Machine Learning (preview)](how-to-train-mlflow-projects.md)
142157
- [Guidelines for deploying MLflow models](how-to-deploy-mlflow-models.md)

articles/machine-learning/includes/machine-learning-mlflow-configure-auth.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22
author: santiagxf
33
ms.service: azure-machine-learning
44
ms.topic: include
5-
ms.date: 08/16/2024
5+
ms.date: 11/20/2024
66
ms.author: fasantia
77
---
88

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.
1010

1111
> [!WARNING]
1212
> *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.
1313
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 have to configure a service principal to communicate with Azure Machine Learning.
1515

1616
# [MLflow SDK](#tab/mlflow)
1717

1818
```python
1919
import os
2020

21-
os.environ["AZURE_TENANT_ID"] = "<AZURE_TENANT_ID>"
22-
os.environ["AZURE_CLIENT_ID"] = "<AZURE_CLIENT_ID>"
23-
os.environ["AZURE_CLIENT_SECRET"] = "<AZURE_CLIENT_SECRET>"
21+
os.environ["AZURE_TENANT_ID"] = "<Azure-tenant-ID>"
22+
os.environ["AZURE_CLIENT_ID"] = "<Azure-client-ID>"
23+
os.environ["AZURE_CLIENT_SECRET"] = "<Azure-client-secret>"
2424
```
2525

26-
# [Using environment variables](#tab/environ)
26+
# [Environment variables](#tab/environ)
2727

2828
```bash
29-
export AZURE_TENANT_ID="<AZURE_TENANT_ID>"
30-
export AZURE_CLIENT_ID="<AZURE_CLIENT_ID>"
31-
export AZURE_CLIENT_SECRET="<AZURE_CLIENT_SECRET>"
29+
export AZURE_TENANT_ID="<Azure-tenant-ID>"
30+
export AZURE_CLIENT_ID="<Azure-client-ID>"
31+
export AZURE_CLIENT_SECRET="<Azure-client-secret>"
3232
```
3333

3434
---
3535

3636
> [!TIP]
37-
> 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.
37+
> 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.
3838
>
3939
> 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.

articles/machine-learning/includes/machine-learning-mlflow-configure-tracking.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
author: santiagxf
33
ms.service: azure-machine-learning
44
ms.topic: include
5-
ms.date: 01/02/2023
5+
ms.date: 11/20/2024
66
ms.author: fasantia
77
---
88

@@ -15,8 +15,8 @@ ms.author: fasantia
1515
1. Sign in and configure your workspace:
1616

1717
```bash
18-
az account set --subscription <subscription>
19-
az configure --defaults workspace=<workspace> group=<resource-group> location=<location>
18+
az account set --subscription <subscription-ID>
19+
az configure --defaults workspace=<workspace-name> group=<resource-group-name> location=<location>
2020
```
2121

2222
1. Get the tracking URI by using the `az ml workspace` command:
@@ -25,7 +25,7 @@ ms.author: fasantia
2525
az ml workspace show --query mlflow_tracking_uri
2626
```
2727

28-
# [Python](#tab/python)
28+
# [Python SDK](#tab/python)
2929

3030
[!INCLUDE [sdk v2](machine-learning-sdk-v2.md)]
3131

@@ -97,7 +97,7 @@ ms.author: fasantia
9797
> If you use a private link-enabled workspace, the MLflow endpoint also uses a private link to communicate with Azure Machine Learning. As a result, the tracking URI uses a format that's different from the one in this article. In this case, you need to use the Azure Machine Learning SDK for Python or the Azure Machine Learning CLI v2 to get the tracking URI.
9898

9999
```python
100-
region = "<region>"
100+
region = '<region>'
101101
subscription_id = '<subscription-ID>'
102102
resource_group = '<resource-group-name>'
103103
workspace_name = '<workspace-name>'
@@ -121,7 +121,7 @@ ms.author: fasantia
121121

122122
# [Environment variables](#tab/environ)
123123

124-
In your compute instance, use the following code to set the [MLFLOW_TRACKING_URI](https://mlflow.org/docs/latest/tracking.html#logging-to-a-tracking-server) MLflow environment variable to the tracking URI of your workspace. This assignment makes all interactions with MLflow in that compute instance point to Azure Machine Learning by default.
124+
In your compute instance, use the following code to set the `MLFLOW_TRACKING_URI` MLflow environment variable to the tracking URI of your workspace. This assignment makes all interactions with MLflow in that compute instance point to Azure Machine Learning by default. For more information, see [Logging functions](https://mlflow.org/docs/latest/tracking/tracking-api.html#logging-functions).
125125

126126
```bash
127127
MLFLOW_TRACKING_URI=$(az ml workspace show --query mlflow_tracking_uri | sed 's/"//g')

0 commit comments

Comments
 (0)