Node.js/express blog on Azure in 5 minutes

Following up on the announcements and demos shown at today’s Learn Windows Azure event, I decided to put together a very quick demo that gets you going on Azure with a real app as fast as possible.¬†

I decided to modify express’ blog sample to use Azure storage, and also pre-configured all the service/role settings that Azure needs so you can get going as fast as possible.

Here is the 5-minute recipe:

  1. Get your Windows Azure account
  2. Get the Windows Azure SDK for Node.js
  3. Get the sample source code from GitHub. If you are wondering where some of the static content in the sample came from, check out this getting started document.
  4. Get the needed Node packages by running this inside the ExpressBlog\WebRole folder:
    npm install
  5. You should now be able to launch the Windows Azure PowerShell for Node.js shortcut from your start menu. Make sure you run as Administrator. The rest of the steps here should be completed from that shell.
  6. Download your Azure publish settings:
    Get-AzurePublishSettings
  7. Import the settings:
    Import-AzurePublishSettings mine.publishsettings
  8. Head to the Azure portal and create a storage account under your subscription. Make note of the account name and access key.
  9. Modify the ExpressBlog\WebRole\Web.cloud.config file where indicated to include the storage settings.
  10. You are now ready to publish. Anywhere inside the ExpressBlog folder, run the following, making sure you use a unique service name:
    Publish-AzureService -Name uniqueServiceName

You’re all done!A Node/Express blog on Azure

Unfortunately things don’t always go according to plan, so in case you get an Internal Server Error or anything else goes wrong after you deploy to the cloud, use this simple trick to debug.

  1. Inside the Web.cloud.config file, enable logging:
    <iisnode loggingEnabled="true" />
  2. Redeploy the service by simply typing:
    Publish-AzureService
  3. Look at the Node.js log file for hints of what may be wrong at http://uniqueServiceName.cloudapp.net/server.js.logs/0.txt