Problem
This first part of this series was a guide to create and deploy Bicep templates. These templates will be used to deploy a microservices application with Azure Container Apps and Dapr. As raised in the previous article, building a microservice application requires a plan to tackle the inter-microservice communication problem that comes with having a distributed system.
Solution
Using Azure Container Apps and Distributed Application Runtime (Dapr) can solve this issue by enabling you to containerize each microservice as a separate application. Using container apps enables you to host all your applications on Azure’s cloud solutions.
Dapr is built-in to Container Apps enabling you to use the Dapr API building blocks without any manual deployment of the Dapr runtime. You simply deploy your services with their Dapr components enabled. This means you can create Dapr components for your application directly.
Prerequisites
- Node.js
- Azure free account (signup here)
- Visual Studio Code (latest)
- Dapr CLI
Azure Container Apps
Azure Container Apps is a serverless platform that enables you to create containerized applications with preset networking, server configuration, container orchestration, and deployment details, which means you get to worry less about the application’s infrastructure. Container Apps provide benefits of running containers without manually configuring cloud infrastructure and complex container orchestrators.
Azure Container Apps are deployed as microservices, composed of one or more containers. Azure Container Apps have all the basic features to run microservices, the use of Dapr enhances the application’s functionality. This provides features like observability, pub/sub, and service-to-service invocation.
There are different ways to deploy an Azure container app. These include the Azure CLI, Azure portal, and Infrastructure as code (IaC). In this tutorial, we use IaC which ensures every deployed container environment is consistent, reproducible, and version-controlled.
Distributed Application Runtime (Dapr)
Dapr is an open-source runtime system that makes it easier to develop microservice-based, cloud applications. This solves distributed application problems like inter-service communication, authentication, and storage. Dapr codifies the best practices for building microservice applications into open, independent APIs called building blocks. This article focuses on the Publish Subscribe (pub/sub) API. Pub/Sub is a loosely coupled messaging pattern where senders (or publishers) publish messages to a topic, to which subscribers subscribe.
This article makes use of Dapr’s Pub/Sub API to make a network call to Dapr’s Pub/Sub building block, which makes a call to Dapr’s Pub/Sub component. Dapr is responsible for sending and receiving the message to and from the message broker which is Azure Service Bus in this instance.
Microservice Communication using Publisher / Subscriber (Async)
In this tutorial, we will create a publisher microservice and a subscriber microservice. Then use Dapr to implement the publish-subscribe pattern. These services will communicate with each other via Azure Service Bus, which creates a Service bus topic for services to publish and subscribe to:

On the broader scale, this Azure Service Bus acts as an intermediate between the microservices. The checkout service sends a message to Azure Bus Service’s Order topic via Dapr’s Pub/Sub system, and the order-process service will subscribe to the same Order topic to receive messages:

The Container App communicates with Dapr’s sidecar which uses Azure Service Bus as the message broker.
Dapr Components
Dapr uses a modular design where functionality is delivered as a component. Components have interchangeable interfaces definitions and you can even contribute or create your own interfaces using the components-contrib repository or pluggable components.
Dapr components make up Dapr’s Building blocks. You can check which components are offered on your hosting platform using the dapr command: dapr components
Since components are exchangeable and loosely coupled to integrate with multiple brokers to offer the same functionality, it is important to configure your components to suit your application’s requirements.
In the component configuration file, note that the metadata spec value defines the technology to be integrated with the component since a single component can cater to multiple technologies:

In this tutorial, you will be using the Azure Service Bus as the pub/sub broker.
Dapr Building Blocks
A building block is an HTTP or gRPC API that can be called from your application. A building block houses multiple components pre-configured to work together for a desired functionality. This tutorial makes use of the pub/sub building block which has a list of components written in GO.
Azure Service Bus
Azure Service Bus is a message broker that can manage message queues and publish-subscribe topics. This tutorial focuses on topics and this is how they work:

A topic can receive a message from one producer and broadcast it to multiple subscribers. A subscription is durable by default and can be altered to expire. The job of the producer is to send messages to the topic and the subscriber’s job is to get a copy of the message in the topic it’s subscribed to. A filter may be placed on a subscriber to filter messages it copies from the topic.
Azure Container Registry
An Azure Container Registry (ACR) is a managed, private Docker registry service provided by Azure. This stores and manages container images (such as Docker images) and other artifacts like Helm charts or Open Container Initiative (OCI)-based artifacts.
ACR plays a key role in microservices deployment by serving as a secure, private repository for storing and managing container images. It allows microservices to be organized into individual repositories, ensuring that each microservice has its own set of container images. ACR integrates seamlessly with Azure services like Container Apps and Azure App Services, enabling continuous integration and deployment (CI/CD) workflows. This simplifies updating, scaling, and deploying microservices across different environments while ensuring security through role-based access control (RBAC) and network security features like private endpoints.
To put it visually, this is the role ACR plays in the architecture of your application:

Dapr Sidecars
Dapr exposes its HTTP and gRPC APIs as a sidecar architecture, either as a container or as a process, not requiring the Azure container apps code to include any Dapr runtime code.
In a microservices deployment, Dapr injects a sidecar container into each service, which acts as a proxy and facilitates communication between services. Each microservice in a Dapr-enabled architecture is typically containerized and stored in ACR:

As you can see, Dapr Sidecars run along the microservices and aids them with pub/sub communication.
Setting Up the Application
The microservice application we are developing must have a set distributed application communication plan in place and this is how we plan to establish communication between different microservices/container apps:

You will create a container apps environment and this environment will house the container apps. These apps will be configured with Dapr enabled when deployed. Having Dapr enabled will ensure that the sidecars are automatically deployed with the container apps. The Azure Service Bus will enable the container apps to communicate with each other using the pub/sub technique.
Conclusion
This tutorial has provided an overview of the main technologies that will enable you to create a microservice application using Azure Container Apps and Dapr. These tools allow us to design an architecture for our application and we can use Bicep to create templates for Azure infrastructure and services we will need for our application.
The next part of this series will use Bicep to start writing code for the application and infrastructure with the goal of creating the architectures we discussed in this tutorial.
Next Steps
- Learn more about Serverless Microservice Computing Concepts and Architecture.
- Learn how to Connect to and Monitor SQL Server Azure Container Instances ACI.
- Learn how you can Move an On-Premises SQL Server Database to the SQL Azure Cloud.
- You can Compare SQL Server Offerings by Top Cloud Providers – Azure, AWS and Google Cloud.