
Learn to build high-performance inter-service communication with gRPC in asp.net core 5, using protoBuf, http/2, and server and client streaming across product, shopping cart, and discount services.
Learn gRPC from scratch with no prior knowledge, build on basic C# and asp.net core, fork the run-aspnet-grpc repo, and practice with visual studio 16.8, .NET 5, and grpcurl.
gRPC is an open source RPC framework developed at Google that connects microservices with high performance over HTTP/2. It uses Protocol Buffers to define contracts and generate cross-language bindings.
Discover how gRPC lets a client call a remote server like a local object, enabling distributed applications. Define services with methods, parameters, and return types, with language-agnostic clients and servers.
Explore protocol buffers, the default data serialization used by gRPC, by defining messages in .proto files. Generate access classes with the protocol buffer compiler and implement RPC services in proto3.
Explore gRPC method types and rpc life cycles, including unary, server streaming, client streaming, and bidirectional streaming RPCs, with emphasis on message ordering, read/write streams, and independent data flows.
Learn the gRPC development workflow: contract-first proto definitions, Protocol Buffers, protoc-generated data access classes, and implementing logic by consuming gRPC services with a C# client.
Discover the advantages of gRPC, including HTTP/2 performance gains and binary serialization that reduces bandwidth versus JSON. Leverage multi-language support, open-source community, bidirectional streaming, and SSL/TLS with authentication options.
Compare gRPC and REST, showing how protobuf benefits compact messages and faster communication, with contract-driven code generation and client-side encoding/decoding, eliminating cross-language serialization.
Discover gRPC for microservices, covering synchronous backend calls, polyglot environments like Python and C#, low latency, high throughput, and bi-directional streaming.
Explore a practical example of gRPC in microservices communication in .net 5: a shopping aggregator acts as a gRPC client, synchronously calling backend services with HTTP/2 and protocol buffers.
Explore gRPC with .NET 5, leveraging HTTP/2, Kestrel, and built-in .NET Core SDK tooling, with cross-platform support and generated client and server code.
gRPC performance in .NET 5 shows robust requests-per-second benchmarks, with the server 60% faster than .NET Core 3.1 and the client 230% faster, for scalable backend microservices.
Explore how to build gRPC in Asp.Net 5 projects by creating a HelloWorld api, developing a protobuf file for a contract-first api, and implementing a gRPC service with dependency injection.
Create an empty asp.net core web project and convert it into a gRPC api server using .net 5, adding the Grpc.AspNetCore package and a hello.proto contract in a protos folder.
Develop a hello.proto protobuf file for a gRPC contract-first API, defining HelloService with SayHello, HelloRequest, and HelloResponse in proto3, then generate C# proto classes in a .NET 5 project.
Inherit the generated gRPC service class and override the SayHello method to implement server logic, using asp.net features and dependency injection, to return a HelloResponse with a Hello message.
Configure gRPC in an ASP.NET project by registering dependency injection with AddGrpc in Startup.ConfigureServices and mapping the gRPC service in Startup.Configure endpoints to run as a gRPC server.
Run a gRPC server by switching from IIS Express to Kestrel, expose http2 gRPC services on port 5001, disable browser launch, and apply macOS workaround for unsecured http2 with Kestrel.
Create a GrpcHelloWorldClient console application in C# to call a gRPC server, generating a client from proto definitions, configuring packages, and aligning target framework.
Consume the Grpc HelloService API from a client console application by creating a GrpcChannel and a HelloServiceClient. Send a HelloRequest via SayHelloAsync and display the server's response.
Scaffold a gRPC server quickly using Visual Studio's gRPC Service template, generating code from proto files, including greet.proto, and startup configurations for http2 with asp.net core.
Create a gRPC client for a gRPC server using .NET 5. Generate client scaffolding from the server and wire the client to call the service.
Consume the Grpc GreeterService API from a client console application using GrpcChannel, connect to the server, send a hello request, and read the reply with debugging and breakpoints.
Please refer this article for Test gRPC services with gRPCurl in ASP.NET Core
https://docs.microsoft.com/en-us/aspnet/core/grpc/test-tools?view=aspnetcore-5.0
Perform service discovery using grpc reflection with the grpcurl command-line tool. Register the reflection package in startup, configure endpoints, and describe services and methods on the local server for testing.
Build product gRPC microservices to expose crud apis over http/2. Outline architecture, code-first in-memory database, proto files, and gRPC service implementation for inter-service communication.
Create a new solution and gRPC-based ASP.NET Core microservice project, configure dependencies, protoc, and Kestrel hosting, and verify endpoints expose the gRPC service on port 5001.
Set up a product database for a gRPC microservice using EF Core in-memory database in a .NET 5 project, define Product and ProductsContext, and configure use in-memory database named 'Products'.
Seed an in-memory product database in a .NET 5 gRPC microservice by creating a product context and seeding initial data at startup through dependency injection.
Develop a proto file to expose CRUD services for products using gRPC in .Net 5, defining product messages and server streaming to get all products with client streaming bulk inserts.
Generate the proto service class from the product proto file in the product gRPC microservice by importing google protobuf well-known types and configuring the proto.
Develop a gRPC product service class, inject the database context and logging, implement the get product method, and map data to a product model.
Create a client console application to consume product gRPC microservices by linking connected services, generating a client from the ERP service, installing NuGet packages, and inspecting the generated client classes.
Explore how to consume the GetProductAsync method via gRPC from a client console app using a channel and product service client in a .NET 5 microservices setup.
Develop a server streaming GetAllProducts method in ProductService using gRPC in a .NET 5 microservices architecture, returning a stream of product models to the client while iterating a product list.
Consume the get all products server streaming method from the client console app, iterating streaming responses from the product service and printing each product to the console.
Refactor the GetAllProducts server-streaming method in a .NET 5 gRPC client using C# 9 features like using declarations and await foreach for cleaner streaming.
Develop and implement the ProductService AddProduct server method in a .NET 5 gRPC microservice, mapping the product request to the product model and persisting it to the database.
Implement automapper in the product grpc microservice by mapping core product entities to product models, handling timestamp conversions, and configuring dependency injection in startup.
Consume the add product async gRPC method from a client console app by creating a product object with name, description, and price, receiving the new product id from the server.
Develop and implement ProductService UpdateProductAsync and DeleteProductAsync methods in a gRPC microservices setup using .NET 5. Map product models, verify existence, apply updates or deletions, and return a status response.
Explore exception handling in gRPC service methods of a .NET 5 product microservice, including not-found errors in the get product, and enable tracing, logging, and startup configuration for DI.
Learn to implement and configure logging in gRPC service methods within .NET 5 microservices, including log level settings, injecting ILogger, and using a logger factory.
Demonstrate consuming updateProductAsync and deleteProductAsync server methods from a client console to update a product and remove one, showing success responses in the console.
Develop a client-streaming insert bulk product method in a ProductService using gRPC and .NET 5, read client stream models, convert to core products, save to database, and return insert result.
Learn to consume a client streaming insert bulk product server method from a .NET 5 gRPC microservices client console app, including streaming multiple products and handling the server response.
Build a product worker service to generate and insert products into ProductGrpc microservices, consume gRPC methods, configure appsettings.json, generate products with ProductFactory, and implement logging on both client and server.
Create a product worker service project in a gRPC microservices solution, featuring a local time-interval worker with dependency injection, configuration, and logging, using appsettings.json for settings.
Add a connected service and portable file to the product worker service project to generate a client for consuming product services.
Set up appsettings.json configuration in a product worker service project, inject configuration via Microsoft.Extensions.Configuration, and access product parameters in code to retrieve values during run.
Learn how to consume a product grpc server method from a product worker client application in net 5 microservices, including channel creation, client setup, and invoking the get product method.
Focus on the big-picture logic to add products via gRPC in a .NET 5 microservice. It shows generating unique product names and inserting into the database.
Develop and wire a product factory in the product worker service to generate random products, register the factory in dependency injection, and insert created products.
Explore implementing and analyzing logging across the product worker service client and product gRPC server, including log levels, debug tracing, and observing production and replication interactions.
Build a shopping cart gRPC server using a code-first microservice approach, with an in-memory EF database, proto service generation, AutoMapper, and client streaming to add items and expose CRUD operations.
Create a shopping cart gRPC microservices project in a .NET 5 solution by organizing folders, scaffolding an ASP.NET Core gRPC service, and configuring Kestrel to use the http/2 protocol.
Create a gRPC microservice shopping cart using .NET 5 with an Entity Framework in-memory database, modeling shopping cart and shopping cart item with a configured context and dependency injection.
Seed an in-memory database for shopping cart data using Entity Framework Core in a .NET 5 gRPC microservice. Initialize seeding at startup to populate carts and items.
Develop a product.proto ProtoBuf file to expose crud services for a shopping cart using gRPC, defining shopping cart and item models, requests, responses, and syntax with namespace and repeated items.
Generate a proto service class from the shopping cart proto file in ShoppingCartGrpc to enable gRPC communication and generate service stubs for a .NET 5 project.
Develop a gRPC shopping cart service class in .NET 5 by inheriting the generated proto service, injecting the database context, and implementing the get shopping cart method with proper mapping.
Implement AutoMapper in the ShoppingCartService to map cart entities to gRPC models, by creating a ShoppingCartProfile, configuring item and cart mappings, and registering AutoMapper via dependency injection in startup.
Develop a gRPC shopping cart service in .NET 5 by implementing proto service methods, handling cart creation, item addition and removal, validation, logging, and returning cart models.
Develop and implement the AddItemIntoShoppingCart client-streaming gRPC server method to add items into a shopping cart, handling cart retrieval, item existence, quantity updates, discount checks, and persistence.
Build a discount gRPC microservice for inter-service communication to calculate each cart item price in the shopping cart, including creating proto definitions, implementing DiscountService, and wiring the client in startup.
Create a discount gRPC microservices project in a gRPC microservices solution by adding a new project under a solution folder, configure project settings, and prepare for database operations.
Develop a discount data model and context for a gRPC microservice in .NET 5, creating a discount entity with id and code and storing discounts in a static in-memory list.
Develop a new discount.proto ProtoBuf file to expose the get discount service in the discount ERP SeaMicro microservice, defining the request with a discount code and returning the discount id.
Generate a proto service class from the discount proto file in discount grpc, then build the .NET 5 project to produce the generated class and base class for discount service.
Develop a DiscountService class to implement gRPC proto service methods, read from a static discount data store, map to a discount model, and log operations during startup configuration.
Learn to consume a discount gRPC service from a shopping cart microservice by configuring connected services, generating a client from the discount proto, and invoking discount methods.
Consume the discount gRPC service from the shopping cart microservice to compute each cart item's final price during add operations using a generated client in .NET 5.
Register the discount gRPC client and discount service into the shopping cart DI, configure startup services, and wire endpoint addresses from configuration for inter-service communication.
Build a shopping cart worker service that retrieves products and adds items by consuming ProductGrpc and ShoppingCartGrpc microservices, using server and client streaming.
Create a shopping cart worker service in a gRPC microservices solution on .NET 5, running as a background service with dependency injection, configuration, and logging.
Add connected services and generate gRPC clients for the shopping cart worker service by integrating product and shopping cart services with portable proto files and client references.
Configure the shopping cart worker service with appsettings.json, inject configuration via Microsoft.Extensions.Configuration, and manage delay-based tasks for product and shopping cart integration.
Consume product and shopping cart gRPC server methods from a shopping cart worker by creating a channel and client, getting or creating a cart, retrieving products, and adding items.
Develop the shopping cart workflow by streaming products from the product service and streaming cart items into the cart service, creating the cart as needed.
Run grpc server microservices for product, shopping cart, and discount workloads, verify replication, and start multi project deployments to observe cart items and discounts.
Authenticate gRPC services with IdentityServer4 using OAuth 2.0 and JWT bearer tokens to secure ShoppingCartGrpc methods, and configure clients, resources, scopes, and test users.
Build a standalone identity server authentication microservice using IdentityServer4 to secure a shopping cart within a .NET 5 microservices setup, including project creation, port configuration, and launch settings.
Build IdentityServer4 authentication microservices to secure a shopping cart by implementing token generation, wiring dependency injection and middleware in startup, and securing the application with tokens.
Configure IdentityServer4 by adding a config class for clients, resources, and scopes, defining a shopping cart api scope, a shopping cart client, and protected resources for the gRPC microservices.
Secure shopping cart gRPC services in a .NET 5 microservices setup by integrating IdentityServer4 OAuth 2.0 and JWT, configuring authentication and authorization in startup and protecting the API with authorization.
Test access to shopping cart gRPC services in a multi-project microservices setup, create a shopping cart, add items, and validate token-based authorization to prevent unauthorized access.
Learn to obtain a token from an identity server and use it to call shopping cart grpc services with a jwt in a .net 5 microservices setup.
Learn how to pass a token in gRPC headers for shopping cart services in .NET 5, secure get-or-create operations, and add authorization metadata to gRPC calls.
Run an entire microservices application locally to see the big picture, starting the product, product worker, and shopping cart services, generating and consuming products to build a shopping cart.
Explore a .NET 5 microservices setup for gRPC bidirectional streaming, including token validation, shopping cart operations, and implementing a new support microservice for client-service bidirectional communication.
You will learn how to Build a high-performance gRPC Inter-service Communication between backend microservices with .Net 5 and AspNet 5.
Microservices are modern distributed systems so with gRPC in ASP.NET 5, we will develop high-performance, cross-platform applications for building distributed systems and APIs. It’s an ideal choice for communication between backend microservices, internal network applications, or iot devices and services. With the release of ASP.NET 5, Microsoft has added first-class support for creating gRPC services with Asp.Net 5.
This course will led you get started building, developing and managing gRPC servers and clients on distributed microservices architecture.
Overall Architecture of Course Project
We can design that we will have 6 microservices which we are going to develop one by one.
We will use Worker Services and Asp.Net 5 Grpc Applications to build client and server gRPC components defining proto service definition contracts.
We will implement realworld e-commerce use case with only gRPC communication. We will have 3 gRPC server applications which are Product — ShoppingCart and Discount gRPC services. And we will have 2 worker services which are Product and ShoppingCart Worker Service. Worker services will be client and perform operations over the gRPC server applications. And we will secure the gRPC services with standalone Identity Server microservices with OAuth 2.0 and JWT token.
ProductGrpc Server Application
First of all, we are going to develop ProductGrpc project. This will be Asp.Net gRPC server web application and expose apis for Product Crud operations.
Product Worker Service
After that, we are going to develop Product Worker Service project for consuming ProductGrpc services. This product worker service project will be the client of ProductGrpc application and generate products and insert bulk product records into Product database by using client streaming gRPC proto services of ProductGrpc application. This operation will be in a time interval and looping as a service application.
ShoppingCartGrpc Server Application
After that, we are going to develop ShoppingCartGrpc project. This will be Asp.Net gRPC server web application and expose apis for SC and SC items operations. The grpc services will be create shopping cart and add or remove item into shopping cart.
ShoppingCart Worker Service
After that, we are going to develop ShoppingCart Worker Service project for consuming ShoppingCartGrpc services. This ShoppingCart worker service project will be the client of both ProductGrpc and ShoppingCartGrpc application. This worker service will read the products from ProductGrpc and create sc and add product items into sc by using gRPC proto services of ProductGrpc and ShoppingCartGrpc application. This operation will be in a time interval and looping as a service application.
DiscountGrpc Server Application
When adding product item into SC, it will retrieve the discount value and calculate the final price of product. This communication also will be gRPC call with SCGrpc and DiscountGrpc application.
Identity Server
Also, we are going to develop centralized standalone Authentication Server with implementing IdentityServer4 package and the name of microservice is Identity Server.
Identity Server4 is an open source framework which implements OpenId Connect and OAuth2 protocols for .Net Core.
With IdentityServer, we can provide protect our ShoppingCart gRPC services with OAuth 2.0 and JWT tokens. SC Worker will get the token before send request to ShoppingCart Grpc server application.
By the end of this course, you will have a practical understanding of how to use gRPC to implement a fast and distributed microservices systems. And Also you’ll learn how to secure protected grpc services with IdentityServer in a microservices architecture.
Is this course for you?
This course is very practical, about 90%+ of the lessons will involve you coding along with me on this project. If you are the type of person who gets the most out of learning by doing, then this course is definitely for you.
Tools you need for this course
In this course all the lessons are demonstrated using Visual Studio 2019 as a code editor. You can of course use any code editor you like and any Operating system you like as long as it's Windows or Mac.