SlideShare una empresa de Scribd logo
1 de 28
Node.js on Azure
Israel Windows Azure UG
        Sasha Goldshtein
        CTO, SELA Group
 blog.sashag.net | @goldshtn
Agenda
• Introduction to Node.js
• Running Node.js on Azure



Azure     Mongoose      Ubuntu       MySQL
  WebMatrix PaaS         Node.js       MongoDB
 Cloud9     Express    Jade          SQL Azure
   nstore    Web Sites        IaaS
Why Am I Using a Mac?
The New Microsoft
• Open
• Flexible
• Competitive

You can run a Node.js web service on a Ubuntu (Linux) VM
on Windows Azure that uses Redis for caching, MongoDB
for sessions, and an SQL Azure database for most models.
   Oh, and you can integrate it with a Windows 8 app.
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)
What’s The Difference Between These
      Two JavaScript Functions?

function f() {                         function g() {
  return                                 return {
  {
     ok: false                                    ok: true
  };                                         };
}                                      }

Credit: Douglas Crockford, JavaScript Guru
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
I hate JavaScript. Why am I
     From 0 to 100 this?!?!
             doing in 60 Seconds
• Hello, World Node.js web server

var http = require(‘http’);
http.createServer(function (req, res) {
  res.writeHead(200, {‘Content-Type’: ‘text/plain’});
  res.end(‘Hello, World!n’);
}).listen(8080);
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
Asynchronous Everywhere
• Almost no blocking APIs
   – “Scaling Node.js for 100K concurrent requests”
   – Suffers from nested async callbacks peril
http.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);
    });
  });
});
What About Azure?
Web Sites
• Shared/reserved, free tier
• Your front-end on Azure

PaaS
• Cloud service
• Web role, Worker role

IaaS
• Bring your own VM
• Windows, multiple Linux flavors
Node.js, Meet Azure Web Sites
• Node.js Azure Web Site
   – Put your main server code in app.js
   – Deploy using Git or FTP

var 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);
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);
});
Data Store for POC Purposes
• The nstore module stores data in a flat file and
  maintains an in-memory index
• Great for POC purposes

var messages = nstore.new(‘messages.db’, ...);
messages.save(msg.id, msg, function (err) ...);

messages.all(function (err, results) { ... });
messages.find({ user: ‘Sasha’ }, ...);
Node.js Deployment to Azure Web Sites

DEMO
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
Using Azure Table Storage
var 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) ...);
Use Table Storage from Node.js On-Premise Application

DEMO
Using SQL Azure
• Experimental node-sqlserver module;
  requires SQL Server Native Client, Windows-
  only, currently supports Node 0.6.x only

var sql = require(‘node-sqlserver’);
sql.query(conn_str, ‘SELECT * FROM Messages’,
  function (err, results) {
    if (!err) ...
  }
);
sql.queryRaw(conn_str, ‘INSERT INTO Messages ...’);
Use SQL Azure from Node.js Azure Web Site

DEMO
Bonus: Windows Azure Mobile
               Services
• Don’t bother writing HTTP requests from your
  Windows 8 app
• Create a Windows Azure Mobile Service

var table = MobileService.GetTable<Message>();
var messages = table.Where(
  m => m.User == ‚Sasha‛).ToList();
table.InsertAsync(new Message { ... });
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) { ... });
Using Node.js with MongoDB from Ubuntu Server Azure VM

DEMO
WebMatrix vs. Cloud9
WebMatrix (Windows)            Cloud9
• Free IDE for easy Web Site   • Web-based IDE that
  development, including          supports deployment to
  with Node.js                    Azure Websites

http://www.microsoft.com/we    http://c9.io
b/webmatrix/
Using WebMatrix with Windows Azure Web Sites

DEMO
Summary
• Azure is open, flexible, and competitive
• Node.js is an awesome server framework
• “Better together”
Questions

http://s.sashag.net/RoIJLf

        Sasha Goldshtein
        CTO, SELA Group
 blog.sashag.net | @goldshtn
Learn More
•   Node.js download and documentation
•   Node.js on Azure home (bunch of tutorials)
•   Express
•   Mongoose
•   node-sqlserver

Más contenido relacionado

La actualidad más candente

Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBHengki Sihombing
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs Irfan Maulana
 
An Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows AzureAn Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows AzureTroy Miles
 
MEAN Stack
MEAN StackMEAN Stack
MEAN StackDotitude
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJSJITENDRA KUMAR PATEL
 
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...Hariharan Ganesan
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJSHüseyin BABAL
 
Nodejs - Building a RESTful API
Nodejs - Building a RESTful APINodejs - Building a RESTful API
Nodejs - Building a RESTful APISang Cù
 
Web assembly overview by Mikhail Sorokovsky
Web assembly overview by Mikhail SorokovskyWeb assembly overview by Mikhail Sorokovsky
Web assembly overview by Mikhail SorokovskyValeriia Maliarenko
 
