13

My app works well locally but I've got an error when I deployed it on Azure Web App:

The specified CGI application encountered an error and the server terminated the process.

My app is a .NET Core 2.0 Web API with no wwwroot folder. I have checked this question, the workaround doesn't work for me and it's about a different .NET Core version. My app creates instance of X509Certificate2 from byte array, I am pretty sure it fails here. I need to dynamically manage X509Certificates - uploading certificate to Web App is not an option.

I also found this in Microsoft Docs:

A known issue with an earlier Kestrel version might cause an ASP.NET Core 1.0 app that's hosted in App Service to intermittently stop responding. You also might see this message: "The specified CGI Application encountered an error and the server terminated the process."

This issue is fixed in Kestrel version 1.0.2. This version is included in the ASP.NET Core 1.0.3 update. To resolve this issue, make sure you update your app dependencies to use Kestrel 1.0.2. Alternatively, you can use one of two workarounds that are described in the blog post ASP.NET Core 1.0 slow perf issues in App Service web apps.

I believe I use latest version of Kestrel dependencies from nuget package:

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />

I also tried to re-create Web App to make sure there is no junk left and I use everything latest. How can I fix it? Any ideas?

Github issue

Andrei
  • 42,814
  • 35
  • 154
  • 218
  • have you tried turning on Diagnostic Logs and look from there? I would expect you would find some unhandled exceptions there. There should even be something in detailed errors log (not sure thought if you have to turn that on first). Even Log Stream might give something. – dee zg Dec 03 '17 at 17:56
  • See [wiki](https://github.com/projectkudu/kudu/wiki/Troubleshooting-.NET-Core-errors) for some steps to investigate. – David Ebbo Dec 03 '17 at 18:18
  • I've had that error appear sometimes, .net core 2 azure app, and then it mysteriously vanishes. My code is making an EFCore call to a sql server; nothing very fancy. – Eric Apr 25 '18 at 18:10
  • Having the same issue. A customer of ours is seeing it but we're not. – Clement May 04 '18 at 04:46
  • Having the same issue. I'm starting to think it has something to do with the amount of rows I'm pulling from the database and saving to a list in memory. No problems locally but on the server issues appear. – Met-u May 15 '18 at 11:38
  • Have a look at this thread that discusses the issue. One user also suspects that its an out-of-memory issue https://www.bountysource.com/issues/42684341-intermittent-error-the-specified-cgi-application-encountered-an-error-and-the-server-terminated-the-process – Met-u May 15 '18 at 11:49

2 Answers2

0

I think it might be caused by a missing UseIISIntegration call in your startup code.

Azure Web Apps are based on IIS, so when hosting an ASP.Net Core running with Kestrel, you need this integration to allow IIS to act as a reverse proxy to your service.

Hope it helps!

Itay Podhajcer
  • 2,616
  • 2
  • 9
  • 14
0

In Azure App Service it is typically solved by adding a setting:

WEBSITE_LOAD_USER_PROFILE = 1

Some information about it can be found here.

Andrei
  • 42,814
  • 35
  • 154
  • 218