13

I've been running my ASP.NET Core 2.1 Preview-1 app on Azure since this release became available. I had installed the ASP.NET Core runtime extensions through the portal and it's been working fine.

Now that Microsoft released ASP.NET Core 2.1 Preview-2, I installed the upgrade to the SDK. Updated my Nuget packages so that I have the preview-2 versions of everything. See my csproj file below: enter image description here

I also removed the ASP.NET Core Runtime extensions from Azure App Service for my app which was showing 2.1 Preview-1. Instead installed ASP.NET Core 2.1 run times for x86 and x64 separately -- see below: enter image description here

Compiled the app and published it to my Azure App service but I'm getting errors. First I got the 502.5 error. Now, I'm getting:

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

What am I missing here?

UPDATE:

As the answer suggested, I set my target to x86 (to play it safe) -- see below:

enter image description here

I removed the extension and the individual x86 and x64 run times and installed only the x86 with support for ASP.NET Core 2.1 preview-2 -- see below: enter image description here

I restarted the app several times and I'm still getting 502.5.

I then tried to do a self deploy through CLI command line by issuing the following command:

dotnet publish -c Release -r win10-x64

And I get the following error:

C:\Program Files\dotnet\sdk\2.1.300-preview2-008530\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(125,5): error : The RuntimeIdentifier platform 'win10-x64' and the PlatformTarget 'x86' must be compatible.

Does this mean I have the x86 version of the SDK installed and I must target x86?

I didn't have half the trouble that I'm going through now going from ASP.NET Core 2.0 to 2.1!!!!

UPDATE 2: Just ran dotnet --info in Kudu console. If I'm reading this correctly, I don't have the correct runtime.

enter image description here

Update 3:

I think this screen shot confirms what I was saying. enter image description here

Update 4:

I installed x86 version of ASP.NET Core 2.1 Runtime -- see below: enter image description here

When I run dotnet --info in Kudu console, I get the following which confuses me. I'm still not seeing the version I was expecting to see:

enter image description here

And when I hit the URL, I'm still getting 502.5 and the same message in Kudu console when I run dotnet MyApp.dll telling me that the correct version of the runtime is not found.

How will I get the correct version in there? I thought installing it through the portal would do it.

