This example demonstrates step by step to create, run, deploy and consume a gRPC service in .NetCore 3.0.
Whole process is has been categorized in 3 main section **Create, Test and Deploy**.
There are seperate(detailed) document for each process describing step by step(from scratch). Each document starts for scratch till end. So read each steps carefully Detailed document for:
- How to Create grpc in C# (.NET Core 3.0)
- How to Test using grpcurl
- How to Deploy in Azure Kubernetes (aks)
- You have a latest version of Visual studio.
- You have a .NET Core 3.0 installed.
- Its good to have Visual Studio Code.
- You have an Azure Subscription. Free $200 Azure Credit
- You have an image repository (this example used Azure container registry)
- Create a gRPC service using default template of Visual Studio
- Add a Service (named CalculationService)
- Register reflection in Startup.cs (install Nuget Grpc.Reflection)
For very detailed explanation of visit how to setup gRPC server in .NET
The sample application SampleGrpcService
Deploy to Aks For step by step explanation on how to setup aks
kubernetes configs yaml files
To test gRPC service, we'll use the grpcurl utility:
- Download grpculy utiltiy
- Run following commands
grpcurl servername:port list (for ex: grpcurl localhost:50051 list )
grpcurl servername:port list packagename.servicename (for ex: grpcurl localhost:50051 list Services.Calculator)
grpcurl servername:port describe packagename.servicename.MethodName (for ex: grpcurl localhost:50051 describe Services.Calculator.AddNumbers)
grpcurl -d '{requestbody}' servername:port packagename.servicename.MethodName (for ex: grpcurl -d '{"firstNumber":5,"secondNumber":3}' localhost:50051 Services.Calculator/AddNumbers)
For detailed explanation and troubleshotting grpcurl
Github grpc project https://github.com/grpc/grpc/tree/master/src/csharp
Why grpc service cannot be deployed on Azure Appservice (for windows and linux both) grpc/grpc-dotnet#578, dotnet/aspnetcore#9020 (comment)