Search Tutorials


AZ-204 - Containers in Azure | JavaInUse

AZ-204 - Containers in Azure

Overview of Containers in Azure

Containers provide a lightweight, portable way to package and run applications with all their dependencies. Azure offers several container services for different use cases -- from simple single-container deployments to full orchestration.

Containers vs. Virtual Machines

Containers

Share the host OS kernel, are lightweight (MBs), start in seconds, and provide process-level isolation. Ideal for microservices and rapid scaling.

Virtual Machines

Include a full guest OS, are heavier (GBs), take minutes to start, and provide hardware-level isolation. Better for legacy apps or when strong isolation is required.

Azure Container Services

ServiceDescriptionUse Case
Azure Container Instances (ACI)Serverless container hosting -- no VM management neededSimple, single-container workloads, burst scenarios
Azure Container Registry (ACR)Private Docker registry for storing and managing container imagesCI/CD pipelines, image storage for ACI/AKS
Azure Kubernetes Service (AKS)Managed Kubernetes orchestrationComplex multi-container applications requiring orchestration
Azure App Service (Containers)PaaS that supports containerized web appsWeb apps with custom runtime requirements

Azure Container Instances (ACI)

ACI is the fastest and simplest way to run a container in Azure. No VM provisioning or orchestration required. You pay only for the resources consumed during execution.

Key Features

Serverless Containers

No infrastructure management. Deploy containers directly without worrying about underlying VMs.

Fast Startup

ACI can start containers in seconds, making it ideal for burst workloads and event-driven processing.

Container Groups

Multiple containers can be deployed together in a container group, sharing the same host, network, and lifecycle -- similar to a Kubernetes pod.

Networking

ACI supports public IP addresses, custom DNS name labels, and Virtual Network integration for private connectivity.

Deploying ACI

az container create \
  --resource-group myResourceGroup \
  --name mycontainer \
  --image mcr.microsoft.com/azuredocs/aci-helloworld \
  --dns-name-label myapp-demo \
  --ports 80

Azure Container Registry (ACR)

ACR is a managed, private Docker registry for building, storing, and managing container images and artifacts. It integrates natively with ACI, AKS, and App Service.

ACR Tiers

TierStorageFeatures
Basic10 GBCost-optimized for dev/test
Standard100 GBHigher throughput for most production needs
Premium500 GBGeo-replication, content trust, private link

ACR Tasks

ACR Tasks automate container image builds in the cloud. They can be triggered by source code commits, base image updates, or on a schedule.

Deploying from ACR

Deploy an ACI App from ACR

To deploy an ACI container from a private ACR registry, you need to provide credentials or use a managed identity for authentication.

az container create \
  --resource-group myResourceGroup \
  --name myapp \
  --image myregistry.azurecr.io/myapp:latest \
  --registry-login-server myregistry.azurecr.io \
  --registry-username myuser \
  --registry-password mypassword \
  --ports 80

Deploy an Azure Web App from ACR

Azure App Service can pull container images directly from ACR using managed identity or admin credentials. Enable continuous deployment to auto-redeploy on image push.

az webapp create \
  --resource-group myResourceGroup \
  --plan myAppServicePlan \
  --name mywebapp \
  --deployment-container-image-name myregistry.azurecr.io/myapp:latest

Docker and WSL 2

Docker Desktop on Windows uses WSL 2 (Windows Subsystem for Linux) as its backend. WSL 2 provides a full Linux kernel, improving container performance and compatibility.

Key Terms

TermDefinition
Azure Container Instances (ACI)A serverless compute service for running containers without managing VMs or orchestration infrastructure.
Azure Container Registry (ACR)A managed, private Docker registry for storing, building, and managing container images in Azure.
Container GroupA collection of containers deployed together on the same host in ACI, sharing network and storage -- similar to a Kubernetes pod.
ACR TasksA feature of ACR that automates container image building in the cloud, triggered by code commits, base image updates, or schedules.
WSL 2Windows Subsystem for Linux version 2, providing a full Linux kernel for running Docker containers natively on Windows.
Exam Tips:
  • ACI = serverless containers, fastest startup, no orchestration. AKS = managed Kubernetes for complex orchestration.
  • ACR Premium tier is required for geo-replication and private link.
  • Container groups in ACI share lifecycle, network, and storage -- like Kubernetes pods.
  • ACR Tasks can automatically rebuild images when base images are updated.
  • App Service supports continuous deployment from ACR -- auto-redeploy on image push.

Practice Questions

Q1. A developer needs to run a simple containerized batch job in Azure without managing any infrastructure. Which service should they use?

  • Azure Kubernetes Service (AKS)
  • Azure Container Instances (ACI)
  • Azure Virtual Machines
  • Azure App Service

Answer: B

ACI is the serverless container service -- no VMs or orchestration to manage. It starts containers in seconds and is ideal for simple, single-container workloads and batch jobs.

Q2. Which ACR tier supports geo-replication?

  • Basic
  • Standard
  • Premium
  • All tiers

Answer: C

Only the Premium tier of Azure Container Registry supports geo-replication, content trust, and private link endpoints.

Q3. What is the ACI equivalent of a Kubernetes pod?

  • Container image
  • Container group
  • Container registry
  • Container task

Answer: B

A container group in ACI is a collection of containers deployed on the same host, sharing network and storage -- the same concept as a Kubernetes pod.

Q4. How can you enable automatic redeployment of a containerized web app when a new image is pushed to ACR?

  • Enable ACR Tasks
  • Enable continuous deployment in App Service
  • Use Azure Event Grid
  • Create an Azure Function trigger

Answer: B

Azure App Service supports continuous deployment from ACR. When enabled, App Service automatically pulls and redeploys when a new image is pushed to the configured registry.

Q5. What does WSL 2 provide for Docker Desktop on Windows?

  • A lightweight virtual machine with GUI support
  • A full Linux kernel for improved container performance
  • An Azure-hosted container runtime
  • A managed Kubernetes cluster

Answer: B

WSL 2 provides a full Linux kernel, enabling Docker containers to run natively on Windows with improved performance and compatibility compared to WSL 1.

AZ-204 Developing Azure Solutions - Table of Contents

Master all exam topics with comprehensive study guides and practice questions.


Popular Posts