2012年6月26日 星期二

Deploy Windows Azure for Node.js by Powershell

 

本篇想說明的是如何用PowerShell Deploy你的專案到Windows Azure

一開始可以先啟動Microsoft Web Platform Installer

image

安裝下列兩項

  • Windows Azure PowerShell
  • Windows Azure SDK for Node.js

image

安裝完,即可以執行Windows Azure PowerShell

image

接下來一開始先建立你的Azure Project

請執行New-AzureServiceProject [ProjectName]

image

再來就是建立你的Node.js 的WebRole

執行Add-AzureNodeWebRole

image

WebRole底下會有建立了預設的檔案,目前server.js為起始檔,可以到web.config更改

image

image

執行完可以在本機測試,請執行Start-AzureEmulator –Launch

image

執行完就會開啟一個browser視窗,顯示你的頁面

image

接下來就是開始Deploy到Windows Azure,首先我們需要deploy的設定檔

請執行Get-AzurePublishSettingsFile

image

執行完,Browser會連線到Windows Azure,若你還沒登入,那請先登入,登入後會出現要你下載你的設定檔

image

設定檔下載後請將他import到你的環境裡面

請執行Import-AzurePublishSettingsFile [設定檔]

image

接下來要Publish WebRole,請下下面的指令,[appName]請使用比較特別的,不然跟別人重複就沒辦法publish,Region可以用"East Asia"
Publish-AzureServiceProject –ServiceName [AppName] –Location [Region] –Launch

image

這個指令大概會花五到七分鐘,所以請大家耐心等待,在deploy期間,你可以到管理介面上面看狀況

image

image


最後會出現Complete,代表成功了,管理介面上也會變成running


image





最後這就是結果了


image



特別要注意的地方就是每次publish都需要一些時間,所以可能要耐心等候,有好幾次我以為我的機器掛了


其他應該還蠻好上手的吧~~~~

沒有留言:

張貼留言