Member-only story
The Definitive guide to get ASP.NET Grpc Services working on Azure App Service

A few months ago, if you had tried to create a Grpc service on ASP.NET, you would have been hard-pressed to get it working. Now, with ChatGPT and GitHub copilot, creating a Grpc service using ASP.NET and Visual Studio has never been easier.
The hard part is deploying to Azure. I should know because I have been trying to do this for about a week or two.
Let me start by saying — it won’t work with App Service hosted on Windows. Even if you follow everything with ChatGPT, MSDN, and everyone else says — it just does not work. I tried it all.
To get it to work, you have to deploy it to Azure App Service hosted on Linux. This means it must not be a Windows-specific build.
Here is the code which I know works:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGrpc();
var app = builder.Build();
app.MapGrpcService<GreeterService>();
app.Run();
Yes, this is taken from the example on MSDN. But know that this will work with all the ASP.NET things you need if you set up authentication talking to a SQL Server database.
Here are the nuget packages I needed:
<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" />
<PackageReference Include="Grpc.AspNetCore.HealthChecks" />
<PackageReference Include="Grpc.AspNetCore.Server" />
<PackageReference Include="Grpc.AspNetCore.Web" />
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.Grpc.Swagger" />
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>…