The document discusses Node.js development in the cloud with Azure. It provides an overview of deploying Node.js applications to Azure Web Sites and infrastructure as a service (IaaS). It also demonstrates using Socket.IO with Node.js for real-time web applications and deploying a sample conference scheduling application to Azure that uses CouchDB for data storage.
6. 6 http://www.anglebrackets.org
The Landscape - Node on Azure
Deployment
Web Sites
From Gallery
Via Source Deployment
IaaS / PaaS
Via Cloud Service deployment from Visual Studio
Deployment tools and source control: GitHub, TFS, FTP
Dev Tools
Azure Node SDK
Azure CLI
Microsoft Web Platform Installer
Microsoft Node Tools for Visual Studio
8. 8 http://www.anglebrackets.org
What is Node.js?
A JavaScript runtime environment
Server-side JavaScript
Compiled
Command line
JavaScript API for network and file system access
Designed for high concurrency
Events, not threads or processes
Never blocks, not even for I/O
Uses CommonJS framework syntax
Close to real OO
9. 9 http://www.anglebrackets.org
Why Use Node.js ?
JavaScript on server-side and client-side
Event loop with a stack
Node.JS serves requests in an event loop
Large number of simultaneous requests.
Avoids Context Switching
Waiting for I/O or Synchronization operation to complete.
Node attaches JS callbacks to I/O requests
The “event driven” part
When the original IO is completed, a callback to the server completes
the request.
10. 10 http://www.anglebrackets.org
Speedy I/O With Events
Threads Events
Threads lock apps / threads One thread
Listens for incoming requests Process from queue
Multiple threads dependent on
multiple processes
State saved for each event
Depends on context switching Not dependent on I/O or
Synchronization
34. azure topic verb options
Command Line Syntax Overview
prompt>
account
account location
account affinity-group
vm
vm disk
vm endpoint
vm image
service
service cert
site
config
download
import
list
show
delete
start
restart
shutdown
capture
create
attach
detach
browse
set
username
password
dns-prefix
vm-name
lb-port
target-image-name
source-path
disk-image-name
size-in-gb
thumbprint
value
-v
-vv
37. 37 http://www.anglebrackets.org
WebSocket
Two-way browser communication
HTTP/1.1 upgrade header for communication
Keeps connections “open” after sending or receiving messages
UTF-8 encoding (no binary)
Just a transport – Challenges:
Server needs to perform a handshake based on the WebSocket protocol, and
implement security separately
WebSocket not supported by all browsers/versions
38. 38 http://www.anglebrackets.org
Node.js with Socket.io
Node.js - Scalable, Event-Driven HTTP server
JavaScript and simple API
Socket.io on Node.js
Socket.io adds the WebSocket protocol and server-side security to Node.js
HTML5 browsers can receive WebSocket connections and keep them “open”.
41. 41 http://www.anglebrackets.org
Conference Scheduler
Attendees can track sessions, vote sessions up and down
Offline Capabilities
IndexedDB
CouchDB VM for Data Storage
Web site hosting the application
Node.js
Grunt
49. 49 http://www.anglebrackets.org
Where to learn more
Node.js
http://nodejs.org
Node.js Dev Center
http://azure.microsoft.com/en-us/develop/nodejs/
Node Tools for Visual Studio
https://nodejstools.codeplex.com/
Code Samples Today:
https://github.com/axemclion
Tutorial: Building a multi-tier cloud application on Windows Azure using MongoLab, node.js, and
Socket.IO
http://msopentech.com/blog/2013/09/18/tutorial-building-multi-tier-cloud-application-windows-azure-using-
mongolab-node-js-socket-io/
Tutorial – Building a Multi-Tier Windows Azure Web application use Cloudant’s Couchdb-as-a-
Service, node.js, CORS, and Grunt
http://msopentech.com/blog/2013/12/19/tutorial-building-multi-tier-windows-azure-web-application-use-
cloudants-couchdb-service-node-js-cors-grunt-2/
Tutorial: Build and deploy a Node.js web site to Azure
http://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-develop-deploy-mac/