0

We are trying to add grpc to an existing project which contains sevral rest api endpoints. The app in question is hosted on azure app service.

Please note: gRPC on azure app service is still in Public Preview feature at the time of writing.

We are following the example here Program.cs

using GrpcGreeterServer.Services;

var builder = WebApplication.CreateBuilder(args);

// Configure Kestrel to listen on a specific Http2 only port
builder.WebHost.ConfigureKestrel(options =>
{
    // Comment out for local development, uncomment when publishing to App Service
    //options.ListenAnyIP(8080); 
    options.ListenAnyIP(8181, listenOptions =>
    {
        listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2;
    });
});

// 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();

var app = builder.Build();

// Configure the HTTP request pipeline.
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();

Which according to How-to deploy a .NET 6 gRPC app on App Service should allow us to add gRPC endpoints to our existing project which contains rest api endpoints among other things.

Unforuantatly when adding the section for kestrel. It seems to break everything else in the project, when run locally swagger doesn't even run anymore. Nor does any of the app respond up on app service.

// Configure Kestrel to listen on a specific Http2 only port
builder.WebHost.ConfigureKestrel(options =>
{
    // Comment out for local development, uncomment when publishing to App Service
    //options.ListenAnyIP(8080); 
    options.ListenAnyIP(8181, listenOptions =>
    {
        listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2;
    });
});

I am of the opinion that this simply means that the projects cant be mixed.

Does anyone know if this is even possible? or am i chasing my tail on this?

update

Okay, the rest api endpoints appear to be working in azure. Its gRPC endpoints that are not. HTTP version is enabled.

enter image description here

Cross post

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449

0 Answers0