Building APIs with NodeJS on Microsoft Azure Websites - Redmond

4,845 views
5,337 views

Published on

Visual Studio Live Redmond 2014 - code https://github.com/rickggaribay/IoT

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,845
On SlideShare
0
From Embeds
0
Number of Embeds
3,770
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Building APIs with NodeJS on Microsoft Azure Websites - Redmond

  1. 1. Building APIs with NodeJS on Microsoft Azure Websites Rick G. Garibay VP, Distinguished Engineer Level: Intermediate
  2. 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
  3. 3. The problem with long URLs…
  4. 4. http://mysadsharepointsite/not/rest/ful/Foo.aspx? RootFolder=%2Fpractice%2FConnected%5FSystem s%2FDocuments%2F5%2E%20Training%20Resourc es&FolderCTID=0x0120006C1E110A70E85644A26E 2C21A71B0D82&View={8F82FE4D-9398-4892- B6E6-C2D9C2AB2BE8}
  5. 5. A terrible user experience at best.
  6. 6. But worse, a missed opportunity…
  7. 7. Every URL you send a customer, partner, prospect is an opportunity to make a branding impression.
  8. 8. http://mysadsharepointsite/not/rest/ful/Foo.aspx? RootFolder=%2Fpractice%2FConnected%5FSystem s%2FDocuments%2F5%2E%20Training%20Resourc es&FolderCTID=0x0120006C1E110A70E85644A26E 2C21A71B0D82&View={8F82FE4D-9398-4892- B6E6-C2D9C2AB2BE8}
  9. 9. http://neurl.it/pewUGm
  10. 10. Marketing Campaigns Advertisements Promotions Internal Communication A/B Testing
  11. 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.
  12. 12. http://mysadsharepointsite/not/rest/ful/Foo.aspx? RootFolder=%2Fpractice%2FConnected%5FSystem s%2FDocuments%2F5%2E%20Training%20Resourc es&FolderCTID=0x0120006C1E110A70E85644A26E 2C21A71B0D82&View={8F82FE4D-9398-4892- B6E6-C2D9C2AB2BE8}
  13. 13. POST http://neurl.it/create HTTP/1.1 User-Agent: Fiddler Host: neurl.it Content-Type: application/json; charset=utf-8 Content-Length: 36 {"Url" : "http://rickgaribay.net"} HTTP/1.1 200 OK X-Powered-By: Express Content-Type: application/json; charset=utf-8 Content-Length: 57 Date: Fri, 08 Mar 2013 05:00:21 GMT Connection: keep-alive { "http://neurl.it/pewUGm" }
  14. 14. 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).
  15. 15. Hello Node // Say Hello via Console console.log("Hello World");
  16. 16. 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/");
  17. 17. 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
  18. 18. Client Event Loop Callback Workers IO Response
  19. 19. Why Node? • My goal is not to convince you to use NodeJS over ASP.NET, Web API, WCF or any other back-end framework.
  20. 20. 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.
  21. 21. Implementing the Create API SHOW ME TEH CODEZ
  22. 22. GET http://neurl.it/pewUGm HTTP/1.1 User-Agent: Fiddler Host: neurl.it Content-Type: application/json; charset=utf-8 Content-Length: 0 HTTP/1.1 302 Moved Temporarily X-Powered-By: Express Location: http://rickgaribay.net Vary: Accept Content-Type: text/plain Content-Length: 56 Date: Fri, 08 Mar 2013 05:16:45 GMT Connection: keep-alive Moved Temporarily. Redirecting to http://rickgaribay.net
  23. 23. Implementing the Redirect API SHOW ME TEH CODEZ
  24. 24. GET http://neurl.it/pewUGm/hits HTTP/1.1 User-Agent: Fiddler Host: neurl.it Content-Type: application/json; charset=utf-8 Content-Length: 0 HTTP/1.1 200 OK X-Powered-By: Express Content-Type: text/html; charset=utf-8 Content-Length: 2 Date: Fri, 08 Mar 2013 05:21:37 GMT Connection: keep-alive 42
  25. 25. Implementing the Hits API SHOW ME TEH CODEZ
  26. 26. Supported Publishing Methods
  27. 27. Supported Web Frameworks
  28. 28. Diagnostics & Monitoring
  29. 29. 10 free sites. Multi-tenant. Daily quotas 100 free sites. Multi-tenant. Daily quotas Unlimited. Dedicated VMs. No quotas Unlimited. Dedicated VMs. + more
  30. 30. shared 1
  31. 31. shared 2
  32. 32. Deploy Neurl.it to Azure with Git & Scale DEMO
  33. 33. Windows Azure Web Sites
  34. 34. 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
  35. 35. 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)
  36. 36. 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
  37. 37. 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/
  38. 38. 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

×