Install and set up the CLI (v2)

The ml extension (preview) 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.

Important

This feature is currently in public preview. This preview version is provided without a service-level agreement, and it's not recommended for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

Prerequisites

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

Installation

The new Machine Learning extension requires Azure CLI version >=2.15.0. Ensure this requirement is met:

az version

If it isn't, upgrade your Azure CLI.

Check the Azure CLI extensions you've installed:

az extension list

Ensure no conflicting extension using the ml namespace is installed, including the azure-cli-ml extension:

az extension remove -n azure-cli-ml
az extension remove -n ml

Now, install the ml extension:

az extension add -n ml -y

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.

Set up

Login:

az login

If you have access to multiple Azure subscriptions, you can set your active subscription:

az account set -s "<YOUR_SUBSCRIPTION_NAME_OR_ID>"

If it doesn't already exist, you can create the Azure resource group:

az group create -n "azureml-examples-rg" -l "eastus"

Machine learning subcommands require the --workspace/-w and --resource-group/-g parameters. To avoid typing these repeatedly, configure defaults:

az configure --defaults group="azureml-examples-rg" workspace="main"

Tip

Most code examples assume you have set a default workspace and resource group. You can override these on the command line.

Now create the machine learning workspace:

az ml workspace create

Next steps