Skip to main content

Azure Machine Learning REST API

The Azure Machine Learning REST API enables you to create, manage, and deploy machine learning models using standard HTTP verbs. The API supports workspace management, model registration, online endpoints, and job execution.

Authentication

Azure Machine Learning REST API uses OAuth2 service principal authentication.

Retrieve Authentication Token

1

Get Service Principal Credentials

Obtain your tenant ID, client ID, and client secret from your Azure service principal.
2

Request Access Token

curl -X POST https://login.microsoftonline.com/<TENANT-ID>/oauth2/token \
  -d "grant_type=client_credentials&resource=https%3A%2F%2Fmanagement.azure.com%2F&client_id=<CLIENT-ID>&client_secret=<CLIENT-SECRET>"
3

Use Token in Requests

Include the token in the Authorization header:
Authorization: Bearer <ACCESS-TOKEN>
Token Response:
{
  "token_type": "Bearer",
  "expires_in": "3599",
  "access_token": "YOUR-ACCESS-TOKEN"
}

Base URL

https://management.azure.com

Workspaces

List Workspaces

Retrieve all Azure Machine Learning workspaces in a resource group. Endpoint:
GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces?api-version=2023-10-01
subscriptionId
string
required
Your Azure subscription ID
resourceGroupName
string
required
Name of the resource group
Response:
{
  "value": [
    {
      "id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.MachineLearningServices/workspaces/my-workspace",
      "name": "my-workspace",
      "type": "Microsoft.MachineLearningServices/workspaces",
      "location": "centralus",
      "properties": {
        "friendlyName": "My Workspace",
        "creationTime": "2023-01-03T19:56:09.7588299+00:00",
        "workspaceId": "cba12345-abab-abab-abab-ababab123456",
        "discoveryUrl": "https://centralus.experiments.azureml.net/discovery"
      }
    }
  ]
}

Create Workspace

Create a new Azure Machine Learning workspace. Endpoint:
PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}?api-version=2023-10-01
location
string
required
Azure region for the workspace
properties.storageAccount
string
required
Resource ID of the Azure Storage account
properties.keyVault
string
required
Resource ID of the Azure Key Vault
properties.applicationInsights
string
required
Resource ID of Application Insights
Request:
{
  "location": "eastus",
  "identity": {
    "type": "systemAssigned"
  },
  "properties": {
    "friendlyName": "My ML Workspace",
    "description": "Production workspace",
    "storageAccount": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Storage/storageAccounts/{storageAccount}",
    "keyVault": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Keyvault/vaults/{keyVault}",
    "applicationInsights": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.insights/components/{appInsights}"
  }
}

Models

Register Model

Register a trained model in your workspace. Endpoint:
PUT https://{region}.api.azureml.ms/modelmanagement/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/models/{modelId}?api-version=2023-10-01
modelId
string
required
Unique identifier for the model
name
string
required
Model name
version
integer
required
Model version number
path
string
required
Path to model files in datastore

List Models

Retrieve all registered models in a workspace. Endpoint:
GET https://{region}.api.azureml.ms/modelmanagement/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/models?api-version=2023-10-01

Online Endpoints

Create Online Endpoint

Deploy a model to an online endpoint for real-time inference. Endpoint:
PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/onlineEndpoints/{endpointName}?api-version=2024-04-01
name
string
required
Endpoint name (must be unique in the region)
properties.authMode
string
Authentication mode: Key or AADToken
properties.compute
string
required
Compute resource for the endpoint
Request:
{
  "name": "my-endpoint",
  "location": "eastus",
  "properties": {
    "authMode": "Key",
    "description": "Production endpoint"
  }
}

Create Deployment

Create a deployment under an online endpoint. Endpoint:
PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/onlineEndpoints/{endpoint}/deployments/{deploymentName}?api-version=2024-04-01
model
string
required
Resource ID of the registered model
codeConfiguration
object
Scoring script configuration:
  • codeId: Resource ID of the code
  • scoringScript: Name of the scoring script
instanceType
string
required
VM size (e.g., Standard_DS3_v2)
instanceCount
integer
required
Number of instances

Invoke Endpoint

Score data using a deployed model. Endpoint:
POST https://{endpoint-uri}/score
Authorization
string
required
Bearer token or endpoint key
Content-Type
string
required
application/json
Request:
{
  "data": [
    [1, 2, 3, 4, 5],
    [6, 7, 8, 9, 10]
  ]
}

Jobs

Create Training Job

Submit a training job to Azure Machine Learning. Endpoint:
PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/jobs/{jobId}?api-version=2024-04-01
properties.jobType
string
required
Job type: Command, Sweep, Pipeline
properties.compute
string
required
Compute resource ID
properties.command
string
required
Command to execute
properties.environment
string
required
Environment resource ID

Get Job Status

Retrieve job details and status. Endpoint:
GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/jobs/{jobId}?api-version=2024-04-01
Response:
{
  "id": "job-id",
  "name": "training-job",
  "properties": {
    "status": "Completed",
    "startTime": "2024-01-15T10:30:00Z",
    "endTime": "2024-01-15T11:45:00Z",
    "jobType": "Command"
  }
}

List Jobs

Get all jobs in a workspace. Endpoint:
GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/jobs?api-version=2024-04-01

Compute

Create Compute Resource

Provision a compute cluster for training. Endpoint:
PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/computes/{computeName}?api-version=2023-10-01
properties.computeType
string
required
Compute type: AmlCompute, ComputeInstance, AKS
properties.properties.vmSize
string
required
VM size (e.g., Standard_D1)
properties.properties.scaleSettings
object
required
Scaling configuration:
  • minNodeCount: Minimum nodes
  • maxNodeCount: Maximum nodes
  • nodeIdleTimeBeforeScaleDown: Idle time before scale down
Request:
{
  "location": "eastus",
  "properties": {
    "computeType": "AmlCompute",
    "properties": {
      "vmSize": "Standard_D1",
      "vmPriority": "Dedicated",
      "scaleSettings": {
        "maxNodeCount": 4,
        "minNodeCount": 0,
        "nodeIdleTimeBeforeScaleDown": "PT30M"
      }
    }
  }
}

List Compute Resources

Endpoint:
GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/computes?api-version=2023-10-01

API Versioning

Always specify the api-version parameter. Current stable version: 2023-10-01
The API version ensures compatibility as the service evolves. Different services may use different versions.

Error Responses

All errors follow Azure standard error format:
{
  "error": {
    "code": "ResourceNotFound",
    "message": "The specified resource was not found",
    "details": []
  }
}

Python SDK

Use the Python SDK for Azure ML

Azure CLI

Command-line interface for Azure ML

Build docs developers (and LLMs) love