SlideShare a Scribd company logo
1 of 66
Download to read offline
AZ02 – NODE.JS SU WINDOWS AZURE


Emanuele DelBono
Software engineer
@emadb


                    #CDays13 – 27 e 28 febbraio 2013
grazie a…
            Sponsor
Do you really know
    javascript?
> [] + []
> [] + []
''
> [] + {}
> [] + {}
{}
> {} + []
> {} + []
0
> {} + {}
> {} + {}
NaN
> Array(10)
> Array(10)
[ , , , , , , , , , , ]
> Array(10)
[ , , , , , , , , , , ]
> Array(10).join('yo')
> Array(10)
[ , , , , , , , , , , ]
> Array(10).join('yo')
yoyoyoyoyoyoyoyoyoyoyo
> Array(10)
[ , , , , , , , , , , ]
> Array(10).join('yo')
yoyoyoyoyoyoyoyoyoyoyo
> Array(10).join('yo' + 1)
> Array(10)
[ , , , , , , , , , , ]
> Array(10).join('yo')
yoyoyoyoyoyoyoyoyoyoyo
> Array(10).join('yo' + 1)
yo1yo1yo1yo1yo1yo1yo1yo1yo1yo1yo
> Array(10)
[ , , , , , , , , , , ]
> Array(10).join('yo')
yoyoyoyoyoyoyoyoyoyoyo
> Array(10).join('yo' + 1)
yo1yo1yo1yo1yo1yo1yo1yo1yo1yo1yo
> Array(10).join('yo' - 1) + ' Batmaaan'
> Array(10)
[ , , , , , , , , , , ]
> Array(10).join('yo')
yoyoyoyoyoyoyoyoyoyoyo
> Array(10).join('yo' + 1)
yo1yo1yo1yo1yo1yo1yo1yo1yo1yo1yo
> Array(10).join('yo' - 1) + ' Batmaaan'

NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN Batmaaan
Agenda
•   What is node.js?
•   Architecture
•   Installation
•   Building applications
•   Modules
I am…
    Software engineer and
•
    Architect in codiceplastico.
    Writes web apps in C#,
    javascript e ruby.
What is node.js?
• A  development  framework  that  uses  
  event  driven,  non  blocking  I/O
• Built  on  javascript
• Based  on  Google  V8  engine
• Ideal  for  high  performance
History
• Created by Ryan Dahl in 2009
• He is trying to find the best way
  to notify the user in real time
• Written in C
• https://github.com/joyent/node
Curious facts
• It’s one of the most watched project on
  Github
• The community has build more than 21k
  modules
• It’s not only for web apps
Web apps scalability
• Synchronous:
  – Every request could block the others
• Multithread
  – Hard times with thousands connections
Node keep it simple


  Single thread
Non-blocking
• Blocking
 var result = db.query(‘select ...’)


• Non blocking
 db.query(‘select...’,function(result) {...})
Why didn’t I think at it before?
• Culture: The non blocking code seems
  more difficult to get
• Infrastructure: single threaded event loop
  require non-blocking I/O
The event loop
• Every operation must be non-
  blocking
• Lots of callbacks
• The result will be available in
  one of the next ticks
The event loop
• No code in the main method
• All I/O operations are asynchronous
• Be quick to respond
YOU HAVE TO THINK IN
    CALLBACKS
Javascript
• Seems the best choice:
  – Anonymous functions, closures
  – One callback at a time
  – None were using it on the server side
Who are using it?




https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node
What can you do with node?
            Web Server
            TCP Server
          Robot controller
         Command line apps
            Proxy server
          Streaming server
          VoiceMail server
           Music machine
Install
What you get?
• node executable
• npm (the node packet manager)
• REPL
DEMO
IDE
• WebMatrix on windows
• Cloud9
• WebStorm

• Don’t forget about the command line + text
  editor
Not only for web apps
• Useful for I/O intensive tasks
• Scripts for DevOps
• Build (jake)

• Not suitable for intensive CPU tasks
Modules (npm)
• NPM is the Nuget for noders
• No version clash
• package.json to manage app
  dependencies
DEMO
Express.js
•   Minimal MVC framework
•   Verb oriented
•   Middleware
•   Templating
Express.js
var express = require('express');
var app = express();

app.get('/', function(req, res){
  res.send('hello noders');
});

app.listen(3000);
Jade
doctype 5
html(lang="en")
  head
    title= pageTitle
    script(type='text/javascript')
       if (foo) {
          bar()
       }
  body
    h1 Jade - node template engine
    #container
       if youAreUsingJade
         p You are amazing
       else
         p Get on it!
DEMO
Azure
• You can deploy your app to Windows
  Azure.
