Developer Data Modeling Mistakes: From Postgres to NoSQL
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
1. Building APIs with NodeJS on Microsoft
Azure Websites
Rick G. Garibay
VP, Distinguished Engineer
Level: Intermediate
2. About Me
• VP, Distinguished Engineer leading the Development
Platform Group at Neudesic
• Working on IoT, Intelligent Transportation and Hospitality
& Gaming
• Microsoft MVP, Microsoft Azure
• Co-Author, “Windows Server AppFabric Cookbook” by
Packt Pub.
• Chairman, Co-Founder Phoenix Connected Systems User
Group (PCSUG.org)
• twitter: @rickggaribay
• blog: http://rickgaribay.net
• email: rick.garibay@neudesic.com | b-rigari@microsoft.com
11. neurl.it v0.1
• Shorten/Create
– When I submit a long, ugly URL to the create API, I
should get back a neurl.
• Redirect
– When I submit a neurl to the submit API, my
request should be automatically redirected.
• Hits
– When I submit a neurl to the hits API, I should get
back the number of hits/redirects for that neurl.
17. What is NodeJS?
• Server-side scripting framework based on the
Google V8 engine accessible via JavaScript.
• Asynchronous by nature, making it very
performant.
• Growing community and industry support,
including libraries (modules).
18. Hello Node
// Say Hello via Console
console.log("Hello World");
19. Hello Node
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all
requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello Worldn");
});
// Listen on port 8000
server.listen(8000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
20. NodeJS Fundamentals
• Node Package Manager (NPM) – Package manager
for downloading and referencing thousands of
NodeJS modules.
• Package.json – Captures information about
modules (including your project/module) and
dependencies.
• Server.js – Typical entry point to a NodeJS
application but any .js will do.
• Running NodeJS apps is as simple as this:
> node server.js
22. Why Node?
• My goal is not to convince you to use NodeJS
over ASP.NET, Web API, WCF or any other
back-end framework.
23. Why Node?
• Rather, I want to show you a practical example
of what you can do with NodeJS.
• Alternate implementations, either in NodeJS
or other platforms, frameworks and languages
is left as an exercise to the reader.
41. Start Simple
Get started with 10 free web sites
Create new sites in seconds
Easily manage and scale your sites
Automatic load balancing and shared
storage across instances
Scale out or up to reserved instances for
improved performance and scale
42. Code Smart
Use ASP.NET, ASP, PHP, or NodeJS
SQL Azure or MySQL databases
Start with open source apps and frameworks
Develop with VS and WebMatrix
Supports any Web development tool on any
platform (Windows, OSX, Linux)
43. Go Live
Rapid deployment for quick iteration
Integrated source control with Team
Foundation Server (TFS) and Git
Built-in monitoring of perf and usage data
Quick access to request logs, failed requests
diagnostics and diagnostics
44. Resources
• Building Hypermedia APIs with HTML5 and Node by Mike
Amudsen
• Express http://expressjs.com/
• Mocha http://visionmedia.github.com/mocha/
• Should https://github.com/lukebayes/node-should
• SuperTest https://github.com/visionmedia/supertest
• MongoDb http://www.mongodb.org/
• Mongoose https://github.com/LearnBoost/mongoose
• Fiddler http://www.fiddler2.com/fiddler2/
• Microsoft Azure: http://Azure.com
• Configuring Domain Names on Azure Websites
http://bit.ly/1pvOclY
Azure CLI http://azure.microsoft.com/en-us/
documentation/articles/xplat-cli/
45. About Me
• VP, Distinguished Engineer leading the Development
Platform Group at Neudesic
• Working on IoT, Intelligent Transportation and Hospitality
& Gaming
• Microsoft MVP, Microsoft Azure
• Co-Author, “Windows Server AppFabric Cookbook” by
Packt Pub.
• Chairman, Co-Founder Phoenix Connected Systems User
Group (PCSUG.org)
• twitter: @rickggaribay
• blog: http://rickgaribay.net
• email: rick.garibay@neudesic.com | b-rigari@microsoft.com