Azure Machine Learning

Azure Machine Learning (Azure ML)

Azure Machine Learning is Microsoft's managed ML platform for training, tracking, deploying, and monitoring models. It covers the full classical-ML lifecycle — data preparation, AutoML, hyperparameter sweeps, distributed training, managed endpoints, and MLOps pipelines — and underpins Azure AI Foundry's generative-AI tooling.


Core Concepts:


Examples

1. Submit a Training Job (Python SDK v2)


from azure.ai.ml import MLClient, command, Input
from azure.ai.ml.constants import AssetTypes
from azure.identity import DefaultAzureCredential

ml = MLClient(DefaultAzureCredential(),
              subscription_id="<sub>", resource_group_name="<rg>",
              workspace_name="my-aml-ws")

job = command(
    code="./src",                                   # folder with train.py
    command="python train.py --data ${{inputs.data}} --epochs 10",
    environment="azureml://registries/azureml/environments/sklearn-1.5/versions/latest",
    compute="cpu-cluster",
    inputs={"data": Input(type=AssetTypes.URI_FOLDER, path="azureml:titanic:1")},
    experiment_name="titanic-gbm",
    display_name="gbm-sweep-base",
)
returned = ml.jobs.create_or_update(job)
print(returned.studio_url)
  

2. Hyperparameter Sweep


from azure.ai.ml.sweep import Choice, Uniform

sweep = job.sweep(
    compute="cpu-cluster",
    sampling_algorithm="bayesian",
    primary_metric="val_auc",
    goal="Maximize",
    max_total_trials=20,
    max_concurrent_trials=4,
)
sweep.search_space = {
    "learning_rate": Uniform(min_value=0.01, max_value=0.3),
    "max_depth":     Choice(values=[3, 5, 7, 9]),
}
ml.jobs.create_or_update(sweep)
  

3. AutoML for Tabular Classification


from azure.ai.ml import automl, Input
from azure.ai.ml.constants import AssetTypes

automl_job = automl.classification(
    compute="cpu-cluster",
    experiment_name="churn-automl",
    training_data=Input(type=AssetTypes.MLTABLE, path="azureml:churn-train:1"),
    target_column_name="churned",
    primary_metric="AUC_weighted",
    n_cross_validations=5,
    enable_model_explainability=True,
)
automl_job.set_limits(timeout_minutes=60, max_trials=30, max_concurrent_trials=4)
ml.jobs.create_or_update(automl_job)
  

4. Deploy to a Managed Online Endpoint


from azure.ai.ml.entities import ManagedOnlineEndpoint, ManagedOnlineDeployment, Model, Environment

endpoint = ManagedOnlineEndpoint(name="churn-endpoint", auth_mode="key")
ml.online_endpoints.begin_create_or_update(endpoint).result()

deployment = ManagedOnlineDeployment(
    name="blue",
    endpoint_name="churn-endpoint",
    model=Model(path="azureml:churn-gbm:3"),
    environment=Environment(image="mcr.microsoft.com/azureml/inference-base:latest"),
    instance_type="Standard_DS3_v2",
    instance_count=1,
)
ml.online_deployments.begin_create_or_update(deployment).result()
ml.online_endpoints.begin_update(ManagedOnlineEndpoint(name="churn-endpoint", traffic={"blue": 100})).result()
  

5. Pipeline Job — Prep → Train → Register


from azure.ai.ml import dsl, Input, Output

prep  = command(code="./prep",  command="python prep.py --in ${{inputs.raw}} --out ${{outputs.clean}}",
                environment="...", inputs={"raw": Input(type="uri_folder")},
                outputs={"clean": Output(type="uri_folder")})
train = command(code="./train", command="python train.py --data ${{inputs.data}}",
                environment="...", inputs={"data": Input(type="uri_folder")},
                outputs={"model": Output(type="uri_folder")})

