Publishing ASP.NET Core application to Azure via PowerShell getting 502 (Bad Gateway) In Azure Publishing ASP.NET Core application to Azure via PowerShell getting 502 (Bad Gateway) In Azure powershell powershell

Publishing ASP.NET Core application to Azure via PowerShell getting 502 (Bad Gateway) In Azure


Do you have a web.config? Is it included in your project.json like this:

"publishOptions": {    "include": [      "wwwroot",      "web.config"    ]  }

Your web.config will look something like this:

<?xml version="1.0" encoding="utf-8"?><configuration>  <system.webServer>    <handlers>      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule"            resourceType="Unspecified"/>    </handlers>    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%"                 stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"                  forwardWindowsAuthToken="false"/>  </system.webServer></configuration>

Note: The environment variables LAUNCHER_PATH and LAUNCHER_ARGS may be the source of your issue. You are attempting to launch the publishing scripts that visual studio runs, it is possible that visual studio sets the values in the environment before running the scripts.

To get an RC2 site up and running on an Azure VM, I had to change that line to look like this:

<aspNetCore processPath="dotnet" arguments="./YourAppEntryPoint.dll"             stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"             forwardWindowsAuthToken="false"/>

Try setting your web.config with the explicit values. If your deploy works, then you know it's the missing ENVVARS that are messing it up.