Azure
Build, deploy, secure, scale, and monitor production AI systems with Microsoft Azure.
A model running on a developer's computer cannot reliably serve a production workload. It needs durable data storage, repeatable environments, scalable compute, controlled releases, security, and operational ownership. Microsoft Azure provides these capabilities as managed cloud services, reducing the need to own physical infrastructure.
Azure can support the entire MLOps lifecycle: ingesting and governing data, tracking experiments, training models, registering approved assets, serving predictions, observing behavior, and feeding verified outcomes into retraining. Begin with requirements rather than choosing services by popularity, and confirm current features, quotas, and regional availability before implementation.
Azure Capability Map
| Capability | Common Azure services | Typical MLOps use |
|---|---|---|
| Object and lake storage | Azure Blob Storage, Azure Data Lake Storage | Datasets, model artifacts, features, outputs, and backups |
| Virtual machines | Azure Virtual Machines, VM Scale Sets | Custom training or inference with operating-system control |
| Container registry | Azure Container Registry | Versioned and scanned training or serving images |
| Container execution | Azure Container Apps, Azure Kubernetes Service | Prediction APIs, workers, jobs, and model servers |
| Serverless compute | Azure Functions | Lightweight event-driven processing and workflow glue |
| Managed machine learning | Azure Machine Learning | Experiments, pipelines, registries, training, endpoints, and monitoring |
| Generative AI platform | Microsoft Foundry | Foundation-model applications, agents, evaluation, and GenAIOps capabilities |
| Messaging and events | Azure Service Bus, Event Grid, Event Hubs | Queues, event routing, and streaming ingestion |
| Workflow and integration | Azure Logic Apps, Data Factory, Machine Learning pipelines | Business integration and data or ML orchestration |
| Observability | Azure Monitor, Log Analytics, Application Insights | Metrics, logs, traces, alerts, and application behavior |
| Identity and secrets | Microsoft Entra ID, managed identities, Azure Key Vault | Authentication, workload access, keys, certificates, and secrets |
| Infrastructure as code | Bicep, ARM templates | Repeatable and reviewed Azure environments |
Core Infrastructure
Blob Storage and Data Lake Storage
Blob Storage holds unstructured objects such as raw data, trained models, images, documents, and inference results. Data Lake Storage adds a hierarchical namespace suited to analytics workloads. Use immutable or uniquely versioned paths, lifecycle and retention policies, encryption, private access where needed, and metadata that links every training run to its exact inputs.
Azure Virtual Machines
Virtual Machines provide control over the operating system, drivers, accelerators, and serving stack. They suit specialized workloads, but the team owns patching, image maintenance, capacity, and host resilience. VM Scale Sets can add or remove similar instances, but scaling must account for model download and warm-up time.
Container Registry, Container Apps, and AKS
Azure Container Registry stores versioned container images. Azure Container Apps offers a managed environment for containerized APIs, workers, and jobs. Azure Kubernetes Service (AKS) is appropriate when Kubernetes features, portability, specialized scheduling, or platform standards justify its additional operational work. Pin image digests, scan dependencies, run as a non-root user, and promote the same tested image between environments.
Azure Functions
Functions are useful for short event-driven operations such as validating a blob upload, enriching metadata, publishing an event, or initiating a pipeline. Evaluate execution time, package size, cold starts, concurrency, memory, and accelerator needs before selecting serverless inference for a model.
Azure Machine Learning
Azure Machine Learning is the managed platform for developing, training, registering, deploying, and managing machine learning assets. Workspaces organize jobs, data, models, components, environments, compute, and endpoints. Registries help share and promote versioned assets across workspaces, while pipelines turn repeatable processing, training, evaluation, and registration steps into an auditable workflow.
For online serving, register the model and environment, then deploy a version behind an online endpoint. Managed online endpoints support production capabilities such as autoscaling, traffic allocation, monitoring integration, and safe rollout. Batch endpoints are better for large offline scoring jobs that do not need an immediate response.
Microsoft Foundry and GenAIOps
Microsoft Foundry provides services for building and operating generative-AI applications. MLOps practices still apply, but GenAIOps expands the release unit to include the foundation model or deployment, prompts, retrieval configuration, indexes, tools, safety policies, evaluators, and application code. Test quality, groundedness, safety, tool authorization, latency, quotas, and token cost before promotion.
Choose an Inference Pattern
| Pattern | Good fit | Important concerns |
|---|---|---|
| Managed online endpoint | Interactive model predictions | Tail latency, autoscaling, authentication, and traffic splitting |
| Container API | Custom FastAPI or model-server workloads | Health probes, revisions, scaling, and dependency management |
| Asynchronous queue and worker | Long-running or bursty predictions | Idempotency, queue delay, retries, and result tracking |
| Batch endpoint or job | Scheduled scoring over stored datasets | Partitioning, throughput, reproducibility, and partial failures |
| Streaming inference | Continuous events or telemetry | Ordering, checkpointing, backpressure, schemas, and late events |
| Edge inference | Offline or device-local decisions | Hardware limits, model updates, security, and telemetry |
Reference MLOps Flow
Versioned data in Blob Storage or Data Lake
-> Data validation and feature preparation
-> Azure Machine Learning training pipeline
-> Evaluation against quality, safety, latency, and cost gates
-> Versioned model and environment in a registry
-> Staging deployment and production-like tests
-> Canary or blue/green release to an online endpoint
-> Azure Monitor + Application Insights + model/outcome monitoring
-> Reviewed feedback and controlled retrainingThe unit of release should be a compatible bundle: model, preprocessing, schema, code, container or environment, configuration, and policy. Never promote an ambiguous file named latest. Retain lineage from production predictions back to the exact model, data, source commit, image, and configuration versions.
Containerized FastAPI Example
- Build a typed FastAPI service with validation, readiness and liveness checks, structured logs, and tests.
- Package the service and model runtime as a non-root Docker image and push an immutable digest to Azure Container Registry.
- Deploy the image to Azure Container Apps, AKS, or an Azure Machine Learning endpoint according to workload needs.
- Use a managed identity to retrieve authorized blobs and secrets instead of embedding credentials.
- Place an appropriate gateway or load balancer in front, configure TLS and private connectivity, and expose only required routes.
- Scale on representative signals such as concurrency, queue depth, latency, memory, or accelerator utilization—not CPU alone.
Data, Events, and Orchestration
Azure Data Factory can coordinate ingestion and transformation, Azure Databricks or Microsoft Fabric can support large-scale data preparation and analytics, and Event Hubs can ingest streams. Service Bus provides durable queues and topics for decoupled work, while Event Grid routes events such as new files or completed jobs. Choose storage and databases from access, consistency, scale, retention, and governance requirements.
Design distributed consumers to tolerate duplicate delivery. Use stable operation IDs, idempotent writes, bounded retries with jitter, poison-message handling, and dead-letter queues. A retry must not accidentally charge a customer twice, create duplicate predictions, or repeat an external action.
Identity, Secrets, and Network Security
- Authenticate people and workloads through Microsoft Entra ID and prefer managed identities over stored credentials.
- Assign least-privilege Azure role-based access control at the narrowest practical scope and review inherited permissions.
- Store secrets, keys, and certificates in Key Vault; rotate them and keep them out of code, notebooks, logs, and images.
- Use private endpoints and virtual network controls for sensitive workspaces, registries, storage, vaults, and inference services where requirements demand them.
- Encrypt data in transit and at rest, restrict public network access, and control outbound paths to reduce exfiltration risk.
- Separate subscriptions or resource groups, duties, identities, and deployment authority according to organizational risk.
Observability
Azure Monitor collects and analyzes metrics and logs, Log Analytics supports queries, and Application Insights observes application requests, dependencies, exceptions, traces, and custom telemetry. Add stable request and prediction IDs, and attach model, prompt, feature, image, and configuration versions to telemetry without unnecessarily recording sensitive inputs.
| Layer | Example signals |
|---|---|
| Infrastructure | CPU, memory, accelerator use, disk, network, pod or replica health |
| Service | Traffic, failures, timeouts, p50/p95/p99 latency, saturation, queue depth |
| Data | Schema violations, missingness, ranges, freshness, drift, feature health |
| Model | Prediction distribution, confidence, calibration, slice quality, delayed ground truth |
| Generative AI | Groundedness, safety events, tool failures, token use, retrieval quality |
| Product and cost | Human corrections, outcome metrics, cost per successful prediction |
Drift is an investigation signal, not automatic proof that a model should be retrained. Combine statistical monitoring with verified labels, user feedback, product outcomes, and an incident playbook.
CI/CD and Infrastructure as Code
Use GitHub Actions or Azure Pipelines to test source, data contracts, pipelines, model quality, security, and deployment configuration. Define infrastructure with Bicep, ARM templates, Terraform, or another reviewed approach. Keep environment-specific values separate while promoting the same immutable release artifact through development, staging, and production.
- Require review and reproducible evidence before a model receives a production approval state.
- Test locally where possible, then run integration, load, resilience, privacy, and rollback tests in staging.
- Use shadow, canary, blue/green, or controlled traffic allocation for risky changes.
- Evaluate both technical health and AI or business outcomes before increasing traffic.
- Keep the last known-good compatible release and regularly demonstrate rollback.
Reliability and Disaster Recovery
- Define service-level objectives plus recovery-time and recovery-point objectives from business impact.
- Use availability zones and redundant components where justified; add cross-region recovery only when the requirement warrants its cost and complexity.
- Apply timeouts, circuit breakers, bounded retries, queues, health probes, graceful shutdown, and safe degraded behavior.
- Back up state and configuration, protect model and data assets, and test restoration rather than assuming replication is sufficient.
- Document ownership, alerts, escalation, rollback, dependency failure, capacity, and data-reconciliation procedures.
Cost Management
- Tag resources and attribute cost to subscriptions, environments, teams, models, or products.
- Create budgets and anomaly alerts before production rollout.
- Right-size compute, use autoscaling, and stop idle notebooks, clusters, endpoints, disks, and development resources.
- Use reserved or interruptible capacity only when the workload and recovery design can tolerate the trade-off.
- Control log retention and data movement, which can become significant hidden costs.
- Track unit economics such as cost per successful prediction or business outcome.
Responsible AI and Governance
Azure services do not make a model responsible automatically. Document intended and prohibited use, evaluate relevant fairness, privacy, robustness, transparency, and safety risks, and assign accountable owners. High-impact decisions may require meaningful human review, evidence, override, escalation, and appeal mechanisms. Reassess controls whenever data, users, models, policies, or operating conditions change.
Common Mistakes
- Choosing AKS or another complex platform before simpler managed services are evaluated.
- Leaving storage, registries, workspaces, vaults, or endpoints publicly accessible for convenience.
- Using broad roles, service principal secrets, or credentials embedded in pipelines and containers.
- Deploying a model without versioned preprocessing, environment, schema, and configuration.
- Monitoring endpoint uptime while ignoring data quality, model behavior, business outcomes, and cost.
- Triggering automatic retraining from drift without labels, validation, approval, or rollback safeguards.
- Scaling on the wrong metric or ignoring model-loading and accelerator warm-up time.
- Keeping idle compute and unlimited telemetry without budgets, lifecycle policies, or retention rules.
Beginner Project: Production-Ready Prediction API
- Train a small model and save a versioned artifact plus evaluation report in protected storage.
- Create a FastAPI prediction service with typed input, tests, health probes, request IDs, and structured logging.
- Build and scan a non-root container, push it to Azure Container Registry, and record its digest.
- Deploy it to a private test environment using Container Apps or an Azure Machine Learning online endpoint.
- Assign a least-privilege managed identity and retrieve authorized storage or Key Vault values without static secrets.
- Create Azure Monitor dashboards and actionable alerts for traffic, latency, failures, saturation, and one model-quality signal.
- Run load, dependency-failure, canary, and rollback tests, then document the architecture and runbook.
- Remove lab resources after the exercise to avoid unexpected charges.
Architecture Review Checklist
[ ] Workload latency, throughput, availability, data, risk, and cost requirements defined
[ ] Exact data, model, code, image, environment, schema, and configuration versions traceable
[ ] Managed identities, least privilege, secrets, encryption, and network boundaries reviewed
[ ] Online, asynchronous, batch, streaming, or edge pattern matches the workload
[ ] CI tests and model, safety, latency, and cost promotion gates enforced
[ ] Service, data, model, outcome, and economic signals monitored
[ ] Canary, rollback, backup, restore, failure, and incident procedures tested
[ ] Resource ownership, budgets, retention, maintenance, and retirement documented