Member-only story

Communication between microservices using typed clients and Dapr — Part 1

Ashwin Kumar
6 min readFeb 28, 2021

In the world of .Net APIs, communication between microservices can be achieved using multiple techniques, either by using the httpClient directly or considering an approach using GRPC. In this two-part series, we will be first looking at how this kind of communication can be achieved using typed rest clients built with swagger and NSwag, and in the second part, we will be using Dapr to show an alternative way of achieving the same. Hopefully, at the end of this excercise, we’ll be able to understand the two techniques and the problems they are attempting to solve.

The application we will be using to demonstrate these techniques is a simple gift registry where a user can register for gifts and another valid user can sign up to buy a gift. We can create two microservices, one to manage the registry and another one to manage users. The source code is available here. Switch to the branch “Step1” (git checkout Step1) which contains the base solution.
When creating these projects using the visual studio template, it is important to ensure that the option “Enable OpenAPI support” is selected, like so,

Creating an ASP.Net project using the visual studio template

The project structure and startup projects for the Registry API in the “Step1” branch looks like this,

--

--

Ashwin Kumar
Ashwin Kumar

Written by Ashwin Kumar

Full stack developer. Tech blogger. Gamer. Dad.

No responses yet