Azure Container Apps for Developers
Azure Container Apps allows you to deploy containerized applications on a serverless platform. It's built on open standards like Kubernetes and Dapr, providing a flexible and powerful environment for your microservices and containerized workloads.
Key Concepts
- Container Apps: A managed environment for running containerized applications.
- Revisions: Immutable snapshots of your application's configuration. You can manage traffic between revisions.
- Jobs: For running batch or scheduled tasks.
- Dapr Integration: Built-in support for the Distributed Application Runtime (Dapr) for building resilient microservices.
- KEDA Integration: Built-in support for Kubernetes Event-Driven Autoscaling (KEDA) for scale-to-zero capabilities.
Getting Started
To get started with Azure Container Apps, you'll typically need:
- An Azure subscription.
- The Azure CLI installed.
- Docker installed for building container images.
1. Create a Container App Environment
This is the foundational resource where your Container Apps will run.
az containerapp env create --name my-container-app-env --resource-group my-resource-group --location eastus
2. Build and Push Your Container Image
Ensure your application is containerized. You can use Dockerfiles.
Push your image to a container registry like Azure Container Registry (ACR) or Docker Hub.
3. Create a Container App
Deploy your container image to the environment.
az containerapp create --name my-app --resource-group my-resource-group --environment my-container-app-env --image myacr.azurecr.io/myapp:v1 --target-port 80 --ingress external --query configuration.ingress.fqdn
This command creates a container app named my-app, pointing to your container image. --ingress external makes it accessible from the internet.
Advanced Features
Traffic Management
You can control how traffic is routed to different revisions of your application.
# Set 80% of traffic to revision 1, 20% to revision 2
az containerapp update --name my-app --resource-group my-resource-group --revision-weight '{"revision1": 80, "revision2": 20}'
Scale to Zero
Configure your application to scale down to zero instances when it's not receiving traffic, saving costs. This is often achieved using KEDA triggers.
{
"scale": {
"minReplicas": 0,
"maxReplicas": 10,
"pollingInterval": 30,
"targetCPU": 70,
"targetMemory": 70,
"kedaConfig": {
"maxReplicaCount": 10,
"minReplicaCount": 0,
"httpConfig": {
"public": true,
"targetPort": 80
},
"triggers": [
{
"type": "http",
"metadata": {
"queueLength": "100"
}
}
]
}
}
}
Dapr Integration
Enable Dapr for your Container App to leverage patterns like service invocation, state management, and pub/sub messaging.
az containerapp update --name my-app --resource-group my-resource-group --dapr true
Learn More
- Official Azure Container Apps Documentation
- Dapr on Azure Container Apps
- KEDA Autoscaling with Azure Container Apps