如何在基于 Linux 的 Azure 应用服务上运行 Angular 网站

问题描述 投票:0回答:1

我正在尝试在基于 Linux 的 Azure 应用服务上运行开箱即用的 Angular 网站。虽然基础 Angular 网站可以作为静态网站运行,但我不打算将未来的自定义网站设为静态,因此 Azure Web 服务似乎更适合作为概念验证。我可以成功构建解决方案并将其上传到 Azure 存储库。我可以将解决方案部署到 Azure,但当我尝试运行它时,Azure 会响应“404 Not Found”。我已将启动命令设置为

pm2 serve /home/site/wwwroot --no-daemon --spa or
pm2 serve /home/site/wwwroot/dist --no-daemon

没有运气。我已将index.html文件调整为

<base href="/"> or
<base href=".">

什么都不起作用。你有什么建议吗?

angular linux azure
1个回答
0
投票

发布我的评论作为答案。

我创建了一个示例 Angular 应用程序,并将其部署到 Azure Web App (Linux),并且成功了。

当我使用你的启动命令时,

pm2 服务 /home/site/wwwroot --no-daemon --spa 或 pm2 服务 /home/site/wwwroot/dist --no-daemon

我遇到了和你一样的问题。

我使用此 URL 检查了 Kudu 文件:

https://<AzureWebAppName>.scm.azurewebsites.net/newui

我在浏览器中找到了我的index.html文件,如下所示。

enter image description here

我使用下面的启动命令,

pm2 serve /home/site/wwwroot/dist/<YourLocalAppName>/browser --no-daemon --spa

enter image description here

Azure 应用服务输出

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.