简体   繁体   English

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

[英]Deploy ASP.NET Core Razor page to Azure App Service

I'm trying to host a ASP.NET Core RazorPages project in Azure App Service.我正在尝试在 Azure 应用服务中托管 ASP.NET Core RazorPages 项目。 As an example I've created a new project and that's the app I want to publish.例如,我创建了一个新项目,这就是我要发布的应用程序。

At first: the publish function from VS2019 (CE) failed with an exception.起初:来自 VS2019 (CE) 的发布 function 因异常而失败。 It is a common exception and I'm not investigate more time in in.这是一个常见的例外,我不会花更多时间调查。

So I thought: I publish it using the portal.所以我想:我使用门户发布它。 So i have a Free account of Azure, create a Resource Group, a Hosting Plan and a Web App.所以我有一个 Azure 的免费帐户,创建一个资源组、一个托管计划和一个 Web 应用程序。 Then i've upload my website using OneDrive and that works.然后我使用 OneDrive 上传了我的网站,这很有效。

I've add the ASP.NET Core 3.1 (x86) Runtime to the extensions and the stack is .NET Core (32 bit, because of free plan).我已将 ASP.NET Core 3.1 (x86) Runtime 添加到扩展中,堆栈为 .NET Core(32 位,因为免费计划)。 I've build the app also for x86.我还为 x86 构建了该应用程序。

But the application doesn't work.但应用程序不起作用。 When I add a default Index.html to the application it works (but not the Razor Pages).当我将默认 Index.html 添加到应用程序时,它可以工作(但不是 Razor 页面)。

Who can solve this problem??谁能解决这个问题??

Regards问候

Donovan多诺万

Looks like you copied too many files to your App Service.看起来您将太多文件复制到应用服务。 The bin/debug and/or bin/release folders should not be there. bin/debug和/或bin/release文件夹应该在那里。 You need to prepare the website for deployment.您需要准备网站以进行部署。 In Visual Studio, you can do so by doing a right-click on the ASP.NET project and selecting 'Publish'.在 Visual Studio 中,您可以通过右键单击 ASP.NET 项目并选择“发布”来执行此操作。 On the page that opens, configure a local publish to a folder.在打开的页面上,配置本地发布到文件夹。 The contents of that folder should then be copied to the App Service.然后应将该文件夹的内容复制到应用服务。

For more information, see Deploy an app to a local folder using Visual Studio .有关详细信息,请参阅使用 Visual Studio 将应用部署到本地文件夹

Also interesting: Host and deploy ASP.NET Core也很有趣:托管和部署 ASP.NET 核心

The dotnet publish command compiles app code and copies the files required to run the app into a publish folder. dotnet publish命令编译应用程序代码并将运行应用程序所需的文件复制到发布文件夹中。 When deploying from Visual Studio, the dotnet publish step occurs automatically before the files are copied to the deployment destination.从 Visual Studio 部署时, dotnet publish步骤会在文件复制到部署目标之前自动发生。

Folder contents文件夹内容
The publish folder contains one or more app assembly files, dependencies, and optionally the .NET runtime.发布文件夹包含一个或多个应用程序程序集文件、依赖项和可选的 .NET 运行时。

A .NET Core app can be published as self-contained deployment or framework-dependent deployment . .NET Core 应用程序可以发布为自包含部署框架相关部署 If the app is self-contained, the assembly files that contain the .NET runtime are included in the publish folder.如果应用程序是独立的,则包含 .NET 运行时的程序集文件将包含在发布文件夹中。 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.如果应用程序依赖于框架,则不包含 .NET 运行时文件,因为该应用程序引用了安装在服务器上的 .NET 版本。 The default deployment model is framework-dependent.默认部署 model 依赖于框架。 For more information, see .NET Core application deployment .有关详细信息,请参阅.NET 核心应用程序部署

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.除了.exe.dll文件之外,ASP.NET 核心应用程序的发布文件夹通常包含配置文件、static 资产和 MVC 视图。 For more information, see ASP.NET Core directory structure .有关详细信息,请参阅ASP.NET 核心目录结构

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 部署托管到 Azure 的 Blazor WebAssembly 应用 ASP.NET Core - Deploy Blazor WebAssembly App ASP.NET Core hosted to Azure ASP.NET Core应用到Azure应用服务上的Linux - ASP.NET Core app to Linux on Azure App Service 自定义 404 页面 Azure App Service Linux asp.net core webapp - Custom 404 page on Azure App Service Linux asp.net core webapp Azure Service Fabric中的ASP.NET Core应用程序中的WebpackDevMiddleware - WebpackDevMiddleware in ASP.NET Core app in Azure Service Fabric ASP.net 核心 docker https on Azure 应用服务容器 - ASP.net core docker https on Azure App Service Containers 无法将ASP.NET 5(ASP.NET Core 1)部署到Azure - Unable to deploy ASP.NET 5 (ASP.NET Core 1) to Azure 在没有.NET Core和Visual Studio的情况下将ASP.NET App部署到Azure Web App - Deploy ASP.NET App to Azure Web App without .NET Core and Visual Studio 如何使用 CICD 管道将带有 linux 应用服务计划的 ASP .NET 核心应用部署到 azure? - How to deploy ASP .NET core app with linux app service plan to azure using CICD pipelines? 使用auth和SQL DB创建ASP.NET MVC应用并部署到Azure App Service - Create an ASP.NET MVC app with auth and SQL DB and deploy to Azure App Service 通过构建管道将 ASP.NET 应用程序部署到 Azure 应用程序服务 - Deploy ASP.NET app to Azure App Service via Build Pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM