Skip to content
AI-200 Learn

Commands reference

Command cheat sheet for the Quote API sample on AI-200: local Docker, az acr build/run, ACR Tasks triggers and Azure Container Apps commands.

What this covers

This is the command cheat sheet for the Quote API project. It groups the local Docker commands, the Azure Container Registry commands that build, store and version the image, the ACR Tasks commands that automate builds, and the Azure Container Apps commands that run it. Use it as a lookup while you work through the project. The exam tests which command fits which job, so the comparison table under Exam traps is the part to memorize.

Exam weight: Develop containerized solutions on Azure (20–25%)

Skills measured

  • "Build, store, version, and manage container images by using Azure Container Registry"
  • "Build and run images by using Azure Container Registry Tasks"

Key concepts

Three ways to build in ACR

CommandKindInputSaved?
az acr buildQuick taskA Dockerfile plus a build contextNo, runs once
az acr runQuick multi-step runA task YAML file (or --cmd)No, runs once
az acr task createSaved taskA Dockerfile or YAML plus a Git or OCI contextYes, can run on triggers

Task triggers

  • Source commit (on by default when the context is a GitHub or Azure Repos URL) and pull request (off by default). Both need a personal access token so ACR can create the webhook.
  • Base image update: rebuilds the app image when its base image is updated in ACR or a public registry.
  • Timer: one or more cron schedules in UTC (--schedule).

Image versioning

Push a unique tag (a version or the run ID) for every build and treat latest as a convenience alias. az acr repository show-tags and az acr repository show-manifests show what is stored.

How it works

Diagram source: flowchart LR Src[Source: local dir or Git] -->|az acr build / az acr run| Build[ACR build agent] Git[Git commit / timer / base image] -->|az acr task create| Build Build --> Repo[(ACR repository<br/>quote-api:tags)] Repo -->|az containerapp create / update| App[Container App]

Hands-on

Azure portal

  1. In the registry, open Services > Repositories to browse images and tags.
  2. Open Services > Tasks to see saved tasks; the Runs tab lists every run with its logs.
  3. In the container app, open Monitoring > Log stream to watch the running API.

Azure CLI

Local

CommandDescription
uvicorn app.main:app --reload --port 8000Run the API locally
docker compose up --buildRun with Docker Compose
docker build -t quote-api:local .Build the image locally
python -m flake8 app/Lint the code

Login and resources

CommandDescription
az loginSign in to Azure
az account set -s "Subscription Name"Select a subscription
az group create -n quote-api-rg -l eastusCreate the resource group
az group delete -n quote-api-rg --yesDelete the resource group and everything in it

Container Registry

CommandDescription
az acr create -g quote-api-rg -n quoteapiacr --sku Basic --admin-enabled trueCreate the registry (admin user on for the lab only)
az acr login -n quoteapiacrLog the local Docker client into ACR
az acr build -r quoteapiacr -t quote-api:latest .Quick task: cloud build and push
az acr run -r quoteapiacr -f acr-task.yaml .Multi-step run (lint + build + push)
az acr repository list -n quoteapiacr -o tableList repositories
az acr repository show-tags -n quoteapiacr --repository quote-apiList image tags

ACR Tasks

CommandDescription
az acr task create -n quote-api-build -r quoteapiacr -f acr-task.yaml --context <git-url> --git-access-token <pat>Create a saved task
az acr task run -n quote-api-build -r quoteapiacrRun a task manually
az acr task list -r quoteapiacr -o tableList all tasks
az acr task logs -r quoteapiacr --run-id <id>View a run's logs
az acr task delete -n quote-api-build -r quoteapiacr --yesDelete a task

GitHub-triggered task (builds on every commit to main):

Azure CLI / Bash
az acr task create \
  -n quote-api-github-build \
  -r quoteapiacr \
  -f acr-task.yaml \
  --context https://github.com/YOUR-ORG/YOUR-REPO.git#main \
  --git-access-token YOUR_GITHUB_PAT \
  --commit-trigger-enabled true

Scheduled task (nightly at 2 AM UTC, no commit trigger):

Azure CLI / Bash
az acr task create \
  -n quote-api-nightly \
  -r quoteapiacr \
  -f acr-task.yaml \
  --context https://github.com/YOUR-ORG/YOUR-REPO.git#main \
  --git-access-token YOUR_GITHUB_PAT \
  --commit-trigger-enabled false \
  --schedule "0 2 * * *"

Container Apps

CommandDescription
az containerapp env create -n quote-api-env -g quote-api-rg -l eastusCreate the environment
az containerapp show -n quote-api -g quote-api-rg --query properties.configuration.ingress.fqdn -o tsvGet the app URL
az containerapp update -n quote-api -g quote-api-rg --image quoteapiacr.azurecr.io/quote-api:latestDeploy a new image (creates a new revision)
az containerapp logs show -n quote-api -g quote-api-rgView app console logs (--follow to stream)

API endpoints

MethodEndpointDescription
GET/Welcome message
GET/quotesList all quotes
GET/quotes/randomRandom quote
POST/quotesCreate a quote
DELETE/quotes/{id}Delete a quote
GET/healthHealth check
GET/docsSwagger UI

Python

Smoke-test the deployed API after a build:

Python
import requests

base = "https://<container-app-fqdn>"
assert requests.get(f"{base}/health", timeout=10).status_code == 200
print(requests.get(f"{base}/quotes/random", timeout=10).json())

Exam traps

RequirementCommand
Build a Dockerfile in Azure without local Dockeraz acr build
Run a multi-step YAML onceaz acr run -f <file>.yaml
Rebuild on every Git commitaz acr task create --context <git-url> --git-access-token
Rebuild nightlyaz acr task create --schedule "<cron>"
Push from a local Docker buildaz acr login, then docker push

Quick review

  • az acr build = quick task from a Dockerfile; az acr run = one-off multi-step YAML.
  • az acr task create saves a task with commit, base-image or timer triggers.
  • Commit triggers are on by default for Git contexts and need a PAT.
  • az acr task logs --run-id retrieves logs for triggered runs.
  • az acr repository show-tags lists the versions you have stored.
  • az containerapp update --image deploys a new image as a new revision.

Practice

Official references