Top Banner
Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js and Open Source Software Development on Microsoft Azure
44

Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Jan 17, 2016

Download

Documents

Tiffany Francis
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Sofia Event Center

14-15 May 2014

Boris Simandoff, Product Manager @ Chaos GroupMihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc.

Node.js and Open Source Software Development on Microsoft Azure

Page 2: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

How this talk has started….

Боби, хайде да направим една презентация за

Microsoft Azure

Page 3: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

How this talk has started….

Ами… щом е за облачни технолологии

няма да откажа…но нека да е с Node.js

Page 4: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

How this talk has started….

А защо да не е за open source

технологии в Microsoft Azure ?

Да включим и други технологии ?

Page 5: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

How this talk has started….

Ето така се правят

презентации…

Page 6: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Contents

• Comparing Node.js to .NET• Introduction to Node.js on Windows• Accessing Azure Storage with Node.js• Using Azure SQL Database with

Node.js• Building a Web Site with Node.js• Deploying a Node.js Application• Microsoft Azure Mobile Services and

Node.js• Edge.js• Resources

Page 7: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

What is Node.js

• Node.js is a simple but powerful tool for asynchronous network programming

• By utilizing your existing knowledge of JavaScript, you can get up and running Apps quickly

• Node.js is based on V8 JS engine• Practically no installation required• Very lightweight (one 7MB static exe)• Node.js encourages good software practices

out of the box like async programming and inversion of control

Page 8: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Node.js Timeline

2009 2010 2011 2012 2013 2014

Jan 2009Created Ryan Dahl

April 2010 Heroku launches node support

Nov 2011 Windows Azure support

EBay releases API built on node

Cloud9IDE azuresupport

Oct 2011 node.js overtakes Ruby as most popular repo on gitHub

Walmart Launch mobile site on node.js

Feb 2012 App Harbour support

July 2011

LinkedIn adopts node for mobile platform

port to Windows

IISNode

July 2010 Yammer adopts node.js

Nov 2010 Cloud9IDE launches

April 2014 Visual Studio support

Node.js for VS 2012 & 2013 Beta 1.0

Nov 2013 Visual Studio support

Node.js for VS 2012 & 2013 Alpha 1.0

Page 9: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Comparing Node.js to .NET• Traditional Web Server Model

Client Server

Request

Response

Dedicated Thread to service request

Page 10: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Comparing Node.js to .NET• Traditional Web Server Model

Request 1

thread 1 processes the requestand blocks till completion

Response 1

thread 1000 processes the requestand blocks till completion

Web Server (with 1000 threads)

Request 1000

Response 1000

Request 1001

Request 1002

Request 1003

Requests queue up as blocked threads

wait on server

Page 11: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Comparing Node.js to .NET• Async Web Server Model

Client Server

Request

Response

Thread is free to service other requests

Return from Async

Do Async Work

Once event or asyncoperation is completethread completes the

request

Page 12: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Comparing Node.js to .NET• Async Web Server Model

Web Server Request 1

Request 99999 Single threaded event Loop

• Listen for requests• Starts any I/O operations by

specifying a call back to execute on completion

• Continue to listen for requests

Response 5

Response 1

“With node.js everything runs in parallelExcept your code ! ”

Response 99999

Page 13: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Comparing Node.js to .NET• Mapping the Nomenclature

IIS Node.jsC# / VB JavaScript

EF / SQL Server Mongoose/MongoDB or other Database

ASP.NET Web Forms Express + EJSASP.NET MVC/Razor Express + Jade/Razor

ASP.NET Web API Express/HapiSignalIR WS / Socket.IO

AngularJS / KnockoutJS AngularJS / KnockoutJS

Page 14: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows• How Node.js works?

Page 15: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows

Node is Single Threaded!

Page 16: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows

..but, Node is FAST!

Page 17: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows• How Node.js works?• Asynchronous I/O• Event Loop with Pool of Threads• Dead-Lock Free (no concurrency

issues)

Page 18: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows• How Node.js works?

Page 19: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows• Why Node.js• The good parts of JavaScript are

really awesome • One language for the browser and

the server • Async by default• Over 1M concurrent requests

Page 20: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows• Enabling a Node.js Server-Side App

on Microsoft Azure (PaaS)• Web Role - all requests are

received by Microsoft IIS 7 and passed to a native IIS module called iisnode

• Worker roles are much more like the basic node application in that they directly run node.exe for Server.js when the role instance starts.

