Search code examples
azureazure-web-app-servicemicroservicesgrpcgrpc-web

Can you use gRPC/gRPC-Web to communicate between Microservices hosted on Azure?


I am currently designing a Microservice Architecture, I am very new to the topic, and this question doesn't seem to be explicitly answered anywhere.

Is it possible to Communicate between Microservices (Azure App Services) with gRPC? Could it perhaps be done with Containers or Kestrel in some way so it could support HTTP/2?

I have the following example working when hosted locally: enter image description here

However when hosting them in In Azure it does not seem to work:

Basically Is it even possible to use gRPC in Azure or would I have to use gRPC-Web for all communications? Or are there any Recommendations/Alternatives like REST/SignalR?


Solution

  • gRPC is now supported in Azure Web App service but only for Linux-based Web App.

    Here is the official documentation on how to set it up.

    Basically, you just need to configure your app to open a port which supports HTTP 2. In .NET Kestrel you do it like this (in example below it's in port 8585):

    UPDATE NOVEMBER 2022: Skip this step for .NET 7! Your webapp won't even start with this ConfigureKestrel block of code. Somehow it magically works without it.

    // Configure Kestrel to listen on a specific HTTP port 
    builder.WebHost.ConfigureKestrel(options => 
    { 
        options.ListenAnyIP(8080); 
        options.ListenAnyIP(8585, listenOptions => 
        { 
            listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2; 
        }); 
    });
    

    UPDATE NOVEMBER 2022: Following steps are still needed for .NET 7

    Then you need to configure HTTP version and proxy in your web app

    grpc in azure webapp

    Then you need to add an environment variable pointing to the port 8585

    grpc setting in azure webapp

    I can confirm gRPC already works in West Europe region.