• Using the CLI
• From WebMatrix (for IDE addicted)
Node on Azure
• Web sites
• Cloud services
• Virtual machines
Deploy on azure
$ azure site create nodeisfun --git
$ git add .
$ git commit -m’first commit’
$ git push azure master
$ azure site browse
DEMO
PACKAGES
mongodb
var MongoClient = require('mongodb').MongoClient;

MongoClient.connect("mongodb://localhost:27017/myDb",
function(err, db) {

  var collection = db.collection('myCollection');

  collection.findOne({mykey:1}, function(err, item){
    console.log(item)
  });
});
node-sqlserver
conn.queryRaw("SELECT * FROM Employees", function (err, res) {
  if (err) {
   console.log("Error running query!");
    return;
  }
  for (var i = 0; i < res.rows.length; i++) {
   console.log(res.rows[i][0] + " " + res.rows[i][1]);
  }
});
WebSockets
• Full-duplex communication over TCP
• W3C standard

• The server calls the browser!!
WebSockets: socket.io
var io = require('socket.io').listen(80);

io.sockets.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});
WebSockets: socket.io
<script src="/socket.io/socket.io.js"></script>
<script>
  var socket = io.connect('http://localhost');
  socket.on('news', function (data) {
    console.log(data);
    socket.emit('my other event', { my: 'data' });
  });
</script>
DEMO
• A collaborative Drum Machine
  – Node.js/express
  – Azure
  – WebSockets
  – Web Audio API
LET’S DRUM
Conclusions
• Node is an interesting platform
• It worth a look
• It’s becoming popular
Not all problems
should be solved in C#
Q&A
Slides and demos available here
  http://www.communitydays.it/
    http://github.com/emadb/
   http://slideshare.net/emadb/

More Related Content

What's hot

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
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsjacekbecela
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejsAmit Thakkar
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRob O'Doherty
 
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
 
Node.js Crash Course
Node.js Crash CourseNode.js Crash Course
Node.js Crash CourseDavid Neal
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node jsAkshay Mathur
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
NodeJS Concurrency
NodeJS ConcurrencyNodeJS Concurrency
NodeJS Concurrencypgriess
 
Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Oscar Renalias
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS Ganesh Kondal
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginnerManinder Singh
 
Understanding the Node.js Platform
Understanding the Node.js PlatformUnderstanding the Node.js Platform
Understanding the Node.js PlatformDomenic Denicola
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsMarcus Frödin
 

What's hot (20)

Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Nodejs intro
Nodejs introNodejs intro
Nodejs intro
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Node.js debugging
Node.js debuggingNode.js debugging
Node.js debugging
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
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
 
Node.js Crash Course
Node.js Crash CourseNode.js Crash Course
Node.js Crash Course
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
NodeJS Concurrency
NodeJS ConcurrencyNodeJS Concurrency
NodeJS Concurrency
 
Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
 
Node ppt
Node pptNode ppt
Node ppt
 
Understanding the Node.js Platform
Understanding the Node.js PlatformUnderstanding the Node.js Platform
Understanding the Node.js Platform
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 
Future of NodeJS
Future of NodeJSFuture of NodeJS
Future of NodeJS
 

Viewers also liked

دعوة حضور حفله السبت القادم
دعوة حضور حفله السبت القادمدعوة حضور حفله السبت القادم
دعوة حضور حفله السبت القادمguest520f2b
 
Ruby seen by a C# developer
Ruby seen by a C# developerRuby seen by a C# developer
Ruby seen by a C# developerEmanuele DelBono
 
La promoció de la lectura a cicle mitjà. aspectes metodològics
La promoció de la lectura a cicle mitjà. aspectes metodològicsLa promoció de la lectura a cicle mitjà. aspectes metodològics
La promoció de la lectura a cicle mitjà. aspectes metodològicsreporteducacio
 
Servei Comunitari. Projecte Rius
Servei Comunitari. Projecte RiusServei Comunitari. Projecte Rius
Servei Comunitari. Projecte Riusreporteducacio
 
An introduction to knockout.js
An introduction to knockout.jsAn introduction to knockout.js
An introduction to knockout.jsEmanuele DelBono
 
Servei Comunitari. Departament d'Ensenyament
Servei Comunitari. Departament d'EnsenyamentServei Comunitari. Departament d'Ensenyament
Servei Comunitari. Departament d'Ensenyamentreporteducacio
 
All I Ever Need To Know About Testing I Learned In Kindergarten
All I Ever Need To Know About Testing I Learned In KindergartenAll I Ever Need To Know About Testing I Learned In Kindergarten
All I Ever Need To Know About Testing I Learned In KindergartenEduardo Sinkiko Yonamine Costa
 
