2017-03-23 159 views
0

我正在關注如何將使用Socket.IO的Node.js聊天應用程序部署到Azure Cloud Service上的this教程。我沒有使用教程中提供的聊天示例,而是寫了一些改進和其他功能,但總體結構基本相同。無法在Microsoft Azure上部署簡單的Node.js應用程序

一切工作正常,我也測試了我的應用程序使用模擬器,它按預期工作。但是,我似乎無法正確地在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. 

任何ide爲什麼會發生這種情況?我寫的聊天應用程序可以找到here

回答

0

我把你的應用程序和它構建在我的本地環境中。它沒有按預期工作。我認爲以下內容會引發您的問題:

1)請考慮將您的dependencies npm模塊更新到最新版本。

2)在您的server.js文件中,您需要ipmongodb模塊,但您尚未將它們包含在dependencies部分。

因此,我將dependenciespackage.json文件更改爲類似下面的文件,然後運行。

"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" 
} 
+0

是的,那確實解決了我的問題。但是,將它部署在Azure App Service上_without_交替顯示'package.json'文件也是爲我工作的。奇怪的。 –

相關問題