如何在Azure上运行node.js服务器?

我已经按照这个教程( https://www.windowsazure.com/en-us/develop/nodejs/tutorials/create-a-website-(mac)/ )来信,但我没有得到回应期望从我的节点服务器。

当我在本地运行节点,但一旦部署到Azure,我得到这个错误:

iisnode处理请求时遇到错误。

HRESULT:0xb HTTP状态:500 HTTP原因:内部服务器错误

这是我的server.js:

var http = require( "http" ); http.createServer(function ( req, res ) { res.writeHead( { "Content-Type": "text/plain"} ); res.end( "Hello Azure!\n" ); } ).listen( process.env.port ); 

我只是尝试了本教程中完全相同的步骤,并能够获得Hello world消息。 这是我目前的部署: http : //nodetestordinacc.azurewebsites.net/ (注意,我可能会在将来删除它)。

如果这一切都在本地运行,那么您应该能够按照我在教程中所做的那样来执行这些步骤,并使其成功运行。

你可以validation步骤:

  • git init(我使用了Github shell)
  • git add。
  • git commit -m“初始提交”
  • git remote add azure [远程仓库的URL]
  • git推azure大师

必须使用本教程开始部分提供的URLreplace[远程存储库的URL]

由门户网站提供的Git URL

更新:

这是我使用的代码。 请准确地复制它:

 var http = require('http'); var port = process.env.port || 1337; http.createServer(function(req, res){ res.writeHead(200, {'Content-Type':'text/plain'}); res.end('Hello World\n'); }).listen(port);