Sam
  • 26,817
  • 58
  • 206
  • 383
  • Any interesting error messages using [this technique](https://github.com/projectkudu/kudu/wiki/Troubleshooting-.NET-Core-errors)? – David Ebbo Apr 12 '18 at 03:38
  • No interesting message. I followed the instructions and it created a log file which is empty. I hit the URL of my app again and it created a second log file. Inside the log file, all I see is this: Hosting environment: Production Content root path: D:\home\site\wwwroot Now listening on: http://127.0.0.1:32458 Application started. Press Ctrl+C to shut down. – Sam Apr 12 '18 at 03:47
  • The error I get is either the 502.5 or the one in the original post. It seems to go back and forth between these two errors. Also, interestingly enough, it takes forever before I get an error. It takes a good 45-60 seconds before I get the error. – Sam Apr 12 '18 at 03:49
  • I'm on the same boat as Sam, exact same symptons. 502.5 or CGI error. Running from inside Kudu's console works correctly. – Matias Quaranta Apr 12 '18 at 16:51
  • When you install .NET via a site extension, the site extension modifies the PATH of your site putting itself at the beginning. Each site extension is self-contained. If you install both then only one will "win", and it will not know anything about the other extension. – Glenn Apr 12 '18 at 17:47
  • When you published standalone I am assuming the reason it's failing is because you are publishing for x64 but building for x86. If you are going to publish for x64 then you should also set that as your platform target in VS. – Glenn Apr 12 '18 at 17:50
  • @Glenn I currently have only one -- the ASP.NET Core Extensions 2.1.0-preview2-final -- which seems to be getting installed automatically every time I publish my app. Even though I have only one extension, the app is still not working on Azure. – Sam Apr 12 '18 at 17:51
  • What I would like to see is the output of running `dotnet myapp.dll` in the Kudu console if you publish it normally (without a RID) with only a single runtime extension installed. I understand you did that and were getting the 502.5, but I don't know what the error was. Also running `dotnet --info` on the Kudu console to make sure you are getting the .NET version from the site extension. – Glenn Apr 12 '18 at 17:52
  • @Glenn Please see Update 2 I just posted in original post. – Sam Apr 12 '18 at 17:55
  • Right. The `ASP.NET Core Extensions` only does logging. Do you have the extension installed that has Runtime in the name? If not install one of them, the x86 one if you are still targeting that in VS, and try dotnet --info again. – Glenn Apr 12 '18 at 18:01
  • @Glenn See Update 4. – Sam Apr 12 '18 at 18:09
  • Did you restart before running `dotnet --info`? Your site needs to stop and start again in order for the PATH change to take place. Since it works by transforming your the IIS config files and only happens during startup. I have noticed some strangeness here, where you tell the site to restart, and it says it has restarted, but then the actual restart doesn't appear to happen for a bit. Things like that. Not sure if you are hitting something like that. But whatever version `dotnet --info` shows is what your app will use. – Glenn Apr 12 '18 at 18:19
  • Yes, I did. I just did it again to make sure and I'm still getting the same version numbers. I think the correct version for preview-2 is `2.1.300`. I'm getting `2.1.101` – Sam Apr 12 '18 at 18:23
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/168861/discussion-between-glenn-and-sam). – Glenn Apr 12 '18 at 18:24
  • I've never zip deployed an app. I was able to create a self contained deployment in `publish` folder. Do I just zip it up and go to "Zip Push Deploy" under "Tools"? – Sam Apr 12 '18 at 18:25
  • Has this been fixed yet? I've tried everything in this question and have had no luck. Currently waiting on a call back from Microsoft to troubleshoot it. – JTester Apr 26 '18 at 23:56
  • I haven't been able to resolve this. Today, I uploaded my code to a new Azure App -- using the free tier -- and my app worked. I had to set it to x64 and made sure I only had x64 version of the SDK was installed. I was doing the same thing in my other app which is on a paid tier and nothing i did worked. I wonder if there's an issue with Azure where certain things are not getting removed -- possibly the old version of the SDK. – Sam Apr 27 '18 at 02:34
  • I had this same thought, but mine is a tad more complicated because I'm using an App Service Environment as well. When I try to run 'dotnet AppName.dll' in the KUDU console it says theres an issue with my core data. Still haven't heard anything from Microsoft, even with an EA license and a 'Critical' support ticket in :( – JTester Apr 27 '18 at 06:54
  • I lost track of this and never come back to finish helping you out. But it shouldn't matter now because RC is out and installed on Azure App Service without a site extension. So you can remove them all and should have the RC. Right? – Glenn May 22 '18 at 21:44
  • Nope, still extremely inconsistent. I had it working for about 10 min then it stopped. – JTester May 30 '18 at 05:36
  • @Sam are you using an application service environment or a vNet in your Azure configuration? – Louis Lewis Jun 04 '18 at 05:48
  • @LouisLewis Now that ASP.NET Core 2.1 full version is released, everything is working as they should. – Sam Jun 04 '18 at 06:09

7 Answers7

4

We've managed to publish ASP.NET Core 2.1 RC1 webapp to Azure app-service using "self-contained" deployment mode.

Platform target: Any CPU

Here are the package references from our .csproj:

<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.0-rc1-final" PrivateAssets="All" /> <PackageReference Include="Microsoft.AspNetCore.AzureAppServicesIntegration" Version="2.1.0-rc1-final" />

Sergiy
  • 1,912
  • 2
  • 16
  • 25
  • I was having issues with 2.2 and the kudu build server. "dotnet add package Microsoft.AspNetCore.AzureAppServicesIntegration" fixed it up – David Dec 07 '18 at 15:06
3

The steps I took to get this working:

  • Remove the 2.1-preview1 ASP.NET Core Runtime Extension.
  • Check the application settings to see if you're running under 32-bit or 64-bit.
  • Install only the matching (32- or 64-bit) ASP.NET Core 2.1 Runtime.
  • Restart the web app.

Restarting is important - before restarting the .NET Core tools were the wrong version and I would also get 502.5 errors.

As you've installed both 32- and 64-bit runtimes I'd try removing the one that your application doesn't need and restart the web app.

Kjetil Limkjær
  • 1,550
  • 12
  • 22
1

I had the same problem. Finally after 2 hours I fixed it.

Here is my configuration:

Extensions:

enter image description here

Console dotnet --info command:

enter image description here

Console kudu dotnet --version command:

enter image description here

a) Remember to restart your app after install extension.

