API Reference
Explore the comprehensive API reference for Azure AI Machine Learning. This section provides detailed documentation for the various tools and services that enable you to build, train, and deploy machine learning models on Azure.
Azure ML SDK
The Azure Machine Learning SDK for Python allows you to interact with Azure ML services programmatically. Discover classes, methods, and functions for managing experiments, datasets, models, and deployments.
azureml.core.Experiment.create()
Experiment.create(name: str, workspace: Workspace) -> ExperimentCreates a new experiment in the specified Azure Machine Learning workspace. If an experiment with the given name already exists, it will be returned.
Parameters
| name | Type | Description |
|---|---|---|
| name | str |
The name of the experiment. |
| workspace | Workspace |
The Azure Machine Learning workspace to create the experiment in. |
Returns
| Type | Description |
|---|---|
Experiment |
The created or existing experiment object. |
from azureml.core import Workspace, Experiment
# Load the workspace
ws = Workspace.from_config()
# Create an experiment
experiment = Experiment.create(name='my-ml-experiment', workspace=ws)
print(f"Experiment '{experiment.name}' created.")
azureml.core.Run.submit()
Run.submit(experiment: Experiment, ...) -> RunSubmits a new run to the specified experiment. This can be a script run, a pipeline run, or a distributed training run.
Parameters
| experiment | Type | Description |
|---|---|---|
| experiment | Experiment |
The experiment to submit the run to. |
| config | ScriptRunConfig or similar |
Configuration for the run (e.g., script, environment, compute target). |
from azureml.core import Workspace, Experiment, ScriptRunConfig
from azureml.core.compute import ComputeTarget
# Load workspace and get compute target
ws = Workspace.from_config()
compute_target = ws.compute_targets['cpu-cluster']
# Define the script run configuration
src = ScriptRunConfig(source_directory='.', script='train.py', compute_target=compute_target)
# Submit the run
experiment_name = 'my-training-runs'
exp = Experiment(workspace=ws, name=experiment_name)
run = exp.submit(src)
print(f"Submitted run: {run.id}")
Azure ML REST API
Interact with Azure Machine Learning services using its comprehensive REST API. This is useful for integrating Azure ML into custom applications, CI/CD pipelines, or for use with languages other than Python.
POST /endpoints
POST /endpoints?api-version=2023-08-15Creates a new managed online endpoint in your Azure Machine Learning workspace. Endpoints are the entry points for real-time inferencing.
Request Body Schema
{
"name": "my-online-endpoint",
"description": "An endpoint for my real-time predictions",
"auth_mode": "key",
"tags": {
"environment": "production"
},
"properties": {
"compute_type": "managed"
}
}
curl --request POST \
--url 'https://[your-workspace-name].api.azureml.ms/[api-version]/endpoints' \
--header 'Authorization: Bearer [your-access-token]' \
--header 'Content-Type: application/json' \
--data '{
"name": "my-online-endpoint",
"description": "An endpoint for my real-time predictions",
"auth_mode": "key",
"tags": {
"environment": "production"
},
"properties": {
"compute_type": "managed"
}
}'
Azure ML CLI (v2)
Manage your Azure ML resources using the Azure CLI extension for Machine Learning. This command-line interface provides a powerful and flexible way to orchestrate your ML workflows.
az ml job create
az ml job create -f <job-yaml-file> --resource-group <rg-name> --workspace <workspace-name>Creates and submits a job (command, sweep, pipeline) based on a YAML configuration file.
Parameters
| Parameter | Description |
|---|---|
| -f, --file | Path to the YAML file defining the job. |
| --resource-group, -g | The Azure resource group name. |
| --workspace, -w | The Azure ML workspace name. |
# Example job.yml
# type: command
# name: my_training_job
# code: ./src
# command: python train.py --input-data ${{inputs.training_data}}
# environment: azureml:AzureML-Minimal@latest
# compute: azureml:cpu-cluster
# inputs:
# training_data:
# type: uri_folder
# path: azureml://datastores/workspaceblobstore/paths/datasets/mydata/train
az ml job create -f job.yml -g my-resource-group -w my-workspace