Azure Machine Learning CLI Documentation
Introduction to the Azure ML CLI
The Azure Machine Learning CLI (v2) is a powerful command-line interface that allows you to manage and orchestrate your machine learning workloads on Azure. It provides a consistent and efficient way to interact with Azure Machine Learning resources, from dataset registration to model deployment.
This documentation guides you through the installation, core concepts, and various commands available in the Azure ML CLI. Whether you are a data scientist, ML engineer, or DevOps professional, the CLI is an essential tool for streamlining your ML lifecycle.
Installation
To use the Azure ML CLI, you need to have the Azure CLI installed first. If you don't have it, you can install it from the official Azure CLI documentation.
Once the Azure CLI is installed, you can install the Azure ML extension:
az extension add --name ml
To verify the installation, run:
az ml --version
Getting Started
Before you can use the CLI, you need to log in to your Azure account and set your default subscription:
az login
az account set --subscription
Next, you'll need to configure your Azure ML workspace. This can be done manually or by pointing the CLI to an existing workspace. For creating a new workspace, you can use the az ml workspace create command.
Example Workspace Creation
az ml workspace create --name my-workspace --resource-group my-resource-group --location eastus
After setting up your workspace, you can start interacting with your ML resources.
CLI Commands
The Azure ML CLI is organized into logical groups for managing different aspects of your machine learning projects.
az ml workspace
Manage your Azure Machine Learning workspaces.
az ml workspace create: Create a new workspace.az ml workspace show: Show details of a workspace.az ml workspace list: List workspaces in a subscription or resource group.az ml workspace delete: Delete a workspace.
Show Workspace Details
az ml workspace show --name my-workspace --resource-group my-resource-group
az ml compute
Manage compute resources for your ML workloads.
az ml compute create: Create a compute target (e.g., AmlCompute, Kubernetes).az ml compute show: Show details of a compute target.az ml compute list: List compute targets in a workspace.az ml compute delete: Delete a compute target.
Create a Compute Cluster
az ml compute create --type amlcompute --name cpu-cluster --min-instances 0 --max-instances 4 --resource-group my-resource-group --workspace-name my-workspace
az ml environment
Manage environments for your training and inference jobs.
az ml environment create: Create an environment from a YAML file.az ml environment show: Show details of an environment.az ml environment list: List environments.az ml environment delete: Delete an environment.
az ml job
Submit, manage, and monitor training jobs.
az ml job create: Submit a job (e.g., command, sweep).az ml job show: Show details of a job.az ml job list: List jobs.az ml job stream: Stream logs for a job.az ml job cancel: Cancel a running job.
Submit a Command Job
az ml job create --file jobs/my-command-job.yml
az ml model
Register and manage your trained models.
az ml model create: Register a model.az ml model show: Show details of a model.az ml model list: List registered models.az ml model delete: Delete a model.
az ml data
Register and manage your datasets.
az ml data create: Register a dataset.az ml data show: Show details of a dataset.az ml data list: List datasets.az ml data delete: Delete a dataset.
az ml endpoint
Manage endpoints for model deployment.
az ml endpoint create: Create an endpoint (e.g., online, batch).az ml endpoint show: Show details of an endpoint.az ml endpoint list: List endpoints.az ml endpoint delete: Delete an endpoint.
az ml deployment
Manage deployments associated with endpoints.
az ml deployment create: Create a deployment for an endpoint.az ml deployment show: Show details of a deployment.az ml deployment list: List deployments for an endpoint.az ml deployment delete: Delete a deployment.
Create an Online Endpoint and Deployment
az ml online-endpoint create --name my-online-endpoint --file endpoints/online/my-endpoint.yml
az ml online-deployment create --endpoint my-online-endpoint --name blue --file endpoints/online/my-deployment-blue.yml --all-traffic
Configuration
The Azure ML CLI relies heavily on YAML configuration files for defining resources, jobs, environments, and deployments. This declarative approach promotes reproducibility and version control.
Key configuration concepts include:
- Jobs: Define the steps, scripts, inputs, outputs, and compute for training or batch inference.
- Environments: Specify the Docker image, Conda packages, or pip dependencies required for your code to run.
- Models: Define how a trained model is registered, including its path, type, and framework.
- Datasets: Describe how to access data, whether it's from Azure Blob Storage, ADLS Gen2, or other sources.
- Endpoints & Deployments: Configure the infrastructure for online or batch inference.
Refer to the official Azure ML YAML examples for detailed templates.
Tutorials and Examples
To further your understanding and practical application of the Azure ML CLI, explore the following resources: