The Azure Machine Learning CLI provides a powerful set of commands to manage experiments, datasets, compute resources, and deployments directly from your terminal.
Install the CLI using pip or conda. The most common method is via pip:
pip install azure-cli
az extension add -n ml
Verify the installation:
az ml -h
Log in to Azure and set your default subscription:
az login
az account set --subscription <subscription-id>
Authenticate the ML extension to your workspace:
az ml workspace set -w <workspace-name> -g <resource-group>
Create a new compute cluster:
az ml compute create -n mycluster -t amlcompute --min-instances 0 --max-instances 4
List compute resources:
az ml compute list
Register a dataset from a storage account:
az ml data create -n mydata -p "{'path':'https://myaccount.blob.core.windows.net/data/train.csv'}"
Download a dataset locally:
az ml data download -n mydata -f ./data/
Register a model artifact:
az ml model create -n mymodel -p ./outputs/model.pkl
List registered models:
az ml model list
Deploy a model as an online endpoint:
az ml endpoint create -n myendpoint -f endpoint.yml
az ml deployment create -e myendpoint -n blue -f deployment.yml
Test the endpoint:
az ml endpoint invoke -n myendpoint -i '{"data": [1,2,3]}'
Run an experiment from a YAML file:
az ml job create -f job.yml
Submit a Python script as a job:
az ml job submit -c mycluster -f script.py --environment azureml:python-3.8
Below is a filtered list of the most frequently used commands. For the full reference, see the CLI Commands page.
| Command | Description |
|---|---|
az ml compute create | Create a new compute target. |
az ml compute list | List compute resources. |
az ml data create | Register a new dataset. |
az ml data download | Download a dataset locally. |
az ml model create | Register a model artifact. |
az ml model list | List models in the workspace. |
az ml endpoint create | Create an online endpoint. |
az ml deployment create | Create a deployment for an endpoint. |
az ml job create | Create a job from a YAML spec. |
az ml job submit | Run a job from a script. |