34
votes

I have a small web app developed with Asp.Net Core 1.1 deployed on Azure and it works well. I just migrated the project to use Asp.Net Core 2.0 and tried to deploy it on Azure. The deployment went fine but when I open the site, I get a 502.5 error. When I check my Azure log stream, I get the following error:

This error occurs when a CGI application does not return a valid set of HTTP headers, or when a proxy or gateway was unable to send the request to a parent gateway. You may need to get a network trace or contact the proxy server administrator, if it is not a CGI problem.

Useless to say that it works well on my development machine with the same code. Note that I'm also using Entity Framework Core 2.0 although I deactivated the database creation on Azure (to check if it was not the cause).

For information, the way I migrated from 1.1 to 2.0 is by changing the target framework settings to "netcoreapp2.0" and by using the NuGet package "Microsoft.AspNetCore.All". Just to be sure, I also deleted my publish profile and recreate one.

Is it possible that Asp.Net Core 2.0 is not yet available on Azure ? I'm fairly new to Asp.Net Core, so I don't know when new releases are made available on Azure.

EDIT

When I try to run my app with dot net CLI via the debug console as proposed by natemcmaster, I got the following issue:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I downloaded the DLL on my desktop and check the version with Dot Net Peak and indeed, the DLL is 1.1.2, although I created the project with Visual Studio and directly publish it, so is it an issue with Visual Studio ? Or Nuget ?

8
-preview1 I assume? That should be available. -preview2 just released and is rolling out to Azure.Tratcher
2.0.0-preview1-finalssougnez
I believe in the latest asp.net community standup (27th June) Damian Edwards said they were talking about deploying the updates to azure within the next week or so (If they were ready) alongside the other updates for preview 2.2Peter Lea

8 Answers

20
votes

the issue was actually coming from the fact that, at first, my web app was using .net core 1.1, which deploys all the DLL in the "wwwroot" folder of the web application. However, with asp.net core 2.0, it does not do that anymore as the DLL are picked up from a global store. However, as Visual Studio does not clean the destination folder before a publish, I ended up with a situation where the 1.1 DLL were in my wwwroot, so the web site was picking up these ones instead of the 2.0 ones in the store folder.

This is explained in more details here: https://github.com/Azure/app-service-announcements-discussions/issues/2#issuecomment-313816550

16
votes

Others have explained the reason why this is happening. I'd like to provide another – arguably easier – solution to the problem.

Just change the settings so that you remove files that are already on Azure – see below:

publish project settings

publish project settings option

6
votes

Check for log files either in the portal or by remotely accessing D:\home\LogFiles.

Sometimes, the logs won't indicate what is going wrong. Another good way to investigate further is to try launching your ASP.NET Core app from the Debug Console. If you are missing a shared framework version or there is another startup error, this will be more visible from the Debug Console.

Go to

https://(your web site name here).scm.azurewebsites.net/DebugConsole/

Your site will be in D:\home\site\wwwroot. You can launch it by executing:

cd D:\home\site\wwwroot
dotnet MyWebApp.dll

If you app still fails to launch, make sure that D:\home\site\wwwroot\web.config is available and configured to use ASP.NET Core Module. https://docs.microsoft.com/en-us/aspnet/core/hosting/aspnet-core-module

2
votes

In my case, It was caused by having a space in the Project Name.

  • I can readily add a space, publish => 502.5.
  • Remove space, publish => good to go.

Hard to believe but I am duplicating it readily with above.

Also using "Remove Additional Files at Destination" per @Sam's Answer

1
votes

See https://github.com/Azure/app-service-announcements/issues/14 "The rollout is expected to complete by Friday June 30th."

1
votes

In my case the issue occurred because AppService at that time supported 2.0.0-preview2-006497 but I had 2.0.0-preview3-006890 installed which was used on build. So I added global.json to use preview 2 SDK and it worked then

0
votes

I don't know if this could help someone one day but in my case, I was using : -Microsoft.AspNetCore.All 2.0.5

Downdrage to Microsoft.AspNetCore.All 2.0.3 resolve my problem

0
votes

This happens when your version of ASP.NET Core cannot be matched on the server.

The simplest solution is to change your settings to deploy the app as self-contained, so it doesn't matter if Azure can match the framework version. Also, delete the files already on Azure, so you don't have issues when upgrading, as explained by @Sam.

enter image description here