是否将ASP.NET Core 5应用程序部署到现有的Azure App Service? [英] Deploy ASP.NET Core 5 app to existing Azure App Service?

查看:190
本文介绍了是否将ASP.NET Core 5应用程序部署到现有的Azure App Service?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在ASP.NET Core 3.x上运行的现有Azure应用服务.我已将应用程序升级到 ASP的今天的发行版.NET Core 5 .这在我的本地IIS Express服务器上工作正常.但是,当我使用Visual Studio 2019将应用程序发布到App Service时,会出现以下错误:

I have an existing Azure App Service running on ASP.NET Core 3.x. I have upgraded the application to today’s release of ASP.NET Core 5. This works fine on my local IIS Express server. When I publish to the application to the App Service using Visual Studio 2019, however, I receive the following error:

HTTP错误500.31-ANCM未能找到本地依赖项

此问题的常用解决方案:

找不到指定版本的Microsoft.NetCore.App或Microsoft.AspNetCore.App.

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.

启用详细错误,我会获得以下附加信息:

With detailed errors enabled, I get the following additional information:

It was not possible to find any compatible framework version 
The framework 'Microsoft.AspNetCore.App', version '5.0.0' was not found.

The following frameworks were found: 
2.1.20 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] 
2.1.22 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] 
2.2.11 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] 
2.2.14 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] 
3.0.3 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] 
3.1.6 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] 
3.1.8 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.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.AspNetCore.App&framework_version=5.0.0&arch=x86&rid=win10-x86

我了解到

I had understood that ASP.NET Core 5 would be immediately available on Azure App Services. Am I missing a step? How can I publish an ASP.NET Core 5 web application to an Azure App Service? Or do I still need to wait until the .NET 5 runtime is available on Azure?

推荐答案

应用程序服务抢先体验功能(公告),您需要明确地将您的App Service配置为使用.NET 5堆栈.

It's not entirely clear from the release notes referenced, but in order to take advantage of the new App Service Early Access feature (announcement), you need to explicitly configure your App Service to use the .NET 5 stack.

要通过Azure门户针对现有应用程序服务执行此操作,请完成以下步骤:

To do this via the Azure Portal for an existing App Service, complete the following steps:

  1. 转到您要升级的应用服务
  2. 点击左侧导航栏中的配置
  3. 在页面级导航中单击常规设置
  4. 堆栈设置下,选择 .NET
  5. 框架版本下,选择 .NET 5
  1. Go to the App Service you want to upgrade
  2. Click on Configuration on the left-hand navigation
  3. Click on General Settings in the page-level navigation
  4. Under Stack Settings, select .NET
  5. Under Framework Version, select .NET 5

注意:从技术上讲,完成此操作后,您将安装.NET 5运行时,并可以切换回例如..NET Core运行时堆栈.但是,这样做会阻止您早期获得对.NET后续更新的访问权限,因此我不建议这样做.

Note: Technically, once you do this, you'll have the .NET 5 runtime installed and could switch back to e.g. the .NET Core runtime stack. Doing so, however, would prevent you from gaining early access to subsequent updates to .NET, so I wouldn't recommend it.

为.NET 5配置应用服务

通过Azure门户配置新的App Service时,对App Service Early Access的这种选择更为明确.在这种情况下,创建应用程序服务时,系统会提示您选择运行时堆栈,在该堆栈下.NET 5被明确标记为 .NET 5(早期访问).

Configuring a new App Service for .NET 5

This opt-in for the App Service Early Access is far more explicit when configuring a new App Service via the Azure Portal. In that case, when creating an App Service, you'll be prompted to select the Runtime stack, under which .NET 5 is explicitly labeled as .NET 5 (Early Access).

注意::如果您已经将另一个App Service配置为在同一App Service Plan上使用App Service Early Access,则.NET 5运行时将已经安装并可用.这是因为.NET运行时在同一App Service计划上的App Services之间共享.

Note: If you already have another App Service configured to use App Service Early Access on the same App Service Plan, then the .NET 5 runtime will already be installed and available. This is because .NET runtimes are shared between App Services on the same App Service Plan.

Visual Studio发布警告

即使具有抢先体验功能,如果您启用了版本兼容性检查,从Visual Studio 2019 16.8发布时,您仍可能会收到以下警告:

Visual Studio publishing warnings

Even with the Early Access feature, you may still receive the following warning when publishing from Visual Studio 2019 16.8, assuming you have version compatibility checks enabled:

您的应用程序需要.NET Core 5.0.0运行时,但是Microsoft Azure App Service仅支持以下版本:2.1.20、2.1.22、2.2.11、2.2.14、3.0.3、3.1.6,和3.1.8.

Your application requires the .NET Core 5.0.0 runtime, but Microsoft Azure App Service only supports the following versions: 2.1.20, 2.1.22, 2.2.11, 2.2.14, 3.0.3, 3.1.6, and 3.1.8.

尽管如此,即使您使用的是与框架无关的部署模式,发布后所有内容也应能正常工作.

Despite that, once you publish everything should work, even if you're using the Framework-dependent deployment mode.

警告:发布有关Application Insights兼容性的状态更新2020年11月发布,但我不希望很快得到解决:跟进线程没有解决而被关闭.

As a word of warning: The current implementation of the App Services Early Access feature doesn't yet support Application Insights integration. I created an issue requesting status updates regarding Application Insights compatibility back in November 2020, but I'm not expecting a resolution anytime soon: a follow-up thread was closed without resolution.

如果您仍依赖于Application Insights的Azure集成,建议您

If you're still relying on the Azure integration of Application Insights, I recommend that you migrate to the SDK implementation.

注意:与早期版本的.NET Framework相比,在ASP.NET Core中配置Application Insights SDK非常简单,并且所需的样板代码要少得多.

Note: Configuring the Application Insights SDK in ASP.NET Core is dramatically simpler than it was in earlier versions of .NET Framework, and requires far less boilerplate code.

替代项

作为替代方案,您可以选择使用发布配置文件( *.pubxml )中的自包含部署模式进行部署.这是.NET 5之前在Azure App Services上新发行.NET Core所需的方法,并且今天仍受支持.

Alternatives

As an alternative, you can instead choose to deploy using the Self Contained deployment mode in your publishing profile (*.pubxml). This was the approach required for new releases of .NET Core on Azure App Services prior to .NET 5, and it continues to be supported today.

这篇关于是否将ASP.NET Core 5应用程序部署到现有的Azure App Service?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