简体   繁体   English

Windows Azure模拟器中运行的Node.js Web应用程序

[英]Node.js Web Application running in Windows Azure Emulator

I've been trying Node.js running in Windows Azure Emulator, but unfortunatelly it isn't working. 我一直在尝试在Windows Azure模拟器中运行Node.js,但是很遗憾,它无法正常工作。 Of course, I started from beginning, Hello World application, following steps in this tutorial . 当然,我按照本教程中的步骤从头开始创建Hello World应用程序。

I followed the steps below with 4 different computers and in all cases the page didn't show anything. 我按照以下步骤操作了4台不同的计算机,在所有情况下,该页面均未显示任何内容。

  • I opened Windows PowerShell environment as Administrator. 我以管理员身份打开Windows PowerShell环境。
  • I created node directory 我创建了节点目录
  • I entered the command: PS C:\\node> New-AzureService tasklist 我输入了命令:PS C:\\ node> New-AzureService任务列表
  • I entered the command: PS C:\\node\\tasklist> Add-AzureNodeWebRole 我输入了命令:PS C:\\ node \\ tasklist> Add-AzureNodeWebRole

Here, my application was created with the code above: 在这里,我的应用程序是使用上面的代码创建的:

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);
  • And finally, I entered the command: PS C:\\node\\tasklist\\WebRole1> Start-AzureEmulator -launch 最后,我输入了命令:PS C:\\ node \\ tasklist \\ WebRole1> Start-AzureEmulator -launch

Now I was supposed to see my hello world page. 现在,我应该看到我的“ hello world”页面。 The question is, if somebody had success with the given tutorial? 问题是,是否有人在给定的教程上取得成功? And what Am I doing wrong? 我在做什么错呢?

I had your exact same error and looking for a long time on the Internet I found this post . 我遇到了与您完全相同的错误,并且在Internet上找了很长时间,发现了这篇文章

Just to summarize, the problem is that there's a script inside Node package for Azure that's trying to grant permissions for "Network Service" to the web root directory. 概括地说,问题在于Azure的Node包中有一个脚本,该脚本试图将“网络服务”的权限授予Web根目录。 However my system language is it-IT, so I don't have a user called "Network Service". 但是我的系统语言是it-IT,因此没有名为“网络服务”的用户。

So you need to edit the script. 因此,您需要编辑脚本。 If your application path is C:\\node\\tasklist then the script is located at 如果您的应用程序路径为C:\\ node \\ tasklist,则脚本位于

C:\node\tasklist\local_package.csx\roles\WebRole1\approot\bin\setup_web.cmd

Just change this line: 只需更改此行:

icacls ..\ /grant "Network Service":(OI)(CI)W

with this: 有了这个:

icacls ..\ /grant "NetworkService":(OI)(CI)W

This worked for me! 这对我有用!

You can try running the example directly in node using: 您可以尝试使用以下命令直接在节点中运行示例:

node server.js 节点server.js

and pointing a browser to http://localhost:1337 . 并将浏览器指向http:// localhost:1337 This takes the Windows Azure emulator out of the picture and might indicate if there is something else going on. 这将Windows Azure模拟器排除在外,并可能指示是否还有其他事情发生。

I think your case is similar with below article. 我认为您的情况与以下文章相似。 http://blogs.msdn.com/b/avkashchauhan/archive/2012/01/31/handling-two-known-issues-with-windows-azure-node-js-sdk-0-5-2.aspx http://blogs.msdn.com/b/avkashchauhan/archive/2012/01/31/handling-two-known-issues-with-windows-azure-node-js-sdk-0-5-2.aspx

I hope you can solve the problem by this info. 希望您可以通过此信息解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM