Install and set up the CLI (v2)
APPLIES TO: Azure CLI ml extension v2 (current)
ml extension to the Azure CLI is the enhanced interface for Azure Machine Learning. It enables you to train and deploy models from the command line, with features that accelerate scaling data science up and out while tracking the model lifecycle.
- To use the CLI, you must have an Azure subscription. If you don't have an Azure subscription, create a free account before you begin. Try the free or paid version of Azure Machine Learning today.
- To use the CLI commands in this document from your local environment, you need the Azure CLI.
The new Machine Learning extension requires Azure CLI version
>=2.38.0. Ensure this requirement is met:
If it isn't, upgrade your Azure CLI.
Check the Azure CLI extensions you've installed:
az extension list
Remove any existing installation of the
ml extension and also the CLI v1
az extension remove -n azure-cli-ml az extension remove -n ml
Now, install the
az extension add -n ml
Run the help command to verify your installation and see available subcommands:
az ml -h
You can upgrade the extension to the latest version:
az extension update -n ml
Installation on Linux
If you're using Linux, the fastest way to install the necessary CLI version and the Machine Learning extension is:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash az extension add -n ml -y
For more, see Install the Azure CLI for Linux.
If you have access to multiple Azure subscriptions, you can set your active subscription:
az account set -s "<YOUR_SUBSCRIPTION_NAME_OR_ID>"
Optionally, setup common variables in your shell for usage in subsequent commands:
GROUP="azureml-examples" LOCATION="eastus" WORKSPACE="main"
This uses Bash syntax for setting variables -- adjust as needed for your shell. You can also replace the values in commands below inline rather than using variables.
If it doesn't already exist, you can create the Azure resource group:
az group create -n $GROUP -l $LOCATION
And create a machine learning workspace:
az ml workspace create -n $WORKSPACE -g $GROUP -l $LOCATION
Machine learning subcommands require the
--resource-group/-g parameters. To avoid typing these repeatedly, configure defaults:
az configure --defaults group=$GROUP workspace=$WORKSPACE location=$LOCATION
Most code examples assume you have set a default workspace and resource group. You can override these on the command line.
You can show your current defaults using
az configure -l -o table
--output/-o allows for more readable output formats.
ml CLI extension (sometimes called 'CLI v2') for Azure Machine Learning sends operational data (YAML parameters and metadata) over the public internet. All the
ml CLI extension commands communicate with the Azure Resource Manager. This communication is secured using HTTPS/TLS 1.2.
Data in a data store that is secured in a virtual network is not sent over the public internet. For example, if your training data is located in the default storage account for the workspace, and the storage account is in a virtual network.
With the previous extension (
azure-cli-ml, sometimes called 'CLI v1'), only some of the commands communicate with the Azure Resource Manager. Specifically, commands that create, update, delete, list, or show Azure resources. Operations such as submitting a training job communicate directly with the Azure Machine Learning workspace. If your workspace is secured with a private endpoint, that is enough to secure commands provided by the
If your Azure Machine Learning workspace is public (that is, not behind a virtual network), then there is no additional configuration required. Communications are secured using HTTPS/TLS 1.2
Submit and view feedback for