πŸ“¦
Module 1 of 9 20–25% 2 sub-modules Β· 15 units Domain 1: Develop Containerized Solutions on Azure

Implement Container Application Hosting on Azure

Build, store, version, and manage container images using Azure Container Registry. Build and run images with ACR Tasks. Deploy containers to Azure App Service with environment variables and secrets.

Azure Container RegistryACR TasksAzure App Service

Last updated: Β· Aligned with Course AI-200T00-A

Module

Store and Manage Containers in Azure Container Registry

units
🎬 Unit 1

Introduction

2 min

Azure Container Registry (ACR) is Azure's private Docker-compatible registry. It stores container images and OCI artifacts, integrates natively with AKS, Container Apps, and App Service, and runs ACR Tasks to build images without a local Docker engine. Think: Private Docker Hub + Azure RBAC + built-in vulnerability scanning.

πŸ’‘ Exam Tip
Three exam pillars for ACR: 1) SKU differences  2) Authentication options  3) ACR Tasks types. Know all three cold.
πŸ“˜ Unit 2

Registries, Repositories, and Artifacts

8 min

ACR β†’ Azure Compute: Build once, deploy everywhere

Developerdocker builddocker pushACRContainer Registrymyapp:v1.0 βœ“myapp:latest βœ“docker pullAzure ComputeApp ServiceContainer AppsAKSFunctionsManaged Identity β†’ AcrPull

1. Registry Hierarchy

  1. Registry β€” top-level ACR account with unique DNS: myapp.azurecr.io. Up to 500 repositories per registry.
  2. Repository β€” named collection of related images (for example: api, worker, batch).
  3. Tag β€” mutable pointer to an image digest (for example: latest, v2.1). Can be overwritten.
  4. Digest β€” immutable SHA-256 hash (sha256:abc123...). Survives tag rewrites. Always use in production.

Memory aid: Library β†’ Bookshelf β†’ Label β†’ ISBN

2. ACR SKUs Compared

#SKUStorageGeo-ReplicationPrivate LinkUse For
1Basic10 GB❌❌Dev/test, learning
2Standard100 GB❌❌Most production workloads
3Premium500 GBβœ…βœ…Multi-region, private networks, HSM keys
⚠️ Common Gotcha
Geo-replication = Premium only. Private endpoints = Premium only. Customer-managed keys = Premium only. If the question mentions ANY of these three β†’ answer is Premium.

3. ACR Authentication Options

  1. Microsoft Entra ID + RBAC (recommended) β€” roles: AcrPull (read-only), AcrPush (push), AcrDelete (delete). Works with managed identities β€” no stored credentials.
  2. Admin account β€” single username + 2 rotatable passwords. Disabled by default. Only for legacy tools that can't use Entra. Never production.
  3. Repository-scoped tokens β€” Premium only. Grants access to specific repos only. Great for vendors/external CI.
⚠️ Common Gotcha
AKS pulls from ACR using Managed Identity + AcrPull β€” NOT admin credentials. Admin account is always the wrong answer for AKS/ACA/App Service scenarios.

⚑ ACR Auth Quick Reference

AKS β†’ ACRManaged Identity + AcrPull role
Container Apps β†’ ACRManaged Identity + AcrPull role
App Service β†’ ACRManaged Identity + AcrPull role
Legacy tool (no Entra)Admin account (last resort)
External vendor accessRepo-scoped token (Premium)
πŸ“˜ Unit 3

Build Container Images with ACR Tasks

8 min

ACR Tasks β€” Three Types

  1. Quick Task β€” one-shot cloud build. No local Docker daemon needed. Ideal for CI pipelines.
    az acr build --registry myregistry --image api:v1 .
  2. Triggered Task β€” runs automatically on an event:
    1. Source trigger β€” on git commit or PR via GitHub/ADO webhook
    2. Base image trigger β€” rebuilds your image when its FROM base image is updated (Premium only)
    3. Schedule trigger β€” cron-style, runs on a timer for nightly scans
    az acr task create \
      --registry myregistry --name build-on-commit \
      --image "api:{{.Run.ID}}" \
      --context https://github.com/org/repo.git --branch main \
      --file Dockerfile --git-access-token $TOKEN
  3. Multi-Step Task (YAML) β€” build β†’ test β†’ push pipeline in YAML:
    version: v1.1.0
    steps:
      - build: -t myregistry.azurecr.io/api:test -f Dockerfile .
      - push: ["myregistry.azurecr.io/api:test"]
      - cmd: myregistry.azurecr.io/api:test --run-tests
      - build: -t myregistry.azurecr.io/api:latest -f Dockerfile .
      - push: ["myregistry.azurecr.io/api:latest"]
