azure - 如何检查 Azure 中的 Node js 错误

标签 azure

我已经通过 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/

相关文章:

javascript - 如何使用javascript连接azure服务总线主题

azure - 在 Azure Log Analytics 中查看自定义应用程序日志时出现问题

asp.net-mvc-3 - 强制 ASP.NET MVC3 处理程序忽略 .cshtml 和 .vbhtml URL 并仅传递它们

azure - 使用 Azure AD 登录 Google 与 Azure AD B2c

c# - 如何安全地实现从Windows服务到公共(public)WebApi的 Multi-Tenancy 访问

azure - 使用 SAS 从 Azure 存储下载 blob

python-3.x - 如何强制本地 Azure 函数服务器使用 HTTP 2.0 而不是 1.1?

Azure Function App Binding ClaimsPrincial 不设置来自 JWT 的声明

azure - 与使用 Java 从 Azure Keyvault 获取证书相关的问题

azure - X509Certificate2 在调用 Google API 的 Azure Webjobs 中失败