将Angular 7应用程序部署到Azure Web App

Tho*_*ato 0 azure azure-web-sites angular

我发现了很多有关如何将Angle App部署到Azure Web App的文章。但是没有工作。我找到了一个解决方案,其中创建了一个Visual Studio Web项目,从Visual Studio Code Project复制dist文件,然后从Visual Studio进行部署。但是,这并不真正有效。我猜该Web应用程序需要一些web.config文件..没有比这更好的方法了吗?我希望直接从Visual Studio Code进行部署,而无需使用asp.net Web项目。如果我只是部署,导航到页面时出现以下错误:

Cannot GET /
Run Code Online (Sandbox Code Playgroud)

在本文中,您似乎所需要的只是一个更高版本的NodeJS:

https://dzone.com/articles/deploy-an-angular-app-from-visual-studio-code-to-a-1

但剂量似乎起作用。

Pet*_*Pan 5

听起来您好像想部署一个基于Angular 7的静态网站,而Azure WebApps上没有任何节点服务器端代码。

我将按照Angular官方Getting started说明来解释部署步骤。

  1. 在我的本地机器上,这些步骤将创建my-app项目,其中包括npm install -g @angular/cling new my-app,和cd my-app。我将跳过以下有关编辑和ng serve直接构建的步骤,如下所示。
  2. I will get a dist directory under the my-app path when just do ng build. Next, I only need to copy all files under the dist/my-app directory to the directory wwwroot of Azure WebApp via Kudu console or FTP or other ways. Then, it works when browser the url https://<your-website-name>.azurewebsites.net like the figure below. 在此处输入图片说明
  3. If you want to show your angular app via the website host with path, such as https://<your-website-name>.azurewebsites.net/docs, you can build your app via ng build --prod --output-path docs --base-href that will create a docs directory under my-app path, and you directly copy the docs directory into wwwroot, then it works on https://<your-website-name>.azurewebsites.net/docs from your browser as the figure above.

Here is my screenshot of my wwwroot path in Kudu. 在此处输入图片说明