πŸ’‘ Exam Tip
Memory aid β€” QTS: Quick (one-shot), Triggered (event-driven), Step (YAML pipeline). Base image trigger = Premium only and is the key "automatically rebuild when OS is patched" scenario.
πŸ“˜ Unit 4

Tag, Version, and Lifecycle Management

8 min

1. Stable vs Unique Tags

  1. Stable tags (for example: latest, v1) β€” mutable. Convenient but silently change. Dev/test only.
  2. Unique tags (for example: v1.2.3-20250601) β€” immutable per build. Fully traceable. Use in production.
  3. Digests (image@sha256:abc...) β€” never changes even if tag is overwritten. Gold standard for prod.

2. Locking Images (Write-Protection)

az acr repository update \
  --name myregistry --image api:v1.2.3 --write-enabled false

Locked images cannot be overwritten or deleted. Protects production images from accidental pushes.

3. Lifecycle Policies (Auto-Cleanup)

az acr config retention update \
  --registry myregistry --status enabled --days 30 --type UntaggedManifests

Auto-deletes untagged manifests older than N days. Prevents storage bloat from accumulated dangling layers.

🧠 Memory Tricks

Auth ladder: Managed Identity (always first) > Repo token (vendors) > Admin (legacy only, never prod)

SKU β†’ features: B/S = basic storage, P = Premium = Private link + geo-replication

Task types: QTS β€” Quick, Triggered, Step

πŸ§ͺ Unit 5

Exercise β€” Build and Push with ACR Tasks

30 min
  1. Create an ACR registry (Standard SKU)
  2. Run az acr build to build without local Docker
  3. Create a triggered task tied to a GitHub repo
  4. Verify images: az acr repository list and az acr repository show-tags
  5. Lock the production tag with --write-enabled false
βœ… Unit 6

Knowledge Check

5 min
  1. Q: Which SKU supports geo-replication? A: Premium
  2. Q: AKS needs to pull from ACR securely. Best approach? A: Assign AcrPull role to AKS cluster's managed identity
  3. Q: What ACR Task type rebuilds your image when the base OS image is patched? A: Base image trigger (Triggered task β€” Premium only)
  4. Q: How do you prevent a production image tag from being overwritten? A: az acr repository update --write-enabled false
  5. Q: What does the ACR admin account provide? A: Username + 2 rotatable passwords β€” legacy auth only, never production
🏁 Unit 7

Summary

2 min

ACR provides a private, Azure-native container registry. Use Premium for geo-replication and private endpoints. Authenticate with managed identity + AcrPull β€” never admin in production. Use ACR Tasks (QTS) to build in the cloud. Use unique tags + digests for production traceability. Set lifecycle policies to auto-clean dangling manifests.

Module

Deploy Containers to Azure App Service

units
🎬 Unit 1

Introduction

3 min

Azure App Service can run your custom Docker containers alongside its built-in language runtimes. You push an image to ACR, point App Service at it, and Azure handles TLS, scaling, and restarts. This module covers deploying, configuring runtime settings, handling secrets, and troubleshooting container failures.

πŸ“˜ Unit 2

Deploy Containers to App Service

8 min

1. Image Sources

  1. Azure Container Registry β€” recommended. Native integration with managed identity. Best for production.
  2. Docker Hub β€” public images or authenticated private repos. Avoid for production (rate limits, no RBAC).
  3. Private registry β€” any registry exposing the Docker HTTP API. Supply server URL + credentials.

