Hands-onLesson 14 of 16

Lab: Deploy a Model with Azure DevOps and Azure ML

Promote a validated model through an Azure DevOps pipeline into an Azure ML online endpoint with smoke tests, approvals, and controlled traffic shifting.

🧒 Simple Explanation (ELI5)

This lab teaches the last mile of MLOps: taking a checked model and releasing it safely instead of copying files around and hoping it works.

🔧 Why Do We Need It?

🌍 Real-world Analogy

This is like opening a new restaurant branch with inspections, limited opening hours, and backup plans before a full public launch.

⚙️ Technical Explanation

The deployment pipeline consumes a validated model version, applies endpoint configuration, runs smoke tests, and optionally uses staged traffic movement such as canary deployment. Azure DevOps provides the orchestration and audit trail. Azure ML provides the endpoint and deployment target.

📊 Visual Representation

Deployment Lab Flow
📚 Model v42
🧾 Azure DevOps
🚀 Staging Endpoint
🐤 Prod Canary

⌨️ Commands / Syntax

yaml
stages:
- stage: deploy_staging
  jobs:
  - job: deploy_model
    steps:
    - script: az ml online-deployment create --file deployment.yml
    - script: az ml online-endpoint invoke --name churn-endpoint --request-file sample.json
- stage: deploy_prod
  dependsOn: deploy_staging
  condition: succeeded()
bash
az ml online-endpoint create --name churn-endpoint --file endpoint.yml
az ml online-deployment create --name blue --endpoint churn-endpoint --file deployment.yml
az ml online-endpoint update --name churn-endpoint --traffic blue=100

💼 Example (Real-world Use Case)

A pricing model is deployed to staging after validation. Azure DevOps sends test payloads and confirms response shape, latency, and logging. After approval, production receives 10% of traffic for 30 minutes. Only when KPIs remain healthy does traffic move to 100%.

🧪 Hands-on

  1. Create an endpoint definition and a deployment definition for one model.
  2. Add a smoke test step that sends a request file and checks for a valid response.
  3. Add a production environment approval in Azure DevOps.
  4. Define a canary traffic step and a rollback command.
  5. Record what evidence an approver should see before clicking approve.

🎮 Try It Yourself

🎮
Promotion Drill

Write a mini release checklist for a high-risk model: validation report attached, smoke test passed, staging latency below threshold, approver named, rollback target identified, production traffic set to 10% first. Then note which of those are currently manual and which should be enforced automatically.

🐛 Debugging Scenario

Problem: the pipeline says deployment is complete, but the endpoint returns schema errors to real clients.

🎯 Interview Questions

Beginner

What is the purpose of a smoke test in deployment?

It confirms the endpoint can serve a basic known request after deployment.

Why use staging before production?

Staging reduces risk by checking the deployment in a controlled environment first.

Why use approvals for model deployment?

Approvals create accountability and prevent accidental promotion of risky releases.

What is canary traffic?

Canary traffic is a small percentage of live traffic sent to the new version first.

Why define rollback before release?

Because failures happen fastest when teams are least ready to improvise safely.

Intermediate

What evidence should an approver review?

Validation metrics, smoke test results, drift context, rollback target, and business risk notes.

Why can a deployment pass smoke tests but still fail for users?

Because smoke tests may not represent real traffic shapes, payload variety, or scale.

What is the difference between deploy success and release success?

Deploy success means infrastructure changed successfully; release success means live behavior is acceptable.

Why should traffic shifting be scriptable?

Scriptable traffic changes are repeatable, auditable, and easier to reverse quickly.

What is the biggest deployment anti-pattern in ML?

Equating model registration with production readiness and skipping real deployment checks.

Scenario-based

A canary looks fine technically but increases customer drop-off. What do you do?

Stop promotion, roll back traffic, and investigate business-impact metrics rather than waiting for more harm.

An approver asks why manual review is still needed if the pipeline is automated. How do you answer?

Automation provides evidence quickly, but high-risk business decisions still require accountable human judgment.

A release succeeded in one region but failed in another. Where do you look first?

Look at region-specific configuration, endpoint routing, environment variables, and resource quotas.

What if the smoke test payload is too simple to catch real failures?

Expand test payload coverage to include real edge cases and production-like schemas.

How do you prove this deployment lab is production-ready thinking rather than a demo?

It includes approvals, smoke tests, controlled traffic, and rollback design, which are core production concerns.

🌐 Real-world Usage

Production model deployments in finance, retail, and SaaS often use exactly these patterns: staged rollout, automated checks, and formal approval gates before full exposure.

📝 Summary

This lab converts a validated artifact into a controlled release. Safe deployment is where MLOps proves it is engineering, not just experimentation.