将 ASP.NET 个核心 Razor 页面部署到 Azure 应用服务

Deploy ASP.NET Core Razor page to Azure App Service

我正在尝试在 Azure 应用服务中托管 ASP.NET Core RazorPages 项目。 例如,我创建了一个新项目,这就是我要发布的应用程序。

起初:VS2019(CE)的发布功能异常失败。这是一个常见的例外,我不会在里面调查更多时间。

所以我想:我使用门户发布它。所以我有一个 Azure 的免费帐户,创建一个资源组、一个托管计划和一个 Web 应用程序。然后我使用 OneDrive 上传了我的网站并且成功了。

我已将 ASP.NET Core 3.1 (x86) 运行时添加到扩展中,堆栈是 .NET Core(32 位,因为免费计划)。我也为 x86 构建了应用程序。

但是应用程序无法运行。当我向应用程序添加默认值 Index.html 时它可以工作(但不是 Razor Pages)。

谁能解决这个问题??

此致

多诺万

您似乎向应用服务复制了太多文件。 bin/debug and/or bin/release 文件夹应该 而不是 。您需要准备要部署的网站。在 Visual Studio 中,您可以通过右键单击 ASP.NET 项目并选择 'Publish' 来完成此操作。在打开的页面上,配置本地发布到文件夹。然后应将该文件夹的内容复制到应用服务。

有关详细信息,请参阅 Deploy an app to a local folder using Visual Studio

也很有趣:Host and deploy ASP.NET Core

The dotnet publish command compiles app code and copies the files required to run the app into a publish folder. When deploying from Visual Studio, the dotnet publish step occurs automatically before the files are copied to the deployment destination.

Folder contents
The publish folder contains one or more app assembly files, dependencies, and optionally the .NET runtime.

A .NET Core app can be published as self-contained deployment or framework-dependent deployment. If the app is self-contained, the assembly files that contain the .NET runtime are included in the publish folder. If the app is framework-dependent, the .NET runtime files aren't included because the app has a reference to a version of .NET that's installed on the server. The default deployment model is framework-dependent. For more information, see .NET Core application deployment.

In addition to .exe and .dll files, the publish folder for an ASP.NET Core app typically contains configuration files, static assets, and MVC views. For more information, see ASP.NET Core directory structure.