Implementing Microservices with gRPC and .NET Core 3.0

Check out this tutorial on what gRPC is and how you can use it in .NET Core 3.0 to build efficient microservices.

Read on :rocket:

1 Like

Let us know your thoughts and opinions once you have a chance to go through the article!

I was hoping to see how you would secure a gRPC connection with Auth0. That would make sense to me for an article coming from Auth0. Currently it’s just another tutorial on how to use gRPC.

2 Likes

Hey there @tvdh! That’s a good thought! Let me tag here @andrea.chiarelli the author of the article to see if we have any plans of releasing the kind of content you mentioned. Thank you!

1 Like

Hi @tvdh,
You are right. This is just a tutorial on using gRPC in .NET Core with the new native support.
Focusing on authentication with gRPC could be the topic of a future article.
Thanks for your contribution.

2 Likes

We’ll let you know @tvdh once we have such article!

1 Like

I’m trying to secure .NET Core wiht Auth0, but the cord on the blog is not working. Here comes my error when I dotnet run on gRPC service.

Startup.cs(17,40): error CS0103: 現在のコンテキストに ‘Configuration’ という名前は存在しません。 [/Users/hisashiyamaguchi/grpc-dotnet/CreditRatingService/CreditRatingService.csproj]
Startup.cs(20,71): error CS1061: ‘object’ に ‘AuthenticationScheme’ の定義が含まれておらず、型 ‘object’ の最初の引数を受け付けるアクセス可能な拡張メソッド ‘AuthenticationScheme’ が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足していないことを確認してください。 [/Users/hisashiyamaguchi/grpc-dotnet/CreditRatingService/CreditRatingService.csproj]
Startup.cs(21,68): error CS1061: ‘object’ に ‘AuthenticationScheme’ の定義が含まれておらず、型 ‘object’ の最初の引数を受け付けるアクセス可能な拡張メソッド ‘AuthenticationScheme’ が見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足していないことを確認してください。 [/Users/hisashiyamaguchi/grpc-dotnet/CreditRatingService/CreditRatingService.csproj]

ビルドに失敗しました。ビルド エラーを修正して、もう一度実行してください。

I’m sorry it’s Japanese, but it seems it’s needed to include further packages on gRPC service.

Hi @hisashiyamaguchi,
The blog post doesn’t cover the integration of gRPC with Auth0.
Maybe you are trying to apply to gRPC the standard approach used for Web APIs, right? If so, it doesn’t work.
I intend to write a blog post about authentication and authorization with gRPC, but currently I don’t know when it will be possible.
Please, stay tuned. I will let you know here when that blog post will be published.

I tried with Visual Studio Code. While running the client, I received an error:
Unhandled exception. Grpc.Core.RpcException: Status(StatusCode=Internal, Detail=

Error starting gRPC call: The SSL connection could not be established, see inner exception.

To solve the Visual Studio Code-related issue or because the dotnet development certificates are not set to be trusted, I ran command
dotnet dev-certs https --trust
in the terminal before running dotnet run
Hope this hint help others tumbling with the same same issue.
BTW, thank you for sharing this well-written article! :smiley:

1 Like

Hey there @khoas!

I’m sure Andrea will address that once he’s online!

Hi @khoas,
Thank you for sharing this valuable suggestion.
For completeness, the issue is not related to Visual Studio Code. It is a by-design behavior of the .NET Core SDK. As you pointed out, the HTTPS development certificate needs to be trusted before running any HTTPS-based application (not just gRPC).
This is a one-time operation. More info here.

Hi

I am getting below exception - have followed the the code correctly - have also tried amendinh Https to Http but to no avail…

Any suggestions appreciated…

Hi @akshay,
Welcome to the Auth0 Community.
Assuming that the server is running, the exception you get usually happens for a couple of reasons:

  • a firewall is blocking the connection
  • the server is listening to a different port

Can you ensure that the server is listening to the same port used by the client?
Also, you didn’t specify your operating system. Please, take into account the limitations on macOS and older Windows versions explained in the article.

Hi @andrea.chiarelli

I am able to use that port in other applications successfully - doubt it’s a firewall issue.

As required I start the Service first and error occurs straight away…I don’t get to starting the Client.

Windows 10 OS

Sorry, @akshay. No other idea about the cause of the issue.
Just another tip, although the error message should have been different, have you trusted the dev certificate as suggested here?

Hey @hisashiyamaguchi and @tvdh,
A tutorial about securing gRPC with Auth0 is online. Please, check out it: Securing gRPC-based Microservices in .NET Core

2 Likes

If you guys have any questions regarding that please add them in there!

Hello,

When trying to run the client example, I get the following error:

Unhandled exception. Grpc.Core.RpcException: Status(StatusCode=Internal, Detail=“Bad gRPC response. Response protocol downgraded to HTTP/1.1.”)
at GrpcGreeterClient.Program.Main(String args) in C:\Source\Core\grpc-dotnet\CreditRatingClient\Program.cs:line 18
at GrpcGreeterClient.Program.(String args)

Any idea how to fix?

Thanks!

—NickS

Hi @SuschNL,
Thank you for reading this article.
Regarding your error, are you running TLS both on the client and the server? Or, if you are using a Mac, have you disabled TLS both on the client and the server?
Do you get the same error with the projects downloaded from the GitHub repository?
Please, let me know if the checks above help you to fix the issue.

Hi Andrea,
Thanks for your post, it is wonderful !
Is there a way to easily use your exemple/libraries in a Xamarin.Forms project ?
Thanks