Member-only story

Communication between microservices using typed clients and Dapr — Part 2

Ashwin Kumar
6 min readFeb 28, 2021

In Part 1, we looked into how we can call across microservices using a strongly typed client generated by using Swagger and NSwag. In this post, we will look into using Dapr for service discovery and how this simplifies the process.

Dapr, the distributed application runtime, has many great features available out of the box. We will be using the service invocation building block to call our User API from the Registry API to validate the user.

The first step is to install the Dapr CLI. The instructions to install the cli can be found here. After installing the CLI, initalize it using the steps documented here. Ensure that the CLI is installed and intialized before proceeding to the next step.

We will use the same source code as before with the Registry and the User APIs which can be found here. Switch to the branch dapr-step (git checkout dapr-step) to view the source code.

The Registry API now has two new libraries installed,

Note: We will not be using the NSwag generated client from the previous blog post but will be using the Dapr client instead, to make the call to the user microservice.

The User API does not have the Dapr client SDKs installed since we dont need it. Instead of running the

--

--

Ashwin Kumar
Ashwin Kumar

Written by Ashwin Kumar

Full stack developer. Tech blogger. Gamer. Dad.

No responses yet