Deploy ASP.NET Core 6 app to existing Azure App Service?
Asked Answered
R

4

4

Based on today's announcement of the ASP.NET Core 6 release, it is my understanding that .NET 6 will be immediately available ("day 0 support") on Azure App Services via Early Access:

We are happy to announce that App Service is rolling out day 0 support for .NET 6.0 applications across all public regions and scenarios on both Windows and Linux App Service plans.

After upgrading my ASP.NET Core application to ASP.NET Core 6, configuring my Azure App Service to use .NET 6, and publishing my application to my existing Azure App Service, however, I get an HTTP Error 500.31 with the specific message:

The framework 'Microsoft.NETCore.App', version '6.0.0' (x64) was not found.

Notably, the only .NET 6 runtime it lists as available is RC2 (6.0.0-rc.2.21480.5), not today's release version.

Upgrade Steps

To facilitate this, I performed the following steps:

  • Project file (csproj): Updated the <TargetFramework /> to target the net6.0
  • Publishing profile (pubxml): Updated the <TargetFramework /> to target the net6.0
  • Project file (csproj): Updated all Microsoft.AspNetCore.* NuGet packages to 6.0.0
  • Azure App Service Configuration: Updated the .NET Version to ".NET 6 (Early Access)"

Error Message

When accessing my Azure App Service site with detailed errors enabled, however, I receive the following error:

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies

Common solutions to this issue:

The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.

Specific error detected by ANCM:

It was not possible to find any compatible framework version 
The framework 'Microsoft.NETCore.App', version '6.0.0' (x64) was not found.

The following frameworks were found: 
2.2.14 at [D:\Program Files\dotnet\shared\Microsoft.NETCore.App] 
3.0.3 at [D:\Program Files\dotnet\shared\Microsoft.NETCore.App] 
3.1.15 at [D:\Program Files\dotnet\shared\Microsoft.NETCore.App] 
3.1.18 at [D:\Program Files\dotnet\shared\Microsoft.NETCore.App] 
5.0.7 at [D:\Program Files\dotnet\shared\Microsoft.NETCore.App] 
5.0.9 at [D:\Program Files\dotnet\shared\Microsoft.NETCore.App] 
6.0.0-rc.2.21480.5 at [D:\Program Files\dotnet\shared\Microsoft.NETCore.App] 

You can resolve the problem by installing the specified framework and/or SDK. 

The specified framework can be found at:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=win10-x64

Additional Information

  • I've restarted my Azure App Service (obviously!)
  • I've waited (more than an hour) for the runtime to be installed via Early Access
  • I am publishing my web application using the Framework-dependent deployment mode
  • I do not have any .NET runtimes configured via Azure App Service Extensions
  • I do not have AspNetCoreModule(V2) configured (as was required for ASP.NET Core 3)
  • This Azure App Service Plan is located in the South Central US region
  • I am publishing from today’s release of Visual Studio 2022

Mixed Messages

While the Azure App Service update cited above suggests that there will be "day 0 support", the ASP.NET Core 6 announcement is less committed:

At the time of this post, .NET 6 is being actively deployed to the worldwide network of servers and configured to build and run .NET 6 apps… which should conclude by the end of this week

I would assume that the Azure update on GitHub would be the most authoritative source, but perhaps there are problems with the rollout that haven't yet been acknowledged by the Azure team?

Related Topics

I previously posted two questions related to publishing previous early releases of ASP.NET Core web applications to Azure App Services, and have followed the resolutions relevant to those posts, to no avail:

Question

How can I deploy a release version of an ASP.NET Core 6 app to an Azure App Service using the Early Access program? Is this even ready yet (as per the Azure App Service announcement)? Or do we need to wait until the end of week (as per the ASP.NET Core 6 announcement)?

Ideally, I’d like to take advantage of Early Access without either distributing the runtime with my application (as a self-contained distribution) or installing the runtime via an extension. Obviously, those remain options, but the premise of Early Access is that they shouldn’t be necessary.

