[英]How to run a node.js server on Azure?
I've followed this tutorial ( https://www.windowsazure.com/en-us/develop/nodejs/tutorials/create-a-website-(mac)/ ) to the letter but I'm not getting the response I expect from my node server. 我已经按照本教程( https://www.windowsazure.com/en-us/develop/nodejs/tutorials/create-a-website-(mac)/ )的字母进行了操作,但没有得到答复期望从我的节点服务器。
It works when I run node locally but once deployed to Azure I get this error: 当我在本地运行节点时,它可以工作,但是一旦部署到Azure,我会收到此错误:
iisnode encountered an error when processing the request.
iisnode在处理请求时遇到错误。
HRESULT: 0xb HTTP status: 500 HTTP reason: Internal Server Error
HRESULT:0xb HTTP状态:500 HTTP原因:内部服务器错误
This is my server.js: 这是我的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 );
I just tried the exact same steps myself of the tutorial and was able to get the Hello world
message. 我自己尝试了与本教程完全相同的步骤,并且能够获得
Hello world
消息。 This is my deployment at the moment: http://nodetestordinacc.azurewebsites.net/ (Note, I'll likely remove it in the future). 目前,这是我的部署: http : //nodetestordinacc.azurewebsites.net/ (注意,以后可能会删除它)。
If it all runs locally then you should be able to follow the steps like I did from the tutorial and get it running successfully. 如果所有程序都在本地运行,那么您应该能够按照本教程中的步骤进行操作,并使其成功运行。
Can you verify the steps: 您可以验证以下步骤:
The [URL for remote repository] must be replaced with the url the portal provided in the beginning of the tutorial: 必须将[远程存储库的URL]替换为教程开始时提供的门户的URL:
Update: 更新:
This is the code I used. 这是我使用的代码。 Please copy it over exactly:
请准确复制:
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.