From ebc3f8b3c5e85837d1557be015a71d059ddd01fb Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 2 Nov 2022 06:16:12 +0800 Subject: [PATCH] Add extra gRPC features to .NET 7 release notes (#27454) Co-authored-by: Wade Pickett --- aspnetcore/release-notes/aspnetcore-7.0.md | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/aspnetcore/release-notes/aspnetcore-7.0.md b/aspnetcore/release-notes/aspnetcore-7.0.md index 1f4c0ad84e..5f023aa7c2 100644 --- a/aspnetcore/release-notes/aspnetcore-7.0.md +++ b/aspnetcore/release-notes/aspnetcore-7.0.md @@ -208,6 +208,41 @@ gRPC JSON transcoding is an extension for ASP.NET Core that creates RESTful JSON For more information, see [gRPC JSON transcoding in ASP.NET Core gRPC apps](xref:grpc/json-transcoding?view=aspnetcore-7.0) and . +### gRPC health checks in ASP.NET Core + +The [gRPC health checking protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md) is a standard for reporting the health of gRPC server apps. An app exposes health checks as a gRPC service. They are typically used with an external monitoring service to check the status of an app. + +gRPC ASP.NET Core has added built-in support for gRPC health checks with the [`Grpc.AspNetCore.HealthChecks`](https://www.nuget.org/packages/Grpc.AspNetCore.HealthChecks) package. Results from [.NET health checks](xref:host-and-deploy/health-checks) are reported to callers. + +For more information, see . + +### Improved call credentials support + +Call credentials are the recommended way to configure a gRPC client to send an auth token to the server. gRPC clients support two new features to make call credentials easier to use: + +* Support for call credentials with plaintext connections. Previously, a gRPC call only sent call credentials if the connection was secured with TLS. A new setting on `GrpcChannelOptions`, called `UnsafeUseInsecureChannelCallCredentials`, allows this behavior to be customized. There are security implications to not securing a connection with TLS. +* A new method called `AddCallCredentials` is available with the [gRPC client factory](xref:grpc/clientfactory). `AddCallCredentials` is a quick way to configure call credentials for a gRPC client and integrates well with dependency injection (DI). + +The following code configures the gRPC client factory to send `Authorization` metadata: + +```csharp +builder.Services + .AddGrpcClient(o => + { + o.Address = new Uri("https://localhost:5001"); + }) + .AddCallCredentials((context, metadata) => + { + if (!string.IsNullOrEmpty(_token)) + { + metadata.Add("Authorization", $"Bearer {_token}"); + } + return Task.CompletedTask; + }); +``` + +For more information, see [Configure a bearer token with the gRPC client factory](xref:grpc/authn-and-authz#bearer-token-with-grpc-client-factory). + ## SignalR ### Client results