我已经通过 bitbucket 管道将一个应用程序(支持 Node js 并在前端使用react)部署到 Azure。它执行时没有任何错误。
pipelines:
branches:
master:
- step:
name: Install, build, test & deploy
caches:
- node
script: # Modify the commands below to build your repository.
- apt-get update || true && apt-get install zip
- cd backend && npm ci && npm run build && cd ../frontend && npm ci && npm run build && cd ../
- mv frontend/build backend/dist/
- cd backend && zip -r build-$BITBUCKET_BUILD_NUMBER.zip *
- curl -v -X POST -u $DEPLOY_USER:$DEPLOY_PASSWORD https://$DEPLOY_URL.scm.azurewebsites.net/api/zipdeploy -T "build-$BITBUCKET_BUILD_NUMBER.zip"
我的包 json
"scripts": {
"build": "npm run build:app",
"build:app": "tsc",
"dev": "NODE_ENV=development tsnd --respawn --transpileOnly ./index.ts",
"lint": "tslint -c tslint.json './**/*.ts'",
"lint:fix": "tslint -c tslint.json './**/*.ts' --fix",
"start": "NODE_ENV=production node dist/server.js",
"start:staging": "NODE_ENV=staging ts-node ./index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
该网站给出 403“您无权查看此目录或页面。”
我已从 https://xxx.scm.azurewebsites.net/ 下载日志(诊断转储)但我没有发现任何错误。
我正在 Azure 和 Mac 本地的 Windows 上运行此程序。可能有什么问题。我可以以某种方式看到节点应用程序启动时的输出吗?或者我该如何调试这个?
最佳答案
启动网络应用:
403 通常在应用程序尚未启动时出现在 Appservice 中。要解决此问题,请在您的应用服务中单击开发工具下的高级工具
这将打开一个窗口,标题顶部有一个选项 - Bash。单击该按钮。
默认情况下它将位于主目录中。现在,使用 cd 导航到 site -> wwwroot
在这里,如果部署正确,您应该能够看到所有文件。现在发出命令 npm start (或任何自定义命令)
监控日志:
在您的网络应用程序中的监控下,您有日志流,只需单击它,您就应该能够看到实时日志。
完成这些更改后,您可以重新启动网络应用程序。
最后,在配置下检查您是否在常规设置中为应用服务提供了启动命令。如果是节点,希望您已经给出 process.env.PORT 来获取可用端口。希望这可以帮助!
关于azure - 如何检查 Azure 中的 Node js 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60882305/