我有以下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);
当我在本地运行服务器并在我的浏览器上访问http://localhost:1337/时,我按预期得到"Hello World!" . 我在我的Azure Web App上部署了index.js但是当我尝试访问它时,我得到了"ERR_CONNECTION_TIMED_OUT" .
我究竟做错了什么?
我已经在Azure上安装了express .
1 回答
G.Werner,首先,您可以启用调试以获取错误详细信息,请按照以下步骤操作:
1)如果不存在,请在根文件夹(D:\ home \ site \ wwwroot)中创建文件iisnode.yml .
2)添加以下行 .
完成后,您可以在
D:\home\site\wwwroot\iisnode
中找到日志 .请参考我的工作步骤 .
app.js
web.config
routes/index.js
Access Result:
更多细节请参考这个案例:Running Node.js on Azure Web App .
此外,您还可以在Visual Studio 2017工具中使用名为“Basic Azure Node.js Express 4 App”的快速模板 .
有任何疑虑,请告诉我 .