部署angular app到Azure app服务web app并显示部署成功,但在浏览器中运行时显示404页面找不到错误?

ubby3x7f  于 2023-06-24  发布在  Angular
关注(0)|答案(1)|浏览(90)

404 Not Found错误日志如下。

/home/LogFiles/2023_06_08_lw0sdlwk0005Y6_default_docker.log  (https://smartinventorytestapp.scm.azurewebsites.net/api/vfs/LogFiles/2023_06_08_lw0sdlwk0005Y6_default_docker.log)
2023-06-08T10:38:05.458442645Z   requireStack: [ '/home/site/wwwroot/node_modules/.bin/ng' ]
2023-06-08T10:38:05.458447245Z }
2023-06-08T10:38:05.467645994Z
2023-06-08T10:38:05.467666994Z Node.js v18.16.0
2023-06-08T10:38:05.589260559Z npm notice
2023-06-08T10:38:05.590561180Z npm notice New minor version of npm available! 9.6.4 -> 9.7.1
2023-06-08T10:38:05.597526393Z npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.7.1>
2023-06-08T10:38:05.600323238Z npm notice Run `npm install -g npm@9.7.1` to update!
2023-06-08T10:38:05.600345538Z npm notice
/home/LogFiles/2023_06_08_lw0sdlwk0005Y6_docker.log  (https://smartinventorytestapp.scm.azurewebsites.net/api/vfs/LogFiles/2023_06_08_lw0sdlwk0005Y6_docker.log)
2023-06-08T11:03:52.503Z INFO  -  Digest: sha256:b1dc34abcaac6f00dd945840a5bc6367123b63b56465a5ec20c316eca98e569e
2023-06-08T11:03:52.504Z INFO  -  Status: Image is up to date for mcr.microsoft.com/appsvc/node:18-lts_20230502.1.tuxprod
2023-06-08T11:03:52.564Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2023-06-08T11:03:52.814Z INFO  - Starting container for site
2023-06-08T11:03:52.816Z INFO  - docker run -d --expose=8080 --name smartinventorytestapp_2_3ea52a68 -e WEBSITE_SITE_NAME=smartinventorytestapp -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=smartinventorytestapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=b11066f3267a7e6498984ab6d3b7a2745eba6596408cd3418260e10128c4799c -e NODE_OPTIONS=--require /agents/nodejs/build/src/Loader.js -e WEBSITE_USE_DIAGNOSTIC_SERVER=True appsvc/node:18-lts_20230502.1.tuxprod pm2 serve /home/site/wwwroot --no-daemon --spa
2023-06-08T11:03:52.816Z INFO  - Logging is not enabled for this container.Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2023-06-08T11:04:01.385Z INFO  - Initiating warmup request to container smartinventorytestapp_2_3ea52a68 for site smartinventorytestapp
2023-06-08T11:04:20.272Z INFO  - Waiting for response to warmup request for container smartinventorytestapp_2_3ea52a68. Elapsed time = 18.887329 sec
Ending Log Tail of existing logs ---
Starting Live Log Stream ---
2023-06-08T11:04:27.567Z INFO  - Container smartinventorytestapp_2_3ea52a68 for site smartinventorytestapp initialized successfully and is ready to serve requests

我希望我的应用程序运行正常,但结果是404 Not Found

iq0todco

iq0todco1#

感谢@Constantine Mora和@Satheesh Elumalai提供的明确步骤。
我已经从这两个文档中引用了参考资料,并且能够构建和运行Angular App to Azure App Service。
当我们部署Simple Angular App时,我正在部署到Azure Windows App Service
Azure Portal中,使用Runtime Stack NODE创建一个新的Web App。

  • 打开命令提示符。运行npm install -g @angular/cli命令。

  • 运行ng new ang-app-12June创建一个新应用。

  • 运行ng serve --open以在本地运行应用程序。

  • 运行ng build以获取最新更改。

VSCode中,安装Azure App Service扩展。

  • Azure tab => Resources中搜索我们在初始步骤中创建的WebApp。

  • 浏览我们创建的应用程序

  • 不要选择整个文件夹,仅选择dist文件夹。

  • 编辑虚拟应用程序并将应用程序名称添加到物理路径。您可以在package.json文件中找到应用程序名称。

  • 检查是否有可用的默认文档。

输出:

相关问题