The 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.
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.38.0. Ensure this requirement is met:
This uses Bash syntax for setting variables. Adjust as needed for your shell. You can also replace the values in commands in the following examples 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 --workspace/-w and --resource-group/-g parameters. To avoid typing these repeatedly, configure defaults:
az configure --defaults group=$GROUP workspace=$WORKSPACE location=$LOCATION
Tip
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 --list-defaults/-l:
az configure -l -o table
Tip
Combining with --output/-o allows for more readable output formats.
Secure communications
The 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 isn't_ 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.
Note
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 azure-cli-ml extension.
If your Azure Machine Learning workspace is public (that is, not behind a virtual network), then there's no extra configuration required. Communications are secured using HTTPS/TLS 1.2
If your Azure Machine Learning workspace uses a private endpoint and virtual network, choose one of the following configurations to use:
If you're OK with the CLI v2 communication over the public internet, use the following --public-network-access parameter for the az ml workspace update command to enable public network access. For example, the following command updates a workspace for public network access:
az ml workspace update --name myworkspace --public-network-access enabled
If you are not OK with the CLI v2 communication over the public internet, you can use an Azure Private Link to increase security of the communication. Use the following links to secure communications with Azure Resource Manager by using Azure Private Link.
To configure the private link for Azure Resource Manager, you must be the subscription owner for the Azure subscription, and an owner or contributor of the root management group. For more information, see Create a private link for managing Azure resources.
Manage data ingestion and preparation, model training and deployment, and machine learning solution monitoring with Python, Azure Machine Learning and MLflow.