2. ACR Authentication for App Service

  1. Managed Identity (recommended)
    az webapp identity assign -g rg -n myapp
    az role assignment create \
      --assignee $(az webapp identity show -g rg -n myapp --query principalId -o tsv) \
      --role AcrPull \
      --scope $(az acr show -n myregistry --query id -o tsv)
    az webapp config container set -n myapp -g rg \
      --docker-custom-image-name myregistry.azurecr.io/api:v1 \
      --docker-registry-server-url https://myregistry.azurecr.io
  2. Admin credentials (legacy) β€” enable admin on ACR, set server/user/password in App Service config. Stores long-lived credentials.
⚠️ Common Gotcha
With managed identity you do NOT pass --docker-registry-server-user or --docker-registry-server-password. The identity handles it. This distinction is tested.

3. Continuous Deployment (CD)

az webapp deployment container config -n myapp -g rg --enable-cd true

Creates a webhook URL. Configure ACR to POST to it on image push. App Service auto-pulls the new image β€” zero CI/CD pipeline needed for simple scenarios.

πŸ“˜ Unit 3

Configure Container Runtime Behavior

7 min

1. Port Mapping β€” WEBSITES_PORT

App Service routes all traffic to the port specified by WEBSITES_PORT. Default assumption is port 80.

az webapp config appsettings set -g rg -n myapp --settings WEBSITES_PORT=8000
⚠️ Common Gotcha
Port mismatch = #1 cause of container startup failures. App shows HTTP 503 or container exits immediately. First check: is WEBSITES_PORT set correctly?

2. Custom Startup Command

az webapp config set -g rg -n myapp --startup-file "gunicorn app:app --bind 0.0.0.0:8000"

Overrides the image CMD/ENTRYPOINT at runtime without rebuilding. Useful for multi-environment configs.

3. Persistent Storage

By default the container filesystem is ephemeral β€” lost on restart. Set WEBSITES_ENABLE_APP_SERVICE_STORAGE=true to mount /home persistently for models, logs, or write-able files.

4. Health Checks

  1. Always On β€” keeps app warm (no cold start). Enable for production, disable to save cost on dev.
  2. Health check path β€” App Service polls your endpoint (for example: /health). Unhealthy instances are recycled.
πŸ“˜ Unit 4

Configure Application Settings

6 min

1. App Settings β†’ Environment Variables

az webapp config appsettings set -g rg -n myapp --settings MODEL_NAME=gpt-4o LOG_LEVEL=info

Every App Setting becomes an environment variable in your container β€” the primary config injection mechanism.

2. Key Vault References (Secure Secrets)

az webapp config appsettings set -g rg -n myapp \
  --settings "[email protected](SecretUri=https://myvault.vault.azure.net/secrets/api-key/)"

App Service fetches the secret at runtime. Secret rotations propagate automatically β€” no redeployment needed.

πŸ’‘ Exam Tip
Key Vault references require: 1) Managed identity on App Service 2) Key Vault Secrets User role assigned. The exam tests this two-step dependency.

3. Connection String Prefixes

  1. SQLAZURECONNSTR_ β€” SQL Azure
  2. MYSQLCONNSTR_ β€” MySQL
  3. POSTGRESQLCONNSTR_ β€” PostgreSQL
  4. CUSTOMCONNSTR_ β€” any custom connection string
πŸ“˜ Unit 5

Observe and Troubleshoot Containers

7 min

1. Log Stream (Live Logs)

az webapp log tail -g rg -n myapp

Streams container stdout/stderr in real time. First stop when a deployment fails.

2. SSH Console (Kudu)

App Service exposes SSH to running containers via https://myapp.scm.azurewebsites.net. Exec into the container and diagnose issues interactively. Your container must expose port 2222 for SSH to work.

3. Application Insights

Set APPLICATIONINSIGHTS_CONNECTION_STRING as an App Setting + add the SDK. Provides request tracing, exceptions, and performance metrics.

⚑ ACR + App Service Master Cheatsheet

Build without Docker locallyaz acr build --registry ... --image ... .
Auth: compute β†’ ACRManaged Identity + AcrPull role
Set container portWEBSITES_PORT=8000
Inject secret securelyKey Vault reference in App Settings
Enable CD from ACR--enable-cd true
Lock image tag--write-enabled false
Geo-replication SKUPremium only
Auto-cleanup old imagesaz acr config retention update --days 30
Live container logsaz webapp log tail -g rg -n myapp
SSH into containerKudu: myapp.scm.azurewebsites.net
πŸ§ͺ Unit 6

