Building Microservices Apps with Azure Container Apps and Dapr

This post was originally published on by Taiseer Joudeh

There is no doubt that building containerized applications and following microservices architecture is one of the most common software architecture patterns observed in the past couple of years.

Microsoft Azure offers different services to package, deploy and manage cloud-native applications, each of which serves a certain purpose and has its own pros and cons. The following link provides a good comparison between the available services to host and manage cloud-native containerized applications in Azure.


From personal experience, I have built and deployed cloud-native apps on Azure Kubernetes Service (AKS) and on RedHat OpenShift and there was a learning curve needed when it comes to creating and configuring the cluster, configuring networking between microservices, services discovery, certificates provisioning, and lastly managing the cluster over the lifetime of the application.

In this detailed tutorial, we will be focusing on the new containerization service offered by Microsoft Azure which is Azure Container Apps (ACA). Microsoft announced the public preview of Azure Container Apps back in Nov 2021 and in May 2022 it announced the General Availability of Azure Container Apps. In brief Azure Container Apps is a fully managed serverless container runtime for building and running cloud-native applications which focuses on the business logic of the apps rather than on cloud infrastructure management.

The source code for this tutorial is available on GitHub. You can check the demo application too.

What is Azure Container Apps?

Azure Container Apps provide a serverless hosting service built on the foundation of AKS, allowing developers to deploy multiple containers without dealing with the underlying infrastructure. Some of the distinctive features of Azure Container Apps are:

– Building microservices applications with Dapr

Azure Container Apps provides built-in compatibility with the Microsoft-sponsored open-source project, Dapr (Distributed Application Runtime). Once Dapr is enabled it will allow building loosely-coupled applications with resilience and scalability in mind.

– Autoscaling in Azure Container Apps

Azure Container Apps supports scaling applications to meet demand from zero instances up to the maximum number of instances configured on the scaling rule, this means that in some services, it can go to 0 replicas if there are no events triggered or no requests received, this means that no cost is incurred.

There are different scaling triggers supported in Azure Container Apps such as:

  • Saling based on the number of concurrent HTTP requests
  • Scaling based on the CPU and Memory usage of the Container App
  • Event-driven scaling with the support of KEDA (Kubernetes Event-driven Autoscaling)

– Networking capabilities with Envoy Proxy

All incoming HTTP requests coming to Azure Container Apps are routed via Envoy proxy, this advanced proxy provides advanced features such as traffic splitting between different versions of your container apps to enable features such as A/B testing and blue/green deployments.

Azure Container Apps use cases we will cover in this tutorial

In this tutorial we will build a tasks management application following the microservices architecture pattern, this application will consist of 3 microservices and each one has certain capabilities to show how Azure Container Apps and Dapr can simplify the building of a microservices application. Below is the architecture diagram of the application we are going to build in this tutorial:

Azure Container Apps Architecture for building Microservices using dapr
  • Web App front-end application that accepts requests from users to manage their tasks.
  • Backend Web API which contains the business logic of tasks management service and data storage.
  • An event-driven backend processor which is responsible for sending emails to task owners based on messages coming from Azure Service Bus Topic.
  • Continuously running background processor to flag overdue tasks running continuously based on Cron timer configuration.
  • Use Azure Container Registry to build and host container images and deploy images from ACR to Azure Container Apps.

Dapr Integration with Azure Container Apps in this tutorial

Dapr provides a set of APIs that simplify the authoring of microservice applications, once Dapr is enabled in Azure Container Apps, it exposes its APIs via a sidecar (a process that runs together with each Azure Container App), The Dapr APIs/Building Blocks used in this tutorial are:

  • Service to Service invocation: Frontend Web App microservice invokes the Backend Web API microservice using Dapr sidecar.
  • State Management: Backend API stores data on Azure Cosmos DB and store email logs on Azure Table Storage using Dapr State Management building blocks.
  • Pub/Sub: Backend API publishes messages to Azure Service Bus when a task is saved and a Backend processor microservices consumes those messages and sends emails using SendGrid.
  • Bindings: The backend processor is triggered based on an incoming event such as a Cron job.

Overview of Azure Container Apps Components

The main components of Azure Container Apps are:

Azure Container Apps Components
  1. Environments in Azure Container Apps
    • The Environment is a secure boundary around several “Container Apps”, It contains at least one single container app or many, all container apps within an environment are deployed into a dedicated Azure Virtual Network, which makes it possible for these different container apps to communicate securely. As well all the logs produced from all container apps in the environment are sent to a dedicated Log Analytics workspace. and makes it possible for these different container apps to communicate, much like an App Service Environment when using Azure App Services
  2. Log Analytics workspace in Azure Container Apps
    • Used to provide monitoring and observability functionality, each environment will have its own Log Analytic workspace and will be shared among all container apps within the environment.
  3. Container Apps in Azure Container Apps
    • Each Container App represents a single deployable unit that can contain one or more related containers (More than one container is an advanced use case, for this tutorial we will deploy a single container in each container app, more about multiple containers in the same single Azure Container App can be found here)
  4. Revisions in Azure Container Apps
    • For each container app, you can create up to 100 “revisions”. Revisions are a way to deploy multiple versions of an app where you have the option to send the traffic to a certain revision. You can select if revision mode will support 1 active revision or multiple active revisions at the same time to support A/B testing scenarios or canary deployments.
  5. Containers in Azure Container Apps
    • Containers in the Azure Container Apps are grouped together in pods inside revision snapshots, containers can be deployed from any public or private container registry, and they support any Linux-based x86-64 (linux/amd64) container image (Windows containers are not supported)

In the upcoming posts, we will start building the application and microservices gradually where I will walk you through the code, deployments, and configuration step by step.

I broke down this series into multiple posts which I’ll be posting gradually, posts are:

All the source code for this series is available on GitHub, you can download it locally or you can fork it. If there is nothing clear or ambiguous, please drop me a comment and I’ll do my best to reply to your questions.

To get the best out of this tutorial I recommend you follow the posts one by one. Happy coding and hopefully this series will help you to get started with Azure Container Apps and Dapr!

The source code for this tutorial is available on GitHub. You can check the demo application too.


Leave a Reply