Node.js
meets
Azure

Deploying Node.js & MongoDB apps to Azure

Simone Chiaretta / @simonech

Setup

Create an Azure
Account

http://aka.ms/azurebenug

Register on MongoLab

https://mongolab.com

Build your app

Just a normal Node.js app, no particular requirement.

Actually there is one

If you use binary modules, have the windows version ready.

Create a database

Get the Connection
string

mongodb://<dbuser>:<dbpassword>@ds045077.mongolab.com:45077/njugbe

Create Azure Site

Azure Management Portal

Setup
git deployment

  • From Local
  • From CodePlex
  • From Github
  • From Bitbucket

Local

You just use the GIT locally and push to the Azure remote


git remote add azure https://<user>@<sitename>.scm.azurewebsites.net/<sitename>.git
git push azure master

Via Github

And then continuously deployed

NPM and package.json


{
  "name": "njub_be_demo",
  "version": "0.0.1",
  "engines": {
        "node": "0.8.x"
    },
  "dependencies": {
    "express": "3.0.6",
    "jade": "*",
    "mongoose": "~3.5.4"
  }
}

Log

Packages

Node.js version


Node.js versions available on the platform are: 0.6.17, 0.6.20, 0.8.2.
Selected node.js version 0.8.2. Use package.json file to choose a different version.

Configuring
Connection String


var taskList = new TaskList(process.env.CUSTOMCONNSTR_MONGOLAB_URI);
...
function TaskList(connection) {
  mongoose.connect(connection);
}

Set it online

CUSTOMCONNSTR_MONGOLAB_URI

Additional
Configuration

Web.config



<handlers>
	<add name="iisnode" path="hello.js" verb="*" modules="iisnode" />
</handlers>
...
<iisnode 
  nodeProcessCommandLine=""%programfiles(x86)%\nodejs\node.exe""
  debuggingEnabled="false"
  devErrorsEnabled="false"
  logDirectory="..\..\LogFiles\nodejs" 
  watchedFiles="*.js;iisnode.yml;node_modules\*;views\*.jade;views\*.ejb;routes\*.js" />

https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config

iisnode.yml


node_env: staging
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\0.8.2\node.exe"

https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml

Debugging

Debugging

Set devErrorsEnabled="true"

After

Logging

Store

Native integration available during preview only in US, but catalog is public.

Bonus section

Azure CLI

Install it

sudo npm install azure-cli -g

Set it up

azure account download
azure account import  <path>

Use it

azure site list
azure site show mysite
azure site browse mysite
azure portal

More info: Windows Azure command-line tool for Mac and Linux

Pricing

Tom Crombez
from Microsoft

Try it out

http://aka.ms/azurebenug

Dank u wel

Merci

Simone Chiaretta

@simonech

http://bit.ly/njug_be_azure