1. Container Architecture for Architects

Containers package application code + dependencies into an immutable unit that runs identically everywhere. The architect's job: choose the right registry, runtime, and orchestration layer.

Key Concepts

  • Image — Immutable artifact; a layered filesystem + run command. Tagged with version (e.g., myapp:1.4.2).
  • Registry — Stores and distributes images. ACR is Azure's private OCI-compliant registry.
  • Orchestration — Manages multiple container instances: scaling, healing, networking. AKS (full Kubernetes) or Container Apps (managed, simpler).
  • Runtime — Executes containers. ACI is Azure's serverless runtime — no cluster to manage.
Architect mindset: Think of ACR as the "what" (images), ACI as the "quick run" (no infra), AKS as the "operate at scale" (full control), and Container Apps as "scale without Kubernetes expertise."

2. Azure Container Registry (ACR)

Tiers

Feature Basic Standard Premium
Storage (GiB)10100500
Throughput (MBps read)3060100+
Webhooks210500
Geo-replication
Private Link / VNet
Content Trust (signing)
Customer-managed keys
ACR Tasks
Monthly cost (approx.)$5$20$50+ per replica

Geo-Replication (Premium)

Replicate your registry to multiple Azure regions. Consumers pull from the nearest replica — lower latency, built-in HA. If one region is down, traffic routes to the next closest.

ACR Tasks — Automated Builds

ACR Tasks run container builds in the cloud — no local Docker daemon required. Three trigger types:

  • Quick taskaz acr build for one-off builds (like a cloud docker build).
  • Automatically triggered — on source-code commit (GitHub/Azure Repos), base-image update, or scheduled timer.
  • Multi-step task — YAML-defined pipeline: build → test → push multiple images.
Base image update trigger: When your base image (dotnet/aspnet:8.0) gets a security patch, ACR Tasks auto-rebuilds your app image. This is a key security automation pattern.

Content Trust & Security (Premium)

  • Content Trust (Docker Notary v2) — Cryptographically sign images; consumers verify signatures before pulling.
  • Private endpoints — Registry accessible only via private IP over VNet; no public exposure.
  • Customer-managed keys — Encrypt image layers at rest with your own keys in Key Vault.
  • Quarantine pattern — Images land in quarantine; pass vulnerability scan → promoted to available.

3. Azure Container Instances (ACI)

ACI is serverless containers — deploy a container group in seconds with no cluster, no VM, no orchestrator. Pay per vCPU-second and GB-second.

When to Use ACI

  • Quick batch jobs (data processing, report generation)
  • CI/CD build agents (spin up, run pipeline, destroy)
  • Sidecar containers for testing or support tasks
  • Burst capacity from AKS via Virtual Kubelet
  • Event-driven workloads that need fast cold start

Limitations — Know When NOT to Use ACI

  • ❌ No built-in orchestration (no auto-scaling, no rolling deployments)
  • ❌ No self-healing — if a container crashes, you must restart it externally
  • ❌ Limited networking — no full VNet integration on all SKUs (Windows has constraints)
  • ❌ Max 4 vCPUs / 16 GB RAM per container group (standard SKU); GPU SKUs available but limited
  • ❌ No persistent storage by default — mount Azure Files for state
  • ❌ Cold start can be 10-30s for large images

Container Groups

ACI's deployment unit is a container group — one or more containers that share the same lifecycle, network (localhost), and storage volumes. Analogous to a Kubernetes Pod.

Exam trap: ACI container groups are scheduled on the same host — containers within a group share localhost and mounted volumes, but NOT containers across different groups.

4. ACI Architecture Patterns

Pattern 1: CI/CD Build Agents

Spin up an ACI container with your build tools, execute the pipeline, push artifacts, then delete the container. Zero idle cost.

Pattern 2: Batch Processing

Queue-driven: Azure Queue Storage triggers a Logic App or Function that spins up N ACI containers in parallel, each processing a chunk. Fan-out/fan-in without managing any infrastructure.

Pattern 3: Sidecar Containers

Deploy an app container + a logging/monitoring sidecar in the same container group. The sidecar ships logs to Log Analytics while the app focuses on business logic.

Pattern 4: Virtual Kubelet Burst from AKS