From ActiveRecord to EventSourcing
From ActiveRecord to EventSourcingFrom ActiveRecord to EventSourcing
From ActiveRecord to EventSourcingEmanuele DelBono
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.jsEmanuele DelBono
 

Viewers also liked (18)

دعوة حضور حفله السبت القادم
دعوة حضور حفله السبت القادمدعوة حضور حفله السبت القادم
دعوة حضور حفله السبت القادم
 
Ruby seen by a C# developer
Ruby seen by a C# developerRuby seen by a C# developer
Ruby seen by a C# developer
 
Mocking
MockingMocking
Mocking
 
Conversa peto
Conversa petoConversa peto
Conversa peto
 
La promoció de la lectura a cicle mitjà. aspectes metodològics
La promoció de la lectura a cicle mitjà. aspectes metodològicsLa promoció de la lectura a cicle mitjà. aspectes metodològics
La promoció de la lectura a cicle mitjà. aspectes metodològics
 
Nodes
Nodes  Nodes
Nodes
 
Inclusió digital
Inclusió digitalInclusió digital
Inclusió digital
 
Servei Comunitari. Projecte Rius
Servei Comunitari. Projecte RiusServei Comunitari. Projecte Rius
Servei Comunitari. Projecte Rius
 
An introduction to knockout.js
An introduction to knockout.jsAn introduction to knockout.js
An introduction to knockout.js
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
Da programmatore a CEO
Da programmatore a CEODa programmatore a CEO
Da programmatore a CEO
 
Test driving an MVVM App
Test driving an MVVM AppTest driving an MVVM App
Test driving an MVVM App
 
Servei Comunitari. Departament d'Ensenyament
Servei Comunitari. Departament d'EnsenyamentServei Comunitari. Departament d'Ensenyament
Servei Comunitari. Departament d'Ensenyament
 
All I Ever Need To Know About Testing I Learned In Kindergarten
All I Ever Need To Know About Testing I Learned In KindergartenAll I Ever Need To Know About Testing I Learned In Kindergarten
All I Ever Need To Know About Testing I Learned In Kindergarten
 
From ActiveRecord to EventSourcing
From ActiveRecord to EventSourcingFrom ActiveRecord to EventSourcing
From ActiveRecord to EventSourcing
 
Ruby loves DDD
Ruby loves DDDRuby loves DDD
Ruby loves DDD
 
Ortografia gabarro
Ortografia gabarroOrtografia gabarro
Ortografia gabarro
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 

Similar to Node azure

soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
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
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
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
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiJackson Tian
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.jsguileen
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSocketsGonzalo Ayuso
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsRichard Rodger
 
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
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An IntroductionNirvanic Labs
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsMichael Lange
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationBen Hall
 

Similar to Node azure (20)

soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
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
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
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.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.js
 
20120816 nodejsdublin
20120816 nodejsdublin20120816 nodejsdublin
20120816 nodejsdublin
 
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
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An Introduction
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

