asp.net core 2.0 publish to azure get IIS 502.5 Error

Viewed 2711

I am starting with asp.net core 2.0 Created a new project with VS 2017. Published it to the windows azure. I got the error IIS 502.5 enter image description here

Check the log stream, I see this

Unhandled Exception: System.FormatException: The short switch '-argFile' is not defined in the switch mappings. at Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at RecruitmentStore.Host.Program.BuildWebHost(String[] args) in D:\RecruitmentStore\RecruitmentStore.Host\Program.cs:line 20 at RecruitmentStore.Host.Program.Main(String[] args) in D:\RecruitmentStore\RecruitmentStore.Host\Program.cs:line 17

IIS Detailed Error - 502.5 - Bad Gateway

And here is my web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore requestTimeout="00:20:00" 
                processPath="bin\IISSupport\VSIISExeLauncher.exe" 
                arguments="-argFile IISExeLauncherArgs.txt" 
                forwardWindowsAuthToken="false" 
                stdoutLogEnabled="true" 
                stdoutLogFile="\\?\%home%\LogFiles\stdout"/>
    <directoryBrowse enabled="true" />
  </system.webServer>
</configuration>

I see the file IISExeLauncherArgs.txt generated inside the bin folder (in my local), but have no idea how it works in Azure.

enter image description here

Can you please tell me how to fix this? I did restarted the app service several times, that doesn't help

2 Answers

As we found, the problem is that you have as part of your project a web.config that is only meant to be used when debugging locally in Visual Studio. If you exclude it form the project, msbuild will generate the correct one at deployment time, and it will run correctly on Azure.

web.config has arguments="-argFile IISExeLauncherArgs.txt" attribute that needs to be removed during publish. Here's a sample ASP.NET Core 2.0 app where this is achieved during publish. I tested this with "File System" and "Web Deploy Package" options (useful for AWS EB deployments)

https://github.com/clearwaterstream/aspnet-websdk-issue242-workaround

Related