Implement Machine Learning Model Lifecycle and Operations · Topic 4 of 5
Online and Batch Endpoints, Testing and Safe Rollout
AI-300 lifecycle: deploy models to online and batch endpoints, test and troubleshoot them, and roll out with blue green traffic, mirroring and rollback.
- 5 min
- Includes a diagram
- Endpoint equals URL; deployment equals model plus compute; traffic is split per deployment.
- Traffic percentages must add up to 100; mirrored traffic does not.
- Mirror traffic is at most 50 percent and its responses are discarded.
What it is
An endpoint is a stable URL; a deployment is the model, code and compute behind it. One endpoint can hold several deployments and split traffic between them. Managed online endpoints serve low latency, synchronous requests. Batch endpoints score large datasets asynchronously. Both are managed: Azure patches the hosts, scales and recovers nodes for you.
How it works
Online endpoint and deployment
# endpoint.yml
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineEndpoint.schema.json
name: churn-endpoint
auth_mode: key
# blue.yml
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json
name: blue
endpoint_name: churn-endpoint
model: azureml:churn-model:4
instance_type: Standard_DS3_v2
instance_count: 2
az ml online-endpoint create --file endpoint.yml
az ml online-deployment create --file blue.yml --all-traffic
az ml online-endpoint invoke --name churn-endpoint --request-file sample.json
For an MLflow model nothing else is needed. For a custom model add code_configuration (a scoring script with init() and run()) and an environment. Online endpoints use key or aml_token authentication. Scale out with more instances or Azure Monitor autoscale rules; tune request_settings (timeouts, concurrency) and liveness_probe / readiness_probe for slow starting models.
Batch endpoint
$schema: https://azuremlschemas.azureedge.net/latest/modelBatchDeployment.schema.json
name: nightly
endpoint_name: churn-batch
type: model
model: azureml:churn-model:4
compute: azureml:cpu-cluster
resources:
instance_count: 2
settings:
max_concurrency_per_instance: 2
mini_batch_size: 10
output_action: append_row
output_file_name: predictions.csv
retry_settings:
max_retries: 3
timeout: 300
az ml batch-endpoint invoke --name churn-batch --input azureml:churn-new:1
| Online endpoint | Batch endpoint | |
|---|---|---|
| Latency | Milliseconds, one request at a time | Minutes or hours |
| Input | JSON request | Data asset or folder of files |
| Compute | Always on instances | Cluster that scales to zero |
| Use for | Apps, APIs | Nightly scoring, large backfills |
For batch, a mini batch is the unit of work, and output_action: append_row merges results into one file.
Test and troubleshoot
- Test one deployment before it gets traffic:
az ml online-endpoint invoke --deployment-name green .... - Debug locally with the
--localflag on create commands before paying for cloud compute. - Read container logs:
az ml online-deployment get-logs --name blue --endpoint-name churn-endpoint --lines 100. Add--container storage-initializerto see model download problems. - Common causes: a failing
init()in the scoring script, a missing package in the environment, not enough quota for the VM size, or the managed identity lacking access to the model or registry. - Status codes: 401 authentication or expired token, 404 no valid deployment with positive traffic, 408 request timeout, 424 error returned by the model container, 429 too many pending requests or rate limited (add instances or retry with backoff), 503 a spike in requests that autoscale cannot follow.
Use Application Insights and endpoint metrics (request latency, requests per minute, CPU and memory) to see the problem pattern.
Progressive rollout and rollback

- Create a new deployment (
green) without--all-traffic; it receives 0 percent. - Test it by deployment name.
- Optionally mirror a share of live traffic to it:
az ml online-endpoint update --name churn-endpoint --mirror-traffic "green=10". Mirrored requests are copied to green but only blue's response reaches the caller. Mirroring is limited to 50 percent. - Shift live traffic gradually:
--traffic "blue=90 green=10", then 50/50, then 0/100. - Roll back instantly with
--traffic "blue=100 green=0". Keep blue until green is proven, then delete it.
A worked example
Version 5 is deployed as green with 0 percent. After a clean mirror at 10 percent, traffic goes 10, 50 and 100 percent while latency and error alerts are watched. At 50 percent the error rate rises, so traffic returns to blue in one command and green is debugged offline.
How the exam asks about this
- "Test new model on real traffic without affecting users." Mirror traffic to the new deployment.
- "Gradually move users to a new version and revert fast." Blue/green deployments with traffic percentages.
- "Score 20 million rows overnight at lowest cost." A batch endpoint on a cluster that scales to zero.
What to remember for the exam
- Endpoint equals URL; deployment equals model plus compute; traffic is split per deployment.
- Traffic percentages must add up to 100; mirrored traffic does not.
- Mirror traffic is at most 50 percent and its responses are discarded.
get-logsand--localare the troubleshooting tools.- Online uses key or aml_token auth; batch uses Microsoft Entra auth.
Deleting the old deployment too early removes your instant rollback.
Common mistakes
Using --all-traffic on the new deployment. That sends all users to an untested version at once.
Choosing online for huge offline jobs. Always on instances cost more than a batch cluster.
Ignoring quota. A deployment fails to start if the subscription lacks cores for the VM size.
Check yourself
How do you send 10 percent of copied live traffic to a new deployment?
Set
--mirror-traffic "green=10"on the endpoint.Which command shows container startup errors?
az ml online-deployment get-logsfor the deployment.When is a batch endpoint the better choice?
When scoring large datasets asynchronously with no low latency requirement.
Topic 4 of 5 in Implement Machine Learning Model Lifecycle and Operations
Test yourself on Implement Machine Learning Model Lifecycle and Operations
The full Microsoft AI-300 question bank has 650 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Microsoft. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.