Boris Simandoff
Не съм сигурен че worker role са чисти node процеси - мисля че и там минава през IIS7
Page 21: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows• Enabling a Node.js Server-Side App

on Windows Azure (PaaS)

Page 22: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows• Node.js in Azure Websites• The architecture for running Node.js within

Azure Websites is identical to that used when hosting within a Web role

Page 23: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Introduction to Node.js on Windows• Integrating Node with IIS / Benefits of using

IISNode:

• Run your Node application across multiple CPU cores

• Serve static content from IIS, dynamic content from node

• Integrated, browser-based debugging with node-inspector

• Monitor the node executable plus changes to your code

• Configuration flexibility with XML + YAML overrides

• View console logs from the browser• All the other existing IIS benefits, including

output caching

Page 24: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Azure Storage with Node.js• Azure Storage• Blob Storage Table Storage

Queue

Page 25: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Azure SQL Database with Node.js• Microsoft Driver for Node.JS for

SQL Server

• Open First – hosted on Githubhttps://github.com/Azure/node-sqlserver

• Simplicity by Design – keeps the simple API

• Use in Windows Azure Web Sites

Page 26: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Azure SQL Database with Node.js• Connecting to SQL Server Database

with Node.JS

var sql = require('node-sqlserver'); var conn_str =

"Driver={SQL Server Native Client 11.0};" + "Server=tcp:[databasename].database.windows.net,1433;" +

"Database=TaskList;Uid=[username];" + "Pwd=[password];Encrypt=yes;Connection Timeout=30“

Page 27: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Azure SQL Database with Node.js• Connecting to SQL Server Database

with Node.JSsql.open(conn_str, function (err, conn) { err && throw err;

conn.queryRaw(query, function (err, results) { err && throw err;for (var i = 0; i < results.rows.length; i++) {

res.write( "Description: " + results.rows[i][0] + "\n");

} res.end();

});

}); // sql.open

Page 28: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• JSON to SQL Type Mappings

JSON Value T-SQL TypeNumeric values (integer, decimal, floating point)

Float(53)

Boolean BitDateTime DateTimeOffset(3)String Nvarchar(max)

Page 29: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Building a Web Site with Node.js• Node Options in the Gallery

Page 30: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Building a Web Site with Node.js• DEMO

Page 31: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Building and Deploying• No build needed• Deploy with Git (awesome)

Page 32: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• Azure Mobile Services Review

Data Authentication Notifications Scripts & Svcs

Page 33: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• Microsoft Azure Mobile Services

Architecture

Page 34: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• Data Storage Services

Page 35: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• Mobile

Services Data Workflow

Client SDK Simplifies This

Insert script

Update script

Delete script

Read script

Node.JS Scripts

Some JSON Object{ FirstName=“…”, LastName=“…” }

REST

ove

r HTT

P

Page 36: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• Authentication Services

Page 37: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• Authentication

Page 38: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• Push Notification Services

Page 39: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• Push Notifications

Insert, Update, Delete, Read on a Table

Automatic or Manual Server ScriptAn Event

Script Runs in the Azure Mobile Service

WindowsPhone 8

MPNS

iOS

APNS

Android

GCM

Windows 8

WNS

Page 40: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• Node Modules

• Extensibility through numerous included modules

request

console

push.*

mssql

statusCodes azure

sendgrid

pusher

twilio

Page 41: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Mobile Services & Node.js• DEMO

Page 42: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Node.js and C# with Edge.js• Edge.js• Native binding to .Net world

var edge = require('edge')var hello = edge.func(function() {/*     

async (input) => {return ".NET welcomes " + input.ToString();     

}*/})

hello('Node.js', function(error, result) { error && throw errorconsole.log(result)

})

Page 43: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Resources:

• Node.js - http://nodejs.org/ • Node.js for Visual Studio -

https://nodejstools.codeplex.com/ • Scott Hanselman blog -

http://www.hanselman.com/blog/ • Microsoft Azure – Node.js Developer Center -

http://azure.microsoft.com/en-us/develop/nodejs/

• Azure SDK for Node.js in GitHub - https://github.com/Azure/azure-sdk-for-node

Page 44: Sofia Event Center 14-15 May 2014 Boris Simandoff, Product Manager @ Chaos Group Mihail Mateev, Senior Technical Evangelist, TL @ Infragistics Inc. Node.js.

Questions???Share your feedback for this particular sessionand for the overall conference experience at

http://aka.ms/intouchfor a chance to win our prizes!