@dsl.pipeline(compute="cpu-cluster")
def churn_pipeline(raw_data):
    p = prep(raw=raw_data)
    t = train(data=p.outputs.clean)
    return {"model": t.outputs.model}

pipeline_job = churn_pipeline(raw_data=Input(type="uri_folder", path="azureml:raw-churn:1"))
ml.jobs.create_or_update(pipeline_job)
  

When to Use Azure ML vs. Foundry vs. OpenAI Service:

Architecture

Azure ML Workspace Architecture Data assetsBlob, ADLS, OneLake EnvironmentsDocker / Conda Computeclusters, serverless Jobscommand, sweep, pipeline MLflow trackingmetrics, artifacts Model registryversions, lineage Online endpointreal-time REST Batch endpointscored files Monitoringdrift, data quality The workspace also links a storage account, a key vault, a container registry and Application Insights, which are created alongside it and hold artifacts, secrets, images and telemetry.

Everything in Azure ML hangs off a workspace. Data assets point to data that stays in its storage service; jobs mount or download it at run time. An environment pins the container image and packages, and compute supplies the machines: compute instances for notebooks, auto-scaling clusters that scale to zero when idle, attached Kubernetes, or serverless compute where Azure provisions the nodes per job. A job combines code, environment, compute and inputs. Metrics and artifacts are logged through MLflow, which is the native tracking API in SDK v2, so standard mlflow.log_metric calls work unchanged. Trained models are registered with lineage back to the job that produced them and served through managed endpoints.

Access is controlled with Azure role-based access control at the workspace level, and jobs authenticate to data with either the submitting user's identity or a managed identity attached to the compute, which avoids storing storage keys in code.

Same Job with the CLI and YAML

# job.yml
$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
code: ./src
command: python train.py --data ${{inputs.data}} --epochs 10
inputs:
  data:
    type: uri_folder
    path: azureml:titanic:1
environment: azureml://registries/azureml/environments/sklearn-1.5/versions/latest
compute: azureml:cpu-cluster
experiment_name: titanic-gbm
az extension add -n ml
az ml job create -f job.yml -g my-rg -w my-aml-ws --stream
az ml model create --name churn-gbm --path azureml://jobs/<job-name>/outputs/artifacts/paths/model/ --type mlflow_model -g my-rg -w my-aml-ws
az ml online-endpoint invoke --name churn-endpoint --request-file sample.json -g my-rg -w my-aml-ws

The YAML and the Python SDK are two views of the same resource definitions, so teams often keep YAML files in Git and submit them from CI. The ${{inputs.data}} syntax is resolved by Azure ML on the compute target, not by the shell.

MLOps and Deployment

MLOps Promotion Path Dev workspacetrain + evaluate Register modelmetrics attached Shared registrycross-workspace Prod endpointblue deployment Traffic shiftgreen 10% to 100% Registries let a model trained in dev be deployed in prod without copying files; endpoints split traffic between deployments.

A managed online endpoint is a stable URL with key or Microsoft Entra token authentication; behind it sit one or more deployments, each with its own model version, environment, instance type and count. Traffic can be split between deployments for blue/green or canary releases, and mirrored traffic lets a new deployment receive a copy of live requests without affecting responses. Batch endpoints run scoring jobs over files on a compute cluster. Pipelines chain components (reusable, versioned steps) so data preparation, training and evaluation run as one reproducible graph, and schedules or Azure DevOps and GitHub Actions trigger them.

When to Use Azure ML

OptionBest forTrade-off
Azure Machine Learningcustom training, AutoML, governed MLOps on Azureplatform concepts to learn; several linked resources
Azure AI Foundrygenerative AI apps, model catalog, agents, evaluationless focused on classical tabular training
Azure OpenAI Servicecalling OpenAI models directlyno custom training beyond fine-tuning
Databricks on AzureSpark-heavy data engineering plus MLseparate workspace and billing model
AWS SageMaker / Vertex AIequivalent platforms on other cloudscloud lock-in either way

Pitfalls