无法在 Microsoft Azure 上部署简单的 Node.js 应用程序

Failed to deploy a simple Node.js application on Microsoft Azure

我正在按照 this 教程使用 Socket.IO 将 Node.js 聊天应用程序部署到 Azure 云服务。我没有使用教程中提供的聊天示例,而是自己编写了一些改进和其他功能,但整体结构基本相同。

一切正常,我还使用模拟器测试了我的应用程序,它按预期工作。但是,我似乎无法在 Azure 服务上正确发布它。

我输入了以下 cmdlet:

Publish-AzureServiceProject -ServiceName mychatapp0323 -Location "East US" -Launch

下面是我收到的消息:

PS C:\node\chatapp\WorkerRole1> Publish-AzureServiceProject -ServiceName mychatapp0323 -Location "East US" -Launch
WARNING: Publishing mychatapp0323 to Microsoft Azure. This may take several minutes...
WARNING: 12:02:17 AM - Preparing runtime deployment for service 'mychatapp0323'
WARNING: 12:02:17 AM - Verifying storage account 'mychatapp0323'...
WARNING: 12:02:52 AM - Preparing deployment for mychatapp0323 with Subscription ID:
0xxxxx8-xxx2-4xxe-8xx8-8xxx67xxxxx0...
WARNING: 12:04:22 AM - Connecting...
WARNING: 12:04:24 AM - Creating...
WARNING: 12:04:26 AM - Created hosted service 'mychatapp0323'.
WARNING: 12:04:27 AM - Uploading Package to storage service mychatapp0323...
WARNING: 12:04:58 AM - Starting...
WARNING: 12:06:04 AM - Created Deployment ID: 13df765e37e840cdb54a998498ab1745.
WARNING: 12:06:04 AM - Initializing...
WARNING: 12:09:06 AM - Instance WorkerRole1_IN_0 of role WorkerRole1 is busy.
Publish-AzureServiceProject : An error occurred while sending the request.
At line:1 char:1
+ Publish-AzureServiceProject -ServiceName mychatapp0323 -Location "Eas ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Publish-AzureServiceProject], HttpRequestException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.CloudService.PublishAzureServiceProjectCommand

进入cmdlet至少2小时后没有报错,并且在这一行卡了很长时间(一个多小时):

WARNING: 12:09:06 AM - Instance WorkerRole1_IN_0 of role WorkerRole1 is busy.

知道为什么会这样吗?我写的聊天应用可以找到here.

我使用了您的应用程序并将其构建在我的本地环境中。它没有按预期工作。我认为以下内容会引发您的问题:

1) 请考虑将您的 dependencies npm 模块更新到最新版本。

2) 在您的 server.js 文件中,您需要 ipmongodb 模块,但您没有将它们包含在 dependencies 部分中。

所以我将 package.json 文件中的 dependencies 更改为如下所示的内容,然后它起作用了。

"dependencies": { 
    "express": "^4.15.2",
    "jade": "^1.11.0",
    "nib": "^1.1.2",
    "socket.io": "^1.7.3",
    "stylus": "^0.54.5",
    "ip": "^1.1.5",
    "mongodb": "^2.2.25"
}