Node azure

  • 1. AZ02 – NODE.JS SU WINDOWS AZURE Emanuele DelBono Software engineer @emadb #CDays13 – 27 e 28 febbraio 2013
  • 2. grazie a… Sponsor
  • 3. Do you really know javascript?
  • 4.
  • 5. > [] + []
  • 6. > [] + [] ''
  • 7.
  • 8. > [] + {}
  • 9. > [] + {} {}
  • 10.
  • 11. > {} + []
  • 12. > {} + [] 0
  • 13.
  • 14. > {} + {}
  • 15. > {} + {} NaN
  • 16.
  • 18. > Array(10) [ , , , , , , , , , , ]
  • 19. > Array(10) [ , , , , , , , , , , ] > Array(10).join('yo')
  • 20. > Array(10) [ , , , , , , , , , , ] > Array(10).join('yo') yoyoyoyoyoyoyoyoyoyoyo
  • 21. > Array(10) [ , , , , , , , , , , ] > Array(10).join('yo') yoyoyoyoyoyoyoyoyoyoyo > Array(10).join('yo' + 1)
  • 22. > Array(10) [ , , , , , , , , , , ] > Array(10).join('yo') yoyoyoyoyoyoyoyoyoyoyo > Array(10).join('yo' + 1) yo1yo1yo1yo1yo1yo1yo1yo1yo1yo1yo
  • 23. > Array(10) [ , , , , , , , , , , ] > Array(10).join('yo') yoyoyoyoyoyoyoyoyoyoyo > Array(10).join('yo' + 1) yo1yo1yo1yo1yo1yo1yo1yo1yo1yo1yo > Array(10).join('yo' - 1) + ' Batmaaan'
  • 24. > Array(10) [ , , , , , , , , , , ] > Array(10).join('yo') yoyoyoyoyoyoyoyoyoyoyo > Array(10).join('yo' + 1) yo1yo1yo1yo1yo1yo1yo1yo1yo1yo1yo > Array(10).join('yo' - 1) + ' Batmaaan' NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN Batmaaan
  • 25. Agenda • What is node.js? • Architecture • Installation • Building applications • Modules
  • 26. I am… Software engineer and • Architect in codiceplastico. Writes web apps in C#, javascript e ruby.
  • 27. What is node.js? • A  development  framework  that  uses   event  driven,  non  blocking  I/O • Built  on  javascript • Based  on  Google  V8  engine • Ideal  for  high  performance
  • 28. History • Created by Ryan Dahl in 2009 • He is trying to find the best way to notify the user in real time • Written in C • https://github.com/joyent/node
  • 29. Curious facts • It’s one of the most watched project on Github • The community has build more than 21k modules • It’s not only for web apps
  • 30. Web apps scalability • Synchronous: – Every request could block the others • Multithread – Hard times with thousands connections
  • 31. Node keep it simple Single thread
  • 32.
  • 33. Non-blocking • Blocking var result = db.query(‘select ...’) • Non blocking db.query(‘select...’,function(result) {...})
  • 34. Why didn’t I think at it before? • Culture: The non blocking code seems more difficult to get • Infrastructure: single threaded event loop require non-blocking I/O
  • 35. The event loop • Every operation must be non- blocking • Lots of callbacks • The result will be available in one of the next ticks
  • 36. The event loop • No code in the main method • All I/O operations are asynchronous • Be quick to respond
  • 37. YOU HAVE TO THINK IN CALLBACKS
  • 38. Javascript • Seems the best choice: – Anonymous functions, closures – One callback at a time – None were using it on the server side
  • 39. Who are using it? https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node
  • 40. What can you do with node? Web Server TCP Server Robot controller Command line apps Proxy server Streaming server VoiceMail server Music machine
  • 42. What you get? • node executable • npm (the node packet manager) • REPL
  • 43. DEMO
  • 44. IDE • WebMatrix on windows • Cloud9 • WebStorm • Don’t forget about the command line + text editor
  • 45. Not only for web apps • Useful for I/O intensive tasks • Scripts for DevOps • Build (jake) • Not suitable for intensive CPU tasks
  • 46. Modules (npm) • NPM is the Nuget for noders • No version clash • package.json to manage app dependencies
  • 47. DEMO
  • 48. Express.js • Minimal MVC framework • Verb oriented • Middleware • Templating
  • 49. Express.js var express = require('express'); var app = express(); app.get('/', function(req, res){ res.send('hello noders'); }); app.listen(3000);
  • 50. Jade doctype 5 html(lang="en") head title= pageTitle script(type='text/javascript') if (foo) { bar() } body h1 Jade - node template engine #container if youAreUsingJade p You are amazing else p Get on it!
  • 51. DEMO
  • 52. Azure • You can deploy your app to Windows Azure. • Using the CLI • From WebMatrix (for IDE addicted)
  • 53. Node on Azure • Web sites • Cloud services • Virtual machines
  • 54. Deploy on azure $ azure site create nodeisfun --git $ git add . $ git commit -m’first commit’ $ git push azure master $ azure site browse
  • 55. DEMO
  • 57. mongodb var MongoClient = require('mongodb').MongoClient; MongoClient.connect("mongodb://localhost:27017/myDb", function(err, db) { var collection = db.collection('myCollection'); collection.findOne({mykey:1}, function(err, item){ console.log(item) }); });
  • 58. node-sqlserver conn.queryRaw("SELECT * FROM Employees", function (err, res) { if (err) {    console.log("Error running query!");     return;   }   for (var i = 0; i < res.rows.length; i++) {    console.log(res.rows[i][0] + " " + res.rows[i][1]);   } });
  • 59. WebSockets • Full-duplex communication over TCP • W3C standard • The server calls the browser!!
  • 60. WebSockets: socket.io var io = require('socket.io').listen(80); io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); });
  • 61. WebSockets: socket.io <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect('http://localhost'); socket.on('news', function (data) { console.log(data); socket.emit('my other event', { my: 'data' }); }); </script>
  • 62. DEMO • A collaborative Drum Machine – Node.js/express – Azure – WebSockets – Web Audio API
  • 64. Conclusions • Node is an interesting platform • It worth a look • It’s becoming popular
  • 65. Not all problems should be solved in C#
  • 66. Q&A Slides and demos available here http://www.communitydays.it/ http://github.com/emadb/ http://slideshare.net/emadb/