AKS installs the Virtual Kubelet (ACI connector). When the cluster runs out of node capacity, new pods burst to ACI — scaling to hundreds of instances in seconds without provisioning new VMs. Ideal for seasonal traffic spikes.

Cost optimization: Virtual Kubelet burst means you keep a small, steady-state AKS cluster and only pay ACI per-second pricing during demand peaks. No over-provisioned nodes sitting idle.

5. ACR + ACI + Managed Identity

Best practice: eliminate stored credentials entirely. Use managed identity for image pulls.

How It Works

  1. Create a user-assigned managed identity.
  2. Grant it AcrPull role on the ACR.
  3. Assign that identity to the ACI container group at deployment time.
  4. ACI uses the identity's token to authenticate to ACR — no passwords, no service principals to rotate.
# Create identity
az identity create -g myRG -n acr-pull-id

# Get identity resource ID & principal ID
IDENTITY_ID=$(az identity show -g myRG -n acr-pull-id --query id -o tsv)
PRINCIPAL_ID=$(az identity show -g myRG -n acr-pull-id --query principalId -o tsv)

# Grant AcrPull on the registry
ACR_ID=$(az acr show -n myregistry --query id -o tsv)
az role assignment create --assignee $PRINCIPAL_ID --role AcrPull --scope $ACR_ID

# Deploy ACI with managed identity
az container create \
  --resource-group myRG \
  --name myapp \
  --image myregistry.azurecr.io/myapp:latest \
  --assign-identity $IDENTITY_ID \
  --acr-identity $IDENTITY_ID
System-assigned vs User-assigned: User-assigned is preferred for ACR pull because you can pre-create the role assignment before deployment. System-assigned creates a chicken-and-egg problem (identity doesn't exist until the resource is created).

6. Container Apps vs ACI vs AKS — When Each Fits

Dimension ACI Container Apps AKS
ComplexityLowest — no infraLow — managed Envoy/KEDAHighest — full K8s API
OrchestrationNoneBuilt-in (Dapr, KEDA)Full Kubernetes
Auto-scalingManual/externalHTTP/event-driven (0→N)HPA, VPA, Cluster Autoscaler
Scale to zeroN/A (stop = no cost)✅ built-inVia KEDA add-on
NetworkingPublic IP or VNet injectManaged VNet, ingressFull CNI, Network Policies
Persistent stateAzure Files mountAzure Files mountPV/PVC (Disks, Files, Blob)
Cost modelPer-second (vCPU+RAM)Per-second + requestsVM node cost + add-ons
Best forShort jobs, burst, sidecarMicroservices, APIs, eventsComplex apps, multi-team, full control
Decision heuristic:
• Need it for <5 minutes, one-off? → ACI
• Microservice that scales on HTTP/events, team doesn't know K8s? → Container Apps
• Multi-team platform, need Network Policies, custom operators, Helm charts? → AKS
🎯 Exam Tip: AZ-305 loves asking "which compute service" questions. ACI = simplest/fastest for isolated tasks. Container Apps = managed microservices without K8s expertise. AKS = full Kubernetes when you need complete control. Cost and operational complexity increase left→right.

7. Real-World: CI/CD Pipeline with ACR Tasks + ACI Ephemeral Agents

📖 Scenario

A fintech company builds 200+ microservices. They need secure, scalable CI/CD without long-lived build servers that accumulate vulnerabilities.

Architecture

  1. Developer pushes code to GitHub → triggers ACR Task via webhook.
  2. ACR Task (multi-step YAML): builds image, runs unit tests in-container, pushes to ACR with content trust signature.
  3. Integration tests: ACR Task triggers an ACI container group — the app + a database sidecar — runs integration tests, then self-destructs.
  4. Promotion: On success, image is tagged :release and geo-replicated to production regions.
  5. Deployment: AKS clusters in each region pull from local ACR replica. Virtual Kubelet bursts overflow to ACI during peak deployment windows.

Why This Works

  • Zero persistent build infrastructure — each build is a fresh container (no "works on the build server" drift).
  • Cost: pay only for build seconds, not 24/7 VMs.
  • Security: managed identity throughout — no stored Docker credentials, no service principal secrets in pipelines.
  • Geo-replication: production pulls are fast and resilient regardless of region.

8. Knowledge Check