serverlesswebapi icon indicating copy to clipboard operation
serverlesswebapi copied to clipboard

Application is running inside IIS process but is not configured to use IIS server.

Open ionutafloarei opened this issue 6 years ago • 5 comments

In this project, if it is launched on local host "debug" mode everything works ok. However, after I deploy the project on Azure Function App there is an error when the function call for any web api like this one below:

https://[...].azurewebsites.net/api/Values

The azure function app was created with the default settings and with ASPNETCORE_DETAILEDERRORS = true in order to be able to see the server error.

The stack trace error can be found below:

An error occurred while starting the application.

InvalidOperationException: Application is running inside IIS process but is not configured to use IIS server. Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter+<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)

InvalidOperationException: Application is running inside IIS process but is not configured to use IIS server. Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter+<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app) Microsoft.AspNetCore.HostFilteringStartupFilter+<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app) Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter+<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder) Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Show raw exception details System.InvalidOperationException: Application is running inside IIS process but is not configured to use IIS server. at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app) at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app) at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() .NET Core 4.6.27317.07 X64 v4.0.0.0 | Microsoft.AspNetCore.Hosting version 2.2.0-rtm-35687 | Microsoft Windows 10.0.14393 | Need help?

ionutafloarei avatar Mar 03 '19 10:03 ionutafloarei

this issue was reported on Azure functions https://github.com/Azure/Azure-Functions/issues/1114

ionutafloarei avatar Mar 03 '19 10:03 ionutafloarei

I'm having the exact same issue. @ionutafloarei , were you able to resolve this?

peterson1 avatar Apr 30 '19 01:04 peterson1

Also having the same issue, but with publish on Azure Web App Service. I managed to pinpoint the problem somewhere to in-process and out-of-process stuff, but couldn't figure it out. I had the clean 3.1 core app and went to publish.

Cubelaster avatar Jun 22 '20 22:06 Cubelaster

Also having the same issue, but with publish on Azure Web App Service. I managed to pinpoint the problem somewhere to in-process and out-of-process stuff, but couldn't figure it out. I had the clean 3.1 core app and went to publish.

Do you know solution for this?

NeelBhatt avatar May 24 '22 10:05 NeelBhatt

Been a long time but there are a couple of things you could check:

  1. web.config should have correct configuration => example is InProcess + .dll (don't think this is the issue right now)
  2. Your Program.cs should use configuration supporting IIS, NOT KESTREL.

If I remember correctly, Azure killed of my Kestrel config because it only runs IIS and default configuration for any .NET Core project is Kestrel.

Something along those lines: Also, if I remember correctly, ASPNETCORE_ENVIRONMENT is actually null on Azure because it's a part of Kestrel config, so you'd have to setup the IIS webconfig correctly.

 .ConfigureWebHostDefaults(webBuilder =>
                {
                    var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

                    if (environment == "Development")
                    {
                        webBuilder
                            .UseKestrel()
                            .ConfigureKestrel(serverOptions =>
                            {
                                serverOptions.Limits.MaxRequestBodySize = 10 * 1024;

                                serverOptions.ConfigureHttpsDefaults(listenOptions =>
                                {
                                    listenOptions.SslProtocols = SslProtocols.Tls12;
                                });
                            })
                            .UseStartup<Startup>();
                    }
                    else
                    {
                        webBuilder
                            .CaptureStartupErrors(true)
                            .UseSetting("detailedErrors", "true")
                            .UseStartup<Startup>();
                    }
                });

Cubelaster avatar May 26 '22 06:05 Cubelaster