Deploy a Container App
In this task you'll deploy a container app.
Azure Container Apps runs containerised web apps, APIs and background workers without you managing servers or Kubernetes. It adds a web address, HTTPS, and scaling based on traffic, and it can scale down to zero copies when nobody is using the app.
Container apps live in an environment, which groups related apps on one network and sends their logs to one place.
Example. SS Kaiser runs its stock-checking API as a container app. It scales up to ten copies on Saturday afternoons and down to zero overnight, so SS Kaiser pays only while people are shopping.
Before you start
You need: Contributor on the resource group. Time: 15 minutes.
Where to look
- Home
- Container Apps
- + Create
- Container App
Steps
- Open Container Apps, select + Create, then Container App.
- Choose rg-portal-practice, name the app app-hello, leave Deployment source on Container image and pick your region.
- Under Container Apps environment, select Create new environment. On its Monitoring tab, choose not to save logs for this practice, then Create.Sending logs to a Log Analytics workspace is right for real apps, but it can add charges.
- On the Container tab, tick Use quickstart image and pick the simple hello world one.
- On the Ingress tab, check that ingress is enabled, accepting traffic from anywhere, with target port 80.
- Select Review + create, then Create. It takes a minute or two.
- Open the app and select the Application Url on Overview to see it working.
- Open Scale (or Scale and replicas) and check the minimum replicas is 0, so the app costs nothing when idle.
Commands
# Create an environment and an app in one go (also creates a Log Analytics workspace)
az containerapp up --name app-hello --resource-group rg-portal-practice \
--location uksouth --image mcr.microsoft.com/k8se/quickstart:latest \
--target-port 80 --ingress external
# Its public address
az containerapp show --name app-hello --resource-group rg-portal-practice \
--query properties.configuration.ingress.fqdn --output tsv
Watch out for
- Cost
- The consumption plan includes a monthly free allowance of processor time, memory and requests, which a test app stays well inside. Log Analytics, if you turn it on, is billed separately.
- Security
- Ingress from anywhere makes the app public. Use internal ingress for APIs that only other apps should call, and store secrets as container app secrets or in Key Vault.
- Common mistakes
- Setting minimum replicas above zero for a test app and paying for idle time. Forgetting that the first request after scaling to zero is slower while a copy starts.
Clean up
- Resource groups
- rg-portal-practice
- Delete resource group
You've finished the containers section: delete the resource group. It removes the container app, its environment, and any registry or container instance you made.
Words to know
- Environment
- A shared boundary for container apps, with one network and one logging set-up.
- Ingress
- Settings that let traffic reach the app, from the internet or only from inside the environment.
- Revision
- A saved version of a container app. Changing the image or settings creates a new one.
- Replica
- One running copy of the app. More replicas handle more traffic.
Tick off each step and track your progress in the guide.
Open this task in Azure Portal, Hands On