MongoDB Days Silicon Valley: Building Applications with the MEAN Stack
MongoDB Days Silicon Valley: Building Applications with the MEAN StackMongoDB Days Silicon Valley: Building Applications with the MEAN Stack
MongoDB Days Silicon Valley: Building Applications with the MEAN StackMongoDB
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginnerManinder Singh
 

La actualidad más candente (19)

Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
Node.js for beginner
Node.js for beginnerNode.js for beginner
Node.js for beginner
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
An Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows AzureAn Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows Azure
 
NodeJS Presentation
NodeJS PresentationNodeJS Presentation
NodeJS Presentation
 
MEAN Stack
MEAN StackMEAN Stack
MEAN Stack
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
MongoDB + Node.JS + EPAM ROAD
MongoDB + Node.JS + EPAM ROADMongoDB + Node.JS + EPAM ROAD
MongoDB + Node.JS + EPAM ROAD
 
Node js
Node jsNode js
Node js
 
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
 
Build App with Nodejs - YWC Workshop
Build App with Nodejs - YWC WorkshopBuild App with Nodejs - YWC Workshop
Build App with Nodejs - YWC Workshop
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
Nodejs - Building a RESTful API
Nodejs - Building a RESTful APINodejs - Building a RESTful API
Nodejs - Building a RESTful API
 
Web assembly overview by Mikhail Sorokovsky
Web assembly overview by Mikhail SorokovskyWeb assembly overview by Mikhail Sorokovsky
Web assembly overview by Mikhail Sorokovsky
 
MongoDB Days Silicon Valley: Building Applications with the MEAN Stack
MongoDB Days Silicon Valley: Building Applications with the MEAN StackMongoDB Days Silicon Valley: Building Applications with the MEAN Stack
MongoDB Days Silicon Valley: Building Applications with the MEAN Stack
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
 
Node js
Node jsNode js
Node js
 

Similar a Node.js on Azure

Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
JavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureJavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureSasha Goldshtein
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationStuart (Pid) Williams
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS drupalcampest
 
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondBuilding APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondRick G. Garibay
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.jsYoann Gotthilf
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Lucas Jellema
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101Rami Sayar
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami SayarFITC
 
Scalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJSScalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJSAndhy Koesnandar
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?Balajihope
 

Similar a Node.js on Azure (20)

Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Node azure
Node azureNode azure
Node azure
 
JavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureJavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows Azure
 
Nodejs web,db,hosting
Nodejs web,db,hostingNodejs web,db,hosting
Nodejs web,db,hosting
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondBuilding APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
 
Scalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJSScalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJS
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 

Más de Sasha Goldshtein

Modern Linux Tracing Landscape
Modern Linux Tracing LandscapeModern Linux Tracing Landscape
Modern Linux Tracing LandscapeSasha Goldshtein
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerSasha Goldshtein
 
Staring into the eBPF Abyss
Staring into the eBPF AbyssStaring into the eBPF Abyss
Staring into the eBPF AbyssSasha Goldshtein
 
Visual Studio 2015 and the Next .NET Framework
Visual Studio 2015 and the Next .NET FrameworkVisual Studio 2015 and the Next .NET Framework
Visual Studio 2015 and the Next .NET FrameworkSasha Goldshtein
 
Swift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSwift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSasha Goldshtein
 
C# Everywhere: Cross-Platform Mobile Apps with Xamarin
C# Everywhere: Cross-Platform Mobile Apps with XamarinC# Everywhere: Cross-Platform Mobile Apps with Xamarin
C# Everywhere: Cross-Platform Mobile Apps with XamarinSasha Goldshtein
 
Modern Backends for Mobile Apps
Modern Backends for Mobile AppsModern Backends for Mobile Apps
Modern Backends for Mobile AppsSasha Goldshtein
 
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013Sasha Goldshtein
 
Mastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and ProductionMastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and ProductionSasha Goldshtein
 
Delivering Millions of Push Notifications in Minutes
Delivering Millions of Push Notifications in MinutesDelivering Millions of Push Notifications in Minutes
Delivering Millions of Push Notifications in MinutesSasha Goldshtein
 
Building Mobile Apps with a Mobile Services .NET Backend
Building Mobile Apps with a Mobile Services .NET BackendBuilding Mobile Apps with a Mobile Services .NET Backend
Building Mobile Apps with a Mobile Services .NET BackendSasha Goldshtein
 
Building iOS and Android Apps with Mobile Services
Building iOS and Android Apps with Mobile ServicesBuilding iOS and Android Apps with Mobile Services
Building iOS and Android Apps with Mobile ServicesSasha Goldshtein
 
Attacking Web Applications
Attacking Web ApplicationsAttacking Web Applications
Attacking Web ApplicationsSasha Goldshtein
 