Exercise β€” Deploy a Container to App Service

30 min
  1. Build an image with az acr build
  2. Create a Linux App Service (Docker container plan)
  3. Configure managed identity + AcrPull for registry auth
  4. Set WEBSITES_PORT and env vars
  5. Add a Key Vault reference for the API key
  6. Verify with az webapp log tail
βœ… Unit 7

Knowledge Check

5 min
  1. Q: App Service fails to start your container β€” first thing to check? A: WEBSITES_PORT matches your app's listen port
  2. Q: How does App Service pull from ACR without stored credentials? A: System-assigned managed identity + AcrPull RBAC role on the registry
  3. Q: Where do you view live stdout from a running container? A: az webapp log tail or Log Stream in Azure portal
  4. Q: A Key Vault reference shows as literal text in the app, not the secret value. Why? A: The managed identity is missing the Key Vault Secrets User role
🏁 Unit 8

Summary

2 min

Deploy containers to App Service using ACR with managed identity authentication. Set WEBSITES_PORT to match your app's listen port. Inject configuration via App Settings and reference secrets from Key Vault instead of embedding them. Use log streaming and SSH console to troubleshoot. Enable continuous deployment for auto-pull on new image pushes.

🧠 Container Startup Failure Checklist

  1. Check WEBSITES_PORT matches app listen port
  2. Check image tag is correct and registry credentials work
  3. Run az webapp log tail for app-level errors
  4. Check managed identity has AcrPull on the registry
  5. Check Key Vault references if secrets are missing
πŸ“¦
Module Cheatsheet

Azure Container Registry + App Service

20–25% PDF

πŸ”‘ Key Facts

  • az acr build β€” Cloud build β€” no local Docker. Runs in Azure.
  • AcrPull role β€” Managed Identity pulls images. NEVER admin user in prod.
  • SKU ladder β€” Basic (10 GB dev) β†’ Standard (100 GB prod) β†’ Premium (geo-rep)
  • Geo-replication β€” Premium ONLY. Push once, pull from nearest replica.
  • Unique tag β€” Immutable per build β€” use in production (not 'latest')
  • WEBSITES_PORT β€” Must match app listen port β€” #1 startup failure cause
  • KV Reference β€” @Microsoft.KeyVault(SecretUri=...) in App Settings
  • Base image trigger β€” Auto-rebuild on OS update β€” Premium ACR task only

πŸ’» Commands & Patterns

az acr build --registry myacr --image api:v1 .
az acr task create --name build --registry myacr   --image "api:{{{.Run.ID}}}" --context https://github.com/org/repo   --branch main --git-access-token $TOKEN
az acr config retention update   --registry myacr --status enabled --days 30
az acr repository update --name myacr   --image api:v1.2.3 --write-enabled false
az webapp config appsettings set -g rg -n app   --settings WEBSITES_PORT=8000
az webapp log tail -g rg -n myapp
🧠

Quick Quiz

5 questions β€” test your understanding before moving on

Finished reading this module? Mark it complete to track your progress.

Frequently Asked Questions

What percentage of the AI-200 exam covers Develop Containerized Solutions on Azure? +

Domain 1 (Develop Containerized Solutions on Azure) accounts for 20–25% of the AI-200 exam. Implement Container Application Hosting on Azure topics like Azure Container Registry and ACR Tasks are actively tested. Study all official skill objectives listed in the module header above.

Is ACR & App Service on the AI-200 exam? +

Yes. Implement Container Application Hosting on Azure is part of Domain 1 in the official AI-200 skill outline, weighted at 20–25%. The key services tested are Azure Container Registry, ACR Tasks, Azure App Service. Review the code examples and exam tips in this module for targeted prep.

How do I practice ACR & App Service hands-on? +

The best approach is to create a free Azure account and follow the code examples in this module step-by-step. The official Microsoft Learn sandbox for Course AI-200T00-A also provides free lab environments for Azure Container Registry and related services.