Microservice communication via gRPC and .NET Aspire
Returning and receiving data from the client is one thing, but what if our API needs to talk to another API or other backend service? That’s where gRPC comes in – the industry standard for passing messages between backend services (East-West traffic). We will leverage .NET Aspire orchestration and service discovery, while retaining the lower-level control of inter-service message communication, by setting up our own gRPC channel. This channel will pass messages between BooksAPI and a new InventoryService whenever a new book is created.
Getting ready
The starter project for this recipe can be found here: https://github.com/PacktPublishing/ASP.NET-9-Web-API-Cookbook/tree/main/end/chapter11/gRPCAspire.
It is recommended that you have the grpcurl CLI tool installed in your terminal per the Technical requirements section of this chapter. While we’ll use PowerShell to test our REST endpoints, we’ll need...