Book Image

Practical Microservices with Dapr and .NET - Second Edition

By : Davide Bedin
Book Image

Practical Microservices with Dapr and .NET - Second Edition

By: Davide Bedin

Overview of this book

This second edition will help you get to grips with microservice architectures and how to manage application complexities with Dapr in no time. You'll understand how Dapr simplifies development while allowing you to work with multiple languages and platforms. Following a C# sample, you'll understand how Dapr's runtime, building blocks, and software development kits (SDKs) help you to simplify the creation of resilient and portable microservices. Dapr provides an event-driven runtime that supports the essential features you need for building microservices, including service invocation, state management, and publish/subscribe messaging. You'll explore all of those in addition to various other advanced features with this practical guide to learning Dapr. With a focus on deploying the Dapr sample application to an Azure Kubernetes Service cluster and to the Azure Container Apps serverless platform, you’ll see how to expose the Dapr application with NGINX, YARP, and Azure API Management. By the end of this book, you'll be able to write microservices easily by implementing industry best practices to solve problems related to distributed systems.
Table of Contents (20 chapters)
1
Part 1: Introduction to Dapr
5
Part 2: Building Microservices with Dapr
11
Part 3: Deploying and Scaling Dapr Solutions

Using Azure Service Bus (ASB) in Dapr

To introduce the pub/sub building block of Dapr with the ASB implementation, we will develop, in C#, a prototype of a collaboration between some .NET microservices.

The following figure shows what we would like to accomplish:

Figure 6.2 – Pub/sub in Dapr with ASB

In Figure 6.2, we have the Order service interacting with the Shipping service via pub/sub; this is the portion we are going to develop.

In the chapter06 folder, you will find many projects. For now, we will focus on order-service (sample.microservice.order) and shipping-service (sample.microservice.shipping).

Important note: projects and solution

We created samples with several C# projects grouped in a solution, with separate projects for Data Transfer Objects (DTOs), a common library for constants, and so on, referenced by both the service and client projects.

Our intention was to organize the assets in a way that would be easy to consume...