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.

This service is ideal for event-driven applications, microservices, and APIs that need to scale automatically.

Key Concepts

Getting Started

To get started with Azure Container Apps, you'll typically need:

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
        
Always consider security implications when exposing your Container Apps to the internet. Use network restrictions and authentication mechanisms.

Learn More

Back to Developers