Windows Azure Mobile Services
Windows Azure Mobile ServicesWindows Azure Mobile Services
Windows Azure Mobile ServicesSasha Goldshtein
 
First Steps in Android Development
First Steps in Android DevelopmentFirst Steps in Android Development
First Steps in Android DevelopmentSasha Goldshtein
 

Más de Sasha Goldshtein (20)

Modern Linux Tracing Landscape
Modern Linux Tracing LandscapeModern Linux Tracing Landscape
Modern Linux Tracing Landscape
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF Primer
 
Staring into the eBPF Abyss
Staring into the eBPF AbyssStaring into the eBPF Abyss
Staring into the eBPF Abyss
 
Visual Studio 2015 and the Next .NET Framework
Visual Studio 2015 and the Next .NET FrameworkVisual Studio 2015 and the Next .NET Framework
Visual Studio 2015 and the Next .NET Framework
 
Swift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSwift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS X
 
C# Everywhere: Cross-Platform Mobile Apps with Xamarin
C# Everywhere: Cross-Platform Mobile Apps with XamarinC# Everywhere: Cross-Platform Mobile Apps with Xamarin
C# Everywhere: Cross-Platform Mobile Apps with Xamarin
 
Modern Backends for Mobile Apps
Modern Backends for Mobile AppsModern Backends for Mobile Apps
Modern Backends for Mobile Apps
 
.NET Debugging Workshop
.NET Debugging Workshop.NET Debugging Workshop
.NET Debugging Workshop
 
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
 
Mastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and ProductionMastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and Production
 
Introduction to RavenDB
Introduction to RavenDBIntroduction to RavenDB
Introduction to RavenDB
 
State of the Platforms
State of the PlatformsState of the Platforms
State of the Platforms
 
Delivering Millions of Push Notifications in Minutes
Delivering Millions of Push Notifications in MinutesDelivering Millions of Push Notifications in Minutes
Delivering Millions of Push Notifications in Minutes
 
Building Mobile Apps with a Mobile Services .NET Backend
Building Mobile Apps with a Mobile Services .NET BackendBuilding Mobile Apps with a Mobile Services .NET Backend
Building Mobile Apps with a Mobile Services .NET Backend
 
Building iOS and Android Apps with Mobile Services
Building iOS and Android Apps with Mobile ServicesBuilding iOS and Android Apps with Mobile Services
Building iOS and Android Apps with Mobile Services
 
Task and Data Parallelism
Task and Data ParallelismTask and Data Parallelism
Task and Data Parallelism
 
What's New in C++ 11?
What's New in C++ 11?What's New in C++ 11?
What's New in C++ 11?
 
Attacking Web Applications
Attacking Web ApplicationsAttacking Web Applications
Attacking Web Applications
 
Windows Azure Mobile Services
Windows Azure Mobile ServicesWindows Azure Mobile Services
Windows Azure Mobile Services
 
First Steps in Android Development
First Steps in Android DevelopmentFirst Steps in Android Development
First Steps in Android Development
 

Último

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Último (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Node.js on Azure

  • 1. Node.js on Azure Israel Windows Azure UG Sasha Goldshtein CTO, SELA Group blog.sashag.net | @goldshtn
  • 2. Agenda • Introduction to Node.js • Running Node.js on Azure Azure 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 • Competitive You can run a Node.js web service on a Ubuntu (Linux) VM on Windows Azure that uses Redis for caching, MongoDB for 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 server var 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 peril http.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 Azure PaaS • Cloud service • Web role, Worker role IaaS • 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 FTP var 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 purposes var 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 Sites DEMO
  • 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 Storage var 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 Application DEMO
  • 19. Using SQL Azure • Experimental node-sqlserver module; requires SQL Server Native Client, Windows- only, currently supports Node 0.6.x only var 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 Site DEMO
  • 21. Bonus: Windows Azure Mobile Services • Don’t bother writing HTTP requests from your Windows 8 app • Create a Windows Azure Mobile Service var 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 VM DEMO
  • 24. WebMatrix vs. Cloud9 WebMatrix (Windows) Cloud9 • Free IDE for easy Web Site • Web-based IDE that development, including supports deployment to with Node.js Azure Websites http://www.microsoft.com/we http://c9.io b/webmatrix/
  • 25. Using WebMatrix with Windows Azure Web Sites DEMO
  • 26. Summary • Azure is open, flexible, and competitive • Node.js is an awesome server framework • “Better together”
  • 27. Questions http://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

Notas del editor

  1. Deploy the bbs-ws application to Azure Web Sites.It uses nstore for persistence.
  2. 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).
  3. Use an SQL Azure database and integrate it (through connection string) in a Node application, using node-sqlserver.This is the bbs-sql demo.
  4. 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.
  5. 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.