Lesson 1 of 2 Testing, Troubleshooting and Safe Rollout

Testing and Troubleshooting Endpoints

This lesson explains how scoring scripts and deployments are tested before they receive traffic, where logs are found, and what common deployment errors mean.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish the inference HTTP server from local endpoints.
  • Describe how to test a deployment with no traffic.
  • Identify the logs for model download and inference.
  • Diagnose common deployment errors.

Testing locally

Deploying to Azure takes several minutes, so finding a bug in the scoring script there is slow. Two local options shorten the loop. The Azure Machine Learning inference HTTP server, installed with pip install azureml-inference-server-http, runs the scoring script in a local Python process without Docker; azmlinfsrv --entry_script score.py starts it, and requests can be sent to it on port 5001. A local endpoint, created with --local, builds the deployment's container with Docker on the developer's machine.

az ml online-endpoint create --file endpoint.yml --local
az ml online-deployment create --file blue.yml --local
az ml online-endpoint invoke --name churn-ep --request-file sample.json --local
az ml online-deployment get-logs --name blue --endpoint-name churn-ep --local

Local endpoints need Docker Engine, support one deployment per endpoint and do not support traffic rules, authentication or probe settings. They are for checking that the container builds and the script works, not for testing release behaviour.

Testing in Azure before traffic

A deployment can be created with 0 percent of traffic and tested directly. az ml online-endpoint invoke with --deployment-name sends a request to that deployment, and a client can do the same by adding the azureml-model-deployment header to its request. Both bypass the endpoint's traffic rules, so the deployment can be checked with real infrastructure, authentication and networking while users still reach the current deployment.

az ml online-deployment create --file green.yml -g rg-ml-prod -w mlw-churn-prod
az ml online-endpoint invoke --name churn-ep --deployment-name green \
  --request-file tests/sample.json -g rg-ml-prod -w mlw-churn-prod

A release workflow typically runs a smoke test like this, then a set of known inputs with expected outputs, then a short load test, before it gives the deployment any live traffic.

Logs

az ml online-deployment get-logs returns the inference server container's logs, which show the output of init() and run(), including Python tracebacks. --container storage-initializer returns the logs of the container that downloads the model and code before the server starts, which is where model download and permission problems appear. --lines limits how many lines are returned.

az ml online-deployment get-logs --name green --endpoint-name churn-ep --lines 200 -g rg-ml-prod -w mlw-churn-prod
az ml online-deployment get-logs --name green --endpoint-name churn-ep --container storage-initializer -g rg-ml-prod -w mlw-churn-prod

For running deployments, Azure Monitor metrics (requests, latency, errors, CPU, memory, instance counts) and logs sent to a Log Analytics workspace through diagnostic settings show behaviour over time, and Application Insights can hold custom logs from the scoring script.

Common errors

Deployment errors fall into a few groups, each with a characteristic cause. The following table lists the ones the exam expects you to recognize, then the common HTTP status codes from a running deployment.

ErrorUsual causeWhere to look
ImageBuildFailureThe environment's image could not be built: conflicting packages, registry access, or no image build compute in a private workspaceBuild log in the studio
OutOfQuotaNot enough cores for the instance type and count, including the 20 percent upgrade reserveQuota page; reduce instances or request quota
BadArgumentInvalid settings, or the model or image cannot be downloaded, for example because the identity lacks accessError message; storage-initializer logs
ResourceNotReadyThe container starts but crashes or never becomes ready, often because init() failsInference server logs
ResourceNotFoundA referenced resource such as the model, environment or compute does not existAsset names and versions
StatusMeaning
401Missing or invalid credentials
404Wrong endpoint URI or deployment name
408The request exceeded request_timeout_ms
424The scoring script raised an error while handling the request
429More concurrent requests than the deployment allows, or the bandwidth limit was exceeded
503The deployment is scaling or cannot handle the load
Worked example

A deployment that never becomes ready

A new deployment fails after 20 minutes with a ResourceNotReady error. The storage-initializer logs show that the model downloaded successfully. The inference server logs show a FileNotFoundError for model.pkl raised from init(). The model was registered from a job output folder named outputs.

The model files are present, but the scoring script looks for them at the wrong path. AZUREML_MODEL_DIR points to the folder that contains the registered model's files, and the job registered its output folder, so the file is under a subfolder. Correct the path in init(), for example by joining the subfolder name or searching the directory, test it with the inference HTTP server or a local endpoint, and redeploy.

Requesting more quota addresses OutOfQuota, not a crashing container. Granting the endpoint identity more storage rights would not help, because the download succeeded. Increasing the readiness probe delay would only make the failure take longer.

Check yourself

How can a new deployment be tested on an endpoint before any traffic is allocated to it?

Show answer

Invoke it directly with --deployment-name in the CLI, or with the azureml-model-deployment header, which routes to the named deployment regardless of traffic settings.

Exam Tips

Remember for the exam

  • Test scoring scripts with the inference HTTP server (no Docker) or a local endpoint (--local, needs Docker).
  • Test a deployment before traffic with --deployment-name or the azureml-model-deployment header.
  • get-logs shows inference server logs; --container storage-initializer shows download logs.
  • ImageBuildFailure, OutOfQuota, BadArgument and ResourceNotReady each point to a different cause.