Rote answered 9/11, 2021 at 0:30 Comment(3)
What is the Visual Studio version you are using ?Rerun
@HarshithaVeeramalla-MT: Good question. I should have included that in my question. This is using today’s release of Visual Studio 2022. The web app runs locally without any issues. The primary issue seems to be it not identifying the .NET 6 runtime on the Azure App Service.Rote
@HarshithaVeeramalla-MT: FYI: It seems this was just a poorly communicated rollout, and is available as of today (with the "official" launch corresponding to .NET Conf 2021), but wasn't yet available yesterday (with the GitHub release). Everything now works exactly as communicated. See my answer below.Rote
R
3

Good news. This appears to have been a temporary lag between the Azure App Service team's "day 0" announcement and actual availability. As of this post, the .NET 6 runtime is now available via Early Access in, at minimum, the South Central US region—and, presumably, others as well (unconfirmed). Worst case, based on the ASP.NET Core 6 announcement, this should be globally available by the end of the week.

Migration Steps

To reiterate from the original post, to migrate you need to perform the following steps:

  • Project: Migrate your app from e.g., ASP.NET 5 to ASP.NET 6; notably, in the project file (csproj):
    • Update the <TargetFramework /> to target the net6.0
    • Update all Microsoft.AspNetCore.* NuGet packages to 6.0.0
  • Publishing profile (pubxml): Update the <TargetFramework /> to target the net6.0
  • Azure App Service Configuration: Updated the .NET Version to ".NET 6 (Early Access)"

Additional Information

You should not need to do any of the following:

  • Restart your Azure App Service
  • Publish your web application using the Self-contained deployment mode
  • Install the .NET runtime via Azure App Service Extensions
  • Configure the AspNetCoreModule(V2) (as was required for ASP.NET Core 3)

Workarounds

If Early Access isn't yet available in your region and you don't want to wait until the end of the week, there are two workarounds available to you, as suggested elsewhere on this thread:

All said, Microsoft can at least claim this was available on "day 1" and take advantage of the ambiguity in indexing.

Rote answered 9/11, 2021 at 16:35 Comment(0)
I
3

I ran into this problem with deploying with Azure DevOps and was completely confused. So I'm posting this to help anyone who is experiencing the same problem upgrading to .NET 6 and using Azure DevOps to deploy.

It was actually quite a small change that was needed.

In the pipeline for the release, make sure that the Runtime Stack selected is DOTNETCORE 6 (see image below)

enter image description here

Irisation answered 7/12, 2021 at 21:39 Comment(0)
M
2
  1. You should change .NET version to .Net 6(Early Access).

  2. And you also need to install extension in scm site, url like https://your_app_name.scm.azurewebsites.net. Search ASP.NET Core 6.0, and install them.

    enter image description here

  3. Then you can restart your webapp to check.

Morey answered 9/11, 2021 at 7:51 Comment(2)
The .NET Version is already set to “.NET 6 (Early Access)”. I’ll try installing the runtime extension as a workaround, but the entire premise of Early Access is that shouldn’t be necessary, right?Rote
FYI: It looks like this is now available even without installing the runtime via an Azure App Service Extension, at least in the South Central US region. Other regions may take another few days. I’ve posted this in a new answer, but referenced your answer as a workaround for cases where it’s not yet available.Rote
T
0

I have successfully deployed to an App Service using the Self-Contained Deployment Mode. All I did is change the TargetFramework to net6.0 in the csproj file and update the nuget all packages to 6.0.0.

Tatouay answered 9/11, 2021 at 6:50 Comment(2)
That makes sense. I know that used to be required for preview and immediately after releases, but it’s not supposed to be necessary with Early Access. Worst case, it’s nice to know we can fall back on that. Thank you for sharing.Rote
FYI: It looks like this is now available even with the Framework-dependent deployment, at least in the South Central US region. Other regions may take another few days. I’ve posted this in a new answer, but referenced your answer as a workaround for cases where it’s not yet available.Rote

© 2022 - 2024 — McMap. All rights reserved.