Batch Endpoints
This lesson explains how batch endpoints run jobs, how model and pipeline component deployments differ, and which settings control mini-batches, failures and outputs.
Learning outcomes
After completing this lesson, you will be able to:
- Describe how a batch endpoint processes input.
- Distinguish model deployments from pipeline component deployments.
- Explain error_threshold, retry_settings and output_action.
- Describe how the default deployment is chosen.
How batch endpoints work
A batch endpoint is a stable name and URI that starts batch scoring jobs. Each invocation names the input data, a folder of files, a file or a table, and the endpoint runs a job on its deployment's compute cluster that splits the input, scores it in parallel, and writes the results to a datastore. The caller receives a job name and checks the job's status or waits for an event, rather than waiting for a response.
Batch endpoints themselves are not billed; only the compute that their jobs use is. With a cluster minimum of zero nodes, a batch endpoint costs nothing between invocations, which makes it the economical choice for periodic large-scale scoring.
Model deployments
A model deployment runs a model, with an optional scoring script and environment that MLflow models do not need. Its settings control how the input is divided and processed.
$schema: https://azuremlschemas.azureedge.net/latest/modelBatchDeployment.schema.json
name: churn-batch-v7
endpoint_name: churn-batch
type: model
model: azureml:churn:7
compute: azureml:cpu-cluster
resources:
instance_count: 4
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
error_threshold: -1
logging_level: info| Setting | Meaning |
|---|---|
instance_count | Nodes used for the job |
max_concurrency_per_instance | Scoring processes per node |
mini_batch_size | Files (or rows for tabular input) per call to the scoring script |
output_action | append_row collects results into one output file; summary_only leaves output to the script |
retry_settings | Retries and timeout per mini-batch |
error_threshold | Failed items tolerated before the job fails; -1 ignores all failures |
A batch scoring script also has init(), and its run(mini_batch) receives a list of file paths, or a DataFrame for tabular input, and returns one result per item.
Pipeline component deployments
Some batch scoring needs more than a model: retrieving features from a feature store, preprocessing, scoring and post-processing. A pipeline component deployment deploys a whole pipeline, packaged as a pipeline component, behind the batch endpoint. Each invocation runs the pipeline with the supplied inputs, so the endpoint's callers do not need to know how many steps it has.
Invoking and managing
A batch endpoint is invoked with the CLI, the SDK or a REST call with a Microsoft Entra token. The endpoint's default deployment handles invocations unless one is named, which lets operators switch the deployment behind a schedule or integration without changing callers.
az ml batch-endpoint invoke --name churn-batch \
--input azureml:customers-to-score:12 --input-type uri_folder \
-g rg-ml-prod -w mlw-churn-prod
az ml batch-deployment create --file churn-batch-v8.yml --set-default -g rg-ml-prod -w mlw-churn-prodResults are written by default to the workspace's default datastore under a folder for the job, or to an output path given at invocation. A scheduled pipeline, Azure Data Factory, Microsoft Fabric or a Logic App often invokes batch endpoints, and an Event Grid event on job completion can start downstream processing.
A batch job that fails on bad files
A nightly batch scoring job over 50,000 image files fails after three hours because 12 files are corrupt and the scoring script raises an exception on them. The business would rather receive predictions for the 49,988 good files and a list of failures than no predictions at all.
Set error_threshold to allow failed items, for example to -1 to ignore all failures or to a small positive number to fail only when many items fail, and keep retry_settings for transient errors. Change the scoring script to catch errors per file and log the failing file names, so that the job completes with predictions for the good files and a record of the bad ones.
Increasing instance_count would fail faster but still fail. Increasing the retry count would retry corrupt files that will never succeed. Moving the workload to an online endpoint would not change how corrupt files are handled and would cost more.
A batch job over 10,000 files must tolerate a few corrupt files without failing. Which setting controls this?
Show answer
error_threshold, the number of failed items allowed before the job fails; -1 ignores all failures. retry_settings retries failed mini-batches first.
Exam Tips
Remember for the exam
- Batch endpoints start jobs on clusters; the endpoint itself is free.
- Model deployments split input into mini-batches; pipeline component deployments run whole pipelines.
- error_threshold, retry_settings and output_action control failures and results.
- Invoke with an input; the default deployment serves unless another is named.