Your SlideShare is downloading. ×
0
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Node.js on Azure
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Node.js on Azure

6,968

Published on

Sasha Goldshtein's talk about Node.js on Azure, including express, nstore, SQL Azure, MongoDB, Azure VMs, and more...

Sasha Goldshtein's talk about Node.js on Azure, including express, nstore, SQL Azure, MongoDB, Azure VMs, and more...

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

No Downloads
Views
Total Views
6,968
On Slideshare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Deploy the bbs-ws application to Azure Web Sites.It uses nstore for persistence.
  • Use Table Storage from aNode.js on-premise application (could as well be a web site!). This is also applicable for Windows 8 client (but not Node.js).This is the bbs-ts demo.Also show the Azure Web Storage Explorer (http://storageexplorer.cloudapp.net).
  • Use an SQL Azure database and integrate it (through connection string) in a Node application, using node-sqlserver.This is the bbs-sql demo.
  • Use Mongoose on the server to integrate with MongoDB. Deploy the bbs-vm code, run it on the Ubuntu VM, show it.If there’s time, also open the ./bin/mongo CLI prompt to show the database contents.
  • Create a new website, click WebMatrix in the bottom drawer. WebMatrix downloads and opens, you can create a new site and then publish it. All the security details are remembered by the tool.
  • Transcript

    • 1. Node.js on AzureIsrael Windows Azure UG Sasha Goldshtein CTO, SELA Group blog.sashag.net | @goldshtn
    • 2. Agenda• Introduction to Node.js• Running Node.js on AzureAzure Mongoose Ubuntu MySQL WebMatrix PaaS Node.js MongoDB Cloud9 Express Jade SQL Azure nstore Web Sites IaaS
    • 3. Why Am I Using a Mac?
    • 4. The New Microsoft• Open• Flexible• CompetitiveYou can run a Node.js web service on a Ubuntu (Linux) VMon Windows Azure that uses Redis for caching, MongoDBfor sessions, and an SQL Azure database for most models. Oh, and you can integrate it with a Windows 8 app.
    • 5. What’s Node.js?• JavaScript on the server on top of Google V8• Hundreds of modules, vibrant ecosystem – HTTP/HTTPS, TCP/UDP servers – File system access, child processes – DB bindings for just about anything – MVC framework (Express) – Everything is open source (mostly on Github)
    • 6. What’s The Difference Between These Two JavaScript Functions?function f() { function g() { return return { { ok: false ok: true }; };} }Credit: Douglas Crockford, JavaScript Guru
    • 7. Why Node.js?• It’s The Hip Thing To Do™• Makes adaptation easier for JavaScript front- end developers• Rapid development, POCs• Easy to work concurrently without perils of multithreading and parallelism• Tiny footprint compared to most server-side frameworks
    • 8. I hate JavaScript. Why am I From 0 to 100 this?!?! doing in 60 Seconds• Hello, World Node.js web servervar http = require(‘http’);http.createServer(function (req, res) { res.writeHead(200, {‘Content-Type’: ‘text/plain’}); res.end(‘Hello, World!n’);}).listen(8080);
    • 9. Event-Driven Architecture• Node uses a single event thread by default• All I/O is asynchronous node process Event Queue callback I/O Completions Event callback Thread callback
    • 10. Asynchronous Everywhere• Almost no blocking APIs – “Scaling Node.js for 100K concurrent requests” – Suffers from nested async callbacks perilhttp.createServer(function (req, res) { var path = url.parse(request.url).pathname; AllowedPath.find({ name: path }, function (e1, p) { if (e1) ... fs.readFile(p.full_path, function (e2, contents) { if (e2) ... res.end(contents); }); });});
    • 11. What About Azure?Web Sites• Shared/reserved, free tier• Your front-end on AzurePaaS• Cloud service• Web role, Worker roleIaaS• Bring your own VM• Windows, multiple Linux flavors
    • 12. Node.js, Meet Azure Web Sites• Node.js Azure Web Site – Put your main server code in app.js – Deploy using Git or FTPvar port = process.env.port || 8080;var http = require(‘http’);http.createServer(function (req, res) { res.writeHead(200, {‘Content-Type’: ‘text/plain’}); res.end(‘Hello, World!n’);}).listen(port);
    • 13. Express Fundamentals• Powerful middleware for Node – Serves static files, renders views with templates, parses POSTs, provides sessions and cookies, supports authentication…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);});
    • 14. Data Store for POC Purposes• The nstore module stores data in a flat file and maintains an in-memory index• Great for POC purposesvar messages = nstore.new(‘messages.db’, ...);messages.save(msg.id, msg, function (err) ...);messages.all(function (err, results) { ... });messages.find({ user: ‘Sasha’ }, ...);
    • 15. Node.js Deployment to Azure Web SitesDEMO
    • 16. Datastore Flexibility• To minimize Azure Web Sites dependencies, can use local files (nstore module)• Even in an on-premise application, can use Azure Table Storage• On the VM, can use practically any DB• With either, can use SQL Azure
    • 17. Using Azure Table Storagevar azure = require(‘azure’);var ts = azure.createTableService(account, key);ts.createTableIfNotExists(‘messages’, ...);var msg = { PartitionKey: ‘partition’, RowKey: uuid.v1(), ...};ts.insertEntity(‘messages’, msg, function(err) ...);
    • 18. Use Table Storage from Node.js On-Premise ApplicationDEMO
    • 19. Using SQL Azure• Experimental node-sqlserver module; requires SQL Server Native Client, Windows- only, currently supports Node 0.6.x onlyvar sql = require(‘node-sqlserver’);sql.query(conn_str, ‘SELECT * FROM Messages’, function (err, results) { if (!err) ... });sql.queryRaw(conn_str, ‘INSERT INTO Messages ...’);
    • 20. Use SQL Azure from Node.js Azure Web SiteDEMO
    • 21. Bonus: Windows Azure Mobile Services• Don’t bother writing HTTP requests from your Windows 8 app• Create a Windows Azure Mobile Servicevar table = MobileService.GetTable<Message>();var messages = table.Where( m => m.User == ‚Sasha‛).ToList();table.InsertAsync(new Message { ... });
    • 22. Node.js, Meet Azure VM• Azure VMs give you full flexibility – install whatever you want – Pick from Windows or multiple Linux distros• We’ll use Mongoose (MongoDB ORM)var db = mongoose.createConnection(...);var Message = db.model(‘Message’, taskSchema);Message.find(function (err, results) { ... });
    • 23. Using Node.js with MongoDB from Ubuntu Server Azure VMDEMO
    • 24. WebMatrix vs. Cloud9WebMatrix (Windows) Cloud9• Free IDE for easy Web Site • Web-based IDE that development, including supports deployment to with Node.js Azure Websiteshttp://www.microsoft.com/we http://c9.iob/webmatrix/
    • 25. Using WebMatrix with Windows Azure Web SitesDEMO
    • 26. Summary• Azure is open, flexible, and competitive• Node.js is an awesome server framework• “Better together”
    • 27. Questionshttp://s.sashag.net/RoIJLf Sasha Goldshtein CTO, SELA Group blog.sashag.net | @goldshtn
    • 28. Learn More• Node.js download and documentation• Node.js on Azure home (bunch of tutorials)• Express• Mongoose• node-sqlserver

    ×