I deployed into Azure App Service a .NET 7 sample hello gRPC API on Linux OS
public class GreeterService : Greeter.GreeterBase
{
private readonly ILogger<GreeterService> _logger;
public GreeterService(ILogger<GreeterService> logger)
{
_logger = logger;
}
public override Task<HelloReply> SayHello(HelloRequest request,
ServerCallContext context)
{
_logger.LogInformation("Saying hello to {Name}", request.Name);
return Task.FromResult(new HelloReply
{
Message = "Hello " + request.Name
});
}
}
It is functioning properly and responding with the Hello greeting after I called it using Postman.
Now that I've attempted to use the built-in Authentication functionality on Azure App Service with Microsoft Identity Platform, I haven't encountered any problems using Postman to call it without authentication.
Did you realize that gRPC is compatible with Azure App Service Authentication?
This is my appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http2"
}
}
}
and this the Program.cs
using GrpcGreeter.Services;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// Additional configuration is required to successfully run gRPC on macOS.
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
// Add services to the container.
builder.Services.AddGrpc();
builder.Services.AddGrpcReflection();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.MapGrpcReflectionService();
app.MapGrpcService<GreeterService>();
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
app.Run();
您提供的身份验证链接用于 Web 应用程序。
按照此MSDoc进行身份验证和授权gRPC。
@Harshitha 如果 Azure 应用服务之上的 gRPC 内置身份验证不起作用,我将按照您的建议将其添加到应用程序中。我试图确定的是 Azure 提供的开箱即用身份验证选项是否对此用例有效。
Did you realize that gRPC is compatible with Azure App Service Authentication?是的,Azure App Service提供与 . 的内置身份验证兼容性gRPC。默认情况下,它Azure Active Directory用作Authentication Provider.
@Harshitha 您提供的 URL 不是 Azure 应用服务的内置身份验证。这种基于代码的验证与 gRPC 兼容,但这不是我要确认的。我指的是在没有任何集成代码的情况下使用 Azure 的内置身份验证。