“Hello-World”node.js/express 在本地工作,但不在 Azure Web App 上工作

G. *_*ner 5 azure node.js express azure-web-app-service

我有以下 node.js/express 文件index.js

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World!');
});

var port = process.env.PORT || 1337;
app.listen(port);
console.log("Server running at http://localhost:%d", port);
Run Code Online (Sandbox Code Playgroud)

当我在本地运行服务器并在浏览器上访问http://localhost:1337/时,我得到“Hello World!” 正如预期的那样。我在 Azure Web App 上部署了 index.js,但当我尝试访问它时,收到“ERR_CONNECTION_TIMED_OUT”。

我究竟做错了什么?

我已经在 Azure 上安装了 Express。

Sam*_*nyi 2

我遇到了同样的问题,您是否尝试过部署到 Linux 应用服务计划,这应该像 Charm 一样工作,但是,如果您使用的是 Windows 计划,请确保您已添加 web.config 文件,请检查一下希望它有所帮助。对于其他面临类似问题的人,请确保您有从 process.env.PORT || 调用的端口 XXX 因为云讨厌硬编码端口值