Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

JavaScript, Meet Cloud: Node.js on Windows Azure

3.289 visualizaciones

Publicado el

Slides from a talk at the North Toronto .NET User Group. An introduction to Node.js and Express followed by a tour of Windows Azure and various hosting options for Node applications, including Windows Azure Web Sites, Windows Azure Mobile Services, and Windows Azure Virtual Machines.

Publicado en: Tecnología
  • Sé el primero en comentar

JavaScript, Meet Cloud: Node.js on Windows Azure

  1. 1. Sasha Goldshtein CTO, SELA Group @goldshtn blog.sashag.net JavaScript, Meet Cloud: Node.js on Windows Azure © Copyright SELA Software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
  2. 2. Node.js? Lightweight JavaScript server with a rich module ecosystem running on Azure as a web site or a service
  3. 3. The New Microsoft You can run a Node.js web service on an Ubuntu VM on Windows Azure that uses Redis for caching, MongoDB for sessions, and an SQL Database for most models. Oh, and you can integrate it with a Windows Store or iPhone app.
  4. 4. What is Node.js JavaScript on the server Uses the Google V8 engine High-speed JavaScript JIT and GC Hundreds of modules, vibrant ecosystem Package manager, including dependencies HTTP(S), TCP, UDP server and client Bindings and ORMs for virtually every DB MVC framework (express) Everything is open source
  5. 5. Why Node? Cross-platform It’s the next hip thing (after RoR) Asynchronous but no explicit concurrency Rapid development Tiny footprint
  6. 6. Hello, Node var http = require('http'); var server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type’: 'text/plain'}); res.end('Hello, Node!n'); }); server.listen(8080);
  7. 7. express var express = require('express'); var app = express.createServer(); app.get('/hello', function (req, res) { res.sendfile('hello.htm'); }); app.post('/echo', function (req, res) { res.end('You said: ' + req.body.message); }); app.listen(8080);
  8. 8. nstore var nstore = require('nstore'); var messages = nstore.new('messages.db', ...); messages.save(msg.id, msg, function (err) ...); messages.all(function (err, results) { ... }); messages.find({ user: 'Sasha' }, ...);
  9. 9. Node on Azure Web Sites Put your code in app.js or server.js Deploy using Git, Mercurial, TFS, FTP, WebDeploy, Dropbox Use modules freely with package.json Debug your website with node-inspectorNEW
  10. 10. msnodesql var sql = require('msnodesql'); sql.query(conn_str, 'SELECT * FROM Messages', function (err, results) { if (!err) ... } ); sql.queryRaw(conn_str, 'INSERT INTO Messages ...');
  11. 11. Node with SQL Database Create an SQL database Get a connection string Open the firewall (if testing from premises) Node away!
  12. 12. Shared DB with Mobile Services While we’re at it … Windows Azure Mobile Services makes implementing backends a breeze You can share a DB var table = MobileService.GetTable<Message>(); var messages = table.Where( m => m.User == "Sasha").ToList(); await table.InsertAsync(new Message(...));
  13. 13. Node with Table Storage Windows Azure Table Storage is a lightweight, super-cheap, NoSQL data store Rows have dynamic properties Single primary key (index) var q = azure.TableQuery.select().from('messages'); tableService.queryEntities( q, function (err, results) ...); tableService.insertEntity('messages', newMsg, ...);
  14. 14. Node on Azure Virtual Machines Install whatever you want Pick from Windows or Linux distros Microsoft open VMDepot offers dozens of images We’ll use MongoDB on Ubuntu And Mongoose for an ORM var db = mongoose.createConnection(...); var Message = db.model('Message', schema); Message.find(function (err, results) ...);
  15. 15. Node Editor in The Cloud Visual Studio Online “Monaco”NEW is a cloud IDE for your Node/ASP.NET Azure web sites
  16. 16. Questions Sasha Goldshtein CTO, SELA Group @goldshtn blog.sashag.net

×