Skip to main content
In this lesson, we explore Azure Container Apps—a robust serverless platform designed for running microservices and containerized applications. This service integrates with Azure Kubernetes Service (AKS) to deliver scalability, streamlined development, and minimal management overhead.

Key Differences from Azure Container Instances

Azure Container Apps offers several advantages compared to Azure Container Instances by acting as an orchestrator with advanced features:
  • Dynamic Scaling with KEDA:
    Azure Container Apps leverages Kubernetes Event-Driven Auto Scaling (KEDA) to automatically scale applications based on CPU, memory usage, or external event triggers such as message queues.
  • Deployment to a Single Environment:
    All containerized applications are deployed within a secure, isolated environment, ensuring safe and reliable communication among apps.
  • Independent Service Development:
    Utilizing a microservices architecture, container apps can be developed, updated, and scaled independently which reduces risk and increases flexibility.
  • Native Dapr Integration:
    Built-in support for the Distributed Application Runtime (Dapr) simplifies microservices development with APIs for Pub/Sub messaging, service invocation, and state management, helping you construct resilient and scalable applications.
The image describes three features of Azure Container Apps: dynamic scaling with KEDA, deployment to a single environment, and independent development and scaling of core functionalities.
The image describes four features of Azure Container Apps: dynamic scaling with KEDA, deployment to a single environment, independent development and scaling, and native Dapr integration.

Container Structure and Pods

Azure Container Apps uses scalable architectures where containers are grouped into pods—logical units in Kubernetes that share resources and network namespaces. A common design pattern is the sidecar model, which adds auxiliary functionalities like logging, monitoring, and inter-service communication to support the main container service.
The image illustrates the structure of containers in Azure Container Apps, showing two container apps, each with two revisions and replicas containing containers.

Working with Container Images and the Azure Portal

Azure Container Apps enables secure deployment of container images stored in private registries such as Azure Container Registry (ACR). By configuring the proper credentials, you ensure that sensitive container images remain protected during the deployment process. For example, consider the deployment of the Airport Codes API. This API reads a JSON file and has been containerized using the following Dockerfile:
A snippet from the API code is shown below:
The build output confirms the successful creation of the image:
The API utilizes a JSON file to provide airport codes, as shown below:
Additional run logs provide further confirmation of the build:

Deploying to Azure Container Apps

Next, you’ll deploy the web API to Azure Container Apps using the Azure CLI. While the Azure Portal provides a user-friendly, click-based experience, the Azure CLI offers more control over your deployment.

Step 1: Create a Resource Group

Create a resource group to consolidate your Azure resources:
The output confirms that the resource group has been created successfully.

Step 2: Create a Container Apps Environment

Establish a secure, isolated environment in which your container apps will run:

Step 3: Create the Container App

Deploy the container app using your published image with the following command:
This command sets the target port to 80 and exposes the application externally. The registry credentials securely pull the container image from the ACR. After running the command, verify the container app’s status in the Azure Portal, where you will see details such as the app name, size, and URL for accessing your application.
The image shows a Microsoft Azure portal interface for managing a container app named "airportcodeapiapp," displaying its properties and container details.
If the target port does not match the port that your application is listening on (for example, if your project uses port 8080), update your application’s configuration accordingly. Alternatively, create a second container app with the correct port mapping.
Create a second container app as follows:
After deployment, verify that the container app revisions and replicas are running correctly in the Azure Portal. Access the application URL with the appropriate API path (e.g., /api/airport-codes) to display the list of airport codes:

Next Steps

Now that your container app is successfully deployed, consider implementing authentication and authorization to secure your API and ensure that only authorized users have access. By following these steps, you have learned how to build a container image, push it to Azure Container Registry, and deploy it as an Azure Container App using the Azure CLI. Enjoy building resilient and scalable applications on Azure Container Apps!

Additional Resources

Watch Video