b) Clear your wwwroot folder from old files and publish again.

Norbert Pisz
  • 3,392
  • 3
  • 27
  • 42
1

I got my project working on asp.net core 2.1 Preview 2 on Azure. I did the following steps;

  1. Deleted the old asp.net core extension from Azure app service Extension
  2. Using kudus deleted all the files in wwwroot folder of the site.
  3. Installed asp.net core site extension from Azure as shown in the picture below and restarted the app service

    Azure Web App Site Extension

  4. Before deploying to Azure, the publish configuration option used is as depicted in the picture below, Azure App Service Publish Configuration in VS 2017 15.7 Preview 3

That's it.

0

Try adding a global.json file in your project folder with this content:

{
  "sdk": {
    "version": "2.1.300-preview2-008530"
  }
}

Restart your app after that to be on the safe side.

Matias Quaranta
  • 13,907
  • 1
  • 22
  • 47
  • This didn't help either! Also, I've noticed that everytime I publish my app to Azure through Visual Studio, it's automatically adding `ASP.NET Core Extensions` and looks like this is version `2.1.0-preview2-final` – Sam Apr 12 '18 at 17:17
  • I'm publishing using the Publish Profile (downloaded from Azure). I manually added the `ASP.NET Core 2.1 (x86) Runtime` extension. After adding the `global.json` file, it started working. Before that, I was only able to run it from within the Kudu's console. – Matias Quaranta Apr 12 '18 at 17:36
  • Just not working at all! Spent quite a bit of time with Glen from Microsoft in a chat room. Nothing we tried would ever work. I even published it to a new site on Azure making sure it's using the correct framework but still just doesn't work. I'm both frustrated and speechless! – Sam Apr 12 '18 at 21:11
  • Set it to use Any CPU. Then tried x86. Then tried x64. Added the `global.json`. Downloaded the publish profile. Restarted countless times and nothing worked! – Sam Apr 12 '18 at 21:12
  • After a couple of minutes I'm back getting the CGI error, even with the global.json file :( So I'm back to a similar situation. No logs, nothing on App Insights either. – Matias Quaranta Apr 12 '18 at 23:25
  • I'm also stuck. Nothing I'm doing is working. What's worse is that if I set my publish profile to target x64 runtime, I can't publish. I tried self contained, FTP, etc. Here's my other issue here: https://stackoverflow.com/questions/49819536/type-or-namespace-name-aspnetcore-does-not-exist-error-when-publishing-to-azur I just can't get this thing to work!!! – Sam Apr 14 '18 at 18:07
0

Here's the only thing that seems to have worked for me.

I did a self-contained deployment using

dotnet publish --self-contained -r win10-x64 -c Release

I then had to do a manual deployment -- in my case using FTP.

I really would like this issue to be resolved but if it's not resolved by my next deployment, I'll do the zip deploy. Because my app has a ReactJs frontend, there were thousands of files to deploy and FTP was not a lot of fun!

Because this approach doesn't depend on what's installed or not installed on Azure App Service, it's a much more straight forward solution.

I still want to be able to simply click Publish in Visual Studio though!

UPDATE: I just did a zip deployment and I'm still getting the errors I was getting before even though zip deployment was successful. So, something is still not right! enter image description here

Sam
  • 26,817
  • 58
  • 206
  • 383
0

I had a problem with a complex website, so I created a simple one with just the App file set at the same version:

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App"  Version="2.1.3" />
  </ItemGroup>

and then, taken from Tim Diekmann's example, I did nothing apart from changing the Deployment Mode in the Azure publishing configuration Settings to Self-Contained - and that worked.

CrispinH
  • 1,899
  • 4
  • 23
  • 38