SlideShare ist ein Scribd-Unternehmen logo
1 von 76
Cherno More Hotel
12 July 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
How this talk has started….
Боби, хайде да направим
една презентация за
Microsoft Azure
How this talk has started….
Ами… щом е за облачни
технолологии
няма да откажа…
но нека да е с Node.js
How this talk has started….
А защо да не е за
open source
технологии в
Microsoft Azure ?
Да включим и други
технологии ?
How this talk has started….
Ето така се
правят
презентации…
How this talk has started….
Момчета, това е
една интересна
тема за Varna Conf
Mihail Mateev
• About…
Mihail Mateev is a Senior Technical Evangelist, Team
Lead at Infragistics Inc., Community Lead for Europe,
Microsoft Azure MVP
Mihail works in various areas related to Microsoft
technologies : Silverlight, WPF, WP, LightSwitch, WCF,
ASP.Net MVC, MS SQL Server and Microsoft Azure
Contents
• Why Node.js
• Comparing Node.js to .NET
• Introduction to Node.js on Windows
• Using Azure SQL Database with Node.js
• Accessing Azure Storage with Node.js
• Building a Web Site with Node.js
• Deploying a Node.js Application
• Node.js & Edge.js
• Microsoft Azure Mobile Services and Node.js
• Resources
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
What is Node.js
• 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
Why Node.js?
• Node.js uses JavaScript syntax.
• There are more than 100 000 000 WEB developers!
• The realistic reason:
Cross platform applications with JS will be faster and easier
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
Node.js Timeline
2009 2010 2011 2012 2013 2014
Jan 2009
Created
Ryan Dahl
April 2010
Heroku
launches
node
support
Nov 2011
Windows Azure
support
EBay releases API
built on node
Cloud9IDE azure
support
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
Cloud9I
DE
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
Comparing Node.js to .NET
• Traditional Web Server Model
Client Server
Request
Response
Dedicated Thread
to service request
Comparing Node.js to .NET
• Traditional Web Server Model
Request 1
thread 1 processes the request
and blocks till completion
Response 1
thread 1000 processes the request
and 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
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 async
operation is complete
thread completes the
request
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 parallel
Except your code ! ”
Response 99999
Comparing Node.js to .NET
• Mapping the Nomenclature
IIS Node.js
C# / VB JavaScript
EF / SQL Server Mongoose/MongoDB or other
Database
ASP.NET Web Forms Express + EJS
ASP.NET MVC/Razor Express + Jade/Razor
ASP.NET Web API Express/Hapi
SignalR WS / Socket.IO
AngularJS / KnockoutJS AngularJS / KnockoutJS
Introduction to Node.js on Windows
• How Node.js works?
Introduction to Node.js on Windows
Node is Single Threaded!
Introduction to Node.js on Windows
..but, Node is FAST!
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)
Introduction to Node.js on Windows
• How Node.js works?
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
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.
Introduction to Node.js on Windows
• Enabling a Node.js Server-Side App on Windows
Azure (PaaS)
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
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
MS SQLServer and Node.js
• Node.js Modules for SQLServer
#N % Node.js Module
#1 20.7% node-sqlserver
Microsoft Driver for Node.js for SQL Server
#2 18.0% tedious
A TDS driver, for connecting to MS SQLServer databases
#3 12.3% tds
TDS client for connecting to Microsoft SQL Server
#4 1.5% mssqlhelper
Microsoft SQL Server database helper
#5 0.4% mssqlx
NodeJs Microsoft SQL Server Command Line Interface
#6 0.2% msnodesql
Microsoft Driver for Node.js for SQL Server
#7 N/A node-sqlserver-unofficial
Microsoft Driver for Node.js for SQL Server – unofficial distribution
MS SQLServer and Node.js
• node-sqlserver & msnodesql
• Microsoft Driver for Node.js for SQL Server
and Azure SQL Database: Node.js module,
based on SQL Server Native Client 11.0 -
available as Microsoft SQL Server 2012
Native Client found in the
SQL Server 2012 Feature Pack
• The same repository, different npm
packages
MS SQLServer and Node.js
• node-sqlserver-unofficial
This is an unofficial binary distribution of that driver.
• No need to compile from source (which requires
Visual Studio and totally confuses people).
• It runs on both x86 and x64 and with node versions
0.8 and 0.10.
• No workarounds needed to run on Azure web sites.
node-sqlserver-unofficial npm page
MS SQLServer and Node.js
• node-sqlserver-unofficial
This is an unofficial binary distribution of that driver.
• No need to compile from source (which requires
Visual Studio and totally confuses people).
• It runs on both x86 and x64 and with node versions
0.8 and 0.10.
• No workarounds needed to run on Azure web sites.
node-sqlserver-unofficial npm page
MS SQLServer and Node.js
• tedious
• A TDS driver, for connecting to MS SQLServer databases.
• Tedious is an implementation of the TDS protocol, which
is used to interact with instances of Microsoft's SQL
Server. It is intended to be a fairly slim implementation of
the protocol, with not too much additional functionality.
• Tedious is implemented only with JavaScript
MS SQLServer and Node.js
• node-tds
• This is a module that allows you to access Microsoft SQL
Server 2005 and later.
• It is a pure JS implementation of the TDS protocol hosted
on GitHub.
• node-tds is similar to tedious
MS SQLServer and Node.js
• node-tds mssqlhelper
• Microsoft SQL Server Helper nodejs
• mssqlx
• NodeJs Microsoft SQL Server Command Line Interface
MS SQLServer and Node.js
• Pros and Cons
driver pros cons
tedious,
tds
Lightweight ,
JS implementation,
no dependencies
Limited functionalities,
Cannot use integrated
authentication
msnodesql,
node-sqlserver
More features Many dependencies,
No actual builds
Require custom build
node-sqlserver-
unofficial
Same like msnodesql, node-sqlserver,
fixed issues with the official distributions
No official support
Ende.js and Edge-sql can run any SQL expression, can connect
using integrated security
Requires .Net 4.5
Can run only on Windows
MS SQLServer and Node.js
• JSON to SQL Type Mappings
JSON Value T-SQL Type
Numeric values (integer,
decimal, floating point)
Float(53)
Boolean Bit
DateTime DateTimeOffset(3)
String Nvarchar(max)
Microsoft Azure and Node.js
• Using Azure SQL Database with Node.js
• Default Microsoft Driver for Node.JS for SQL Server
• Open First – hosted on Github
https://github.com/Azure/node-sqlserver
• Simplicity by Design – keeps the simple API
• Use in Windows Azure Web Sites
Azure SQL Database with Node.js
• Using Azure SQL Database with Node.js
• Connecting to SQL Server Database with Node.JS – node-
sqlserver
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“
Azure SQL Database with Node.js
• Connecting to SQL Server Database with Node.JS
sql.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
Azure SQL Database with Node.js
• Using Azure SQL Database with Node.js
• Connecting to SQL Server Database with Node.JS + tedious
var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var config = {
server: 'ic509d6puu.database.windows.net',
userName: '[user]@[db-server].database.windows.net',
password: [password],
database: ' [database] ' ,
encrypt: true // for Azure users
}
Azure SQL Database with Node.js
• Using Azure SQL Database with Node.js
• Connecting to SQL Server Database with Node.JS + tedious
function executeStatement() {
request = new Request( "select 42,
'hello world'", function(err, rowCount) {
if (err) {
console.log(err);
} else {
console.log(rowCount + ' rows');
}
connection.close();
});
request.on('done',
function(rowCount, more) {
console.log(rowCount +
' rows returned‘ );
});
connection.execSql(request);
}
Azure SQL Database with Node.js
• Using Azure SQL Database with Node.js
• Connecting to SQL Server Database with Node.JS + tedious
var connection = new Connection(config);
connection.on('connect' , function(err) {
// If no error, then good to go...
executeStatement();
}
);
Azure SQL Database with Node.js
• Using Azure SQL Database with Node.js
• Connecting to SQL Server Database with Node.JS + tedious
– Insert Query
connection.on('connect', function(err){
var request = new Request("INSERT INTO MyTable (uniqueIdCol, intCol,
nVarCharCol) VALUES (@uniqueIdVal, @intVal, @nVarCharVal)",
function(err){
if(err){
console.log(err);
};
});
request.addParameter('uniqueIdVal',
TYPES.UniqueIdentifierN,'ba46b824-487b-4e7d-8fb9-703acdf954e5');
request.addParameter('intVal', TYPES.Int, 435);
request.addParameter('nVarCharVal', TYPES.NVarChar, 'hello world');
connection.execSql(request);
});
Azure SQL Database with Node.js
• Using Azure SQL Database with Node.js
• Connecting to SQL Server Database with Node.JS +
node-sqlserver-unofficial
var sql = require('node-sqlserver-unofficial');
sql.query(conn_str, "SELECT TOP 10 FirstName, LastName FROM Person.Person", function (err, results) {
if (err) {
res.writeHead(500, { 'Content-Type': 'text/plain' });
res.write( "Got error :-( " + err);
res.end( "" );
return;
}
res.writeHead(200, { 'Content-Type': 'text/plain' });
for (var i = 0; i < results.length; i++) {
res.write( "FirstName: " + results[i].FirstName + " LastName: " + results[i].LastName );
}
res.end( "; Done." );
});
Azure Storage with Node.js
• Azure Storage
• Blob Storage Table Storage Queue
Azure Storage with Node.js
• Azure Table Storage
• Table Storage – Create Table
var azureTable = require( 'azure-table-node' );
azureTable.setDefaultClient({
accountUrl: 'http://[accountName].table.core.windows.net/' ,
accountName: '[accountName] ' ,
accountKey: '[accountKey] '
});
var client = azureTable.getDefaultClient();
client.createTable( 'testtable' , function (err, data) {
});
Azure Storage with Node.js
• Azure Table Storage
• Table Storage – Display Table
var azureTable = require( 'azure-table-node' );
client.queryEntities( 'testtable' , {
query: azureTable.Query.create( 'PartitionKey' , '==', 'tests' )
}, function (err, data, continuation) {
if (err) {
res.writeHead(500, { 'Content-Type' : 'text/plain' });
res.write( "Got error :-( " + err);
res.end( "" );
return;
}
var json = JSON.stringify(data);
res.writeHead(200, { 'Content-Type' : 'text/plain' })
res.end( "Table displayed: " + json);
});
Building a Web Site with Node.js
• Node Options in the Gallery
Building a Web Site with Node.js
• DEMO
• Creating Azure Web Site with Node.js, tedious and
Azure SQL Database
• Creating Azure Web Site with Node.js, node-
sqlserver-unofficial and Azure SQL Database
• Creating Web App with Edge and Azure SQL
Database
Building a Web Site with Node.js
• DEMO
• Creating Azure Web Site with Node.js,
azure-table-node and Azure Table Storage
• Creating Azure Web Site with Node.js,
azure and Azure Blob Storage
Building and Deploying
• No build needed
• Deploy with Git (awesome)
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 error
console.log(result)
})
Node.js and C# with Edge.js
• Edge.js and SQL Server / Azure SQL Database
• The Edge.js module for Node.js allows in-process interop beween
Node.js and .NET code
• The Edge-sql extension of Edge.js enables executing T-SQL scripts
embedded within a Node.js application using asynchronous ADO.NET
running in-process with Node.js code.
• The Edge-sql extension currently supports the four basic CRUD
operations: select, insert, update, and delete.
Node.js and C# with Edge.js
• Edge.js and SQL Server / Azure SQL Database
• Connection string / using environment variables
SETX EDGE_SQL_CONNECTION_STRING "Data Source=localhost;Initial
Catalog=node-test;Integrated Security=True "
Node.js and C# with Edge.js
• Edge.js and SQL Server / Azure SQL Database
• Query SQL Server directly using Edge.js
var getTopUsers = edge.func('sql', function () { /*
SELECT TOP 5 * FROM SampleUsers ORDER BY CreateDate DESC
*/ });
Node.js and C# with Edge.js
• Edge.js, Edge-sql and SQL Server / Azure SQL Database
• Query SQL Server directly using Edge.js /
code to set the ConnectionString in node.js
var params = {
connectionString: "Data Source=IGBGSOFEV06SQLEXPRESS;Initial
Catalog=NodeJS;Integrated Security=True“ ,
source: "SELECT TOP 5 * FROM SampleUsers ORDER BY CreateDate DESC"
};
var getTopUsers = edge.func( 'sql‘ , params);
Node.js and C# with Edge.js
• Edge.js , Edge-sql and SQL Server / Azure SQL Database
• Query SQL Server directly using Edge.js
getTopUsers(null, function (error, result) {
if (error) { logError(error, res); return; }
if (result) {
res.write( "<ul>" );
result.forEach(function(user) {
res.write( "<li>" + user.FirstName + " " +
user.LastName + ": " + user.Email + "</li>" );
});
res.end( "</ul>" );
}
else {
}
});
Node.js and C# with Edge.js
• Edge.js , Edge-sql and SQL Server / Azure SQL Database
• Execute .NET code to query SQL Server
• Create a .NET class library
• Import the .Net assembly and use it’s API in Node.js +
Edge application
Node.js and C# with Edge.js
• Edge.js , Edge-sql and SQL Server / Azure SQL Database
• Create a .Net Class Library
public class Sample1
{
public async Task<object> Invoke(object input)
{
....
}
public async Task<List<SampleUser>> QueryUsers(int
pageNumber, int pageSize)
{
....
}
}
Node.js and C# with Edge.js
• Edge.js , Edge-sql and SQL Server / Azure SQL Database
• Create a .Net Class Library
public class SampleUser
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public DateTime CreateDate { get; set; }
}
Node.js and C# with Edge.js
• Edge.js , Edge-sql and SQL Server / Azure SQL Database
• Using a .Net Library from Node.js + Edje.js app
// Set up the assembly to call from Node.js
var querySample = edge.func({
assemblyFile: 'EdgeSampleLibrary.dll',
typeName: 'EdgeSampleLibrary.Sample1',
methodName: 'Invoke'
});
Node.js and C# with Edge.js
• Edge.js , Edge-sql and SQL Server / Azure SQL Database
• Using a .Net Library from Node.js + Edje.js app
// This is the data we will pass to .NET
var data = { pageNumber: 2, pageSize: 3 }
// Invoke the .NET function
querySample(data, function (error, result) {
....
});
Node.js and C# with Edge.js
• Edge.js, Edge-sql and SQL Server / Azure SQL Database
• DEMO
Mobile Services & Node.js
• Azure Mobile Services Review
Data Authentication Notifications Scripts & Svcs
Mobile Services & Node.js
• Microsoft Azure Mobile Services Architecture
Mobile Services & Node.js
• Data Storage Services
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=“…” }
RESToverHTTP
Mobile Services & Node.js
• Authentication Services
Mobile Services & Node.js
• Authentication
Mobile Services & Node.js
• Push Notification Services
Mobile Services & Node.js
• Push Notifications
Insert, Update, Delete, Read on a Table
Automatic or Manual Server Script
An Event
Script Runs in the Azure Mobile Service
Windows
Phone 8
iOS AndroidWindows 8
Mobile Services & Node.js
• Node Modules
• Extensibility through numerous included modules
Mobile Services & Node.js
• DEMO
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
Q & A

Weitere ähnliche Inhalte

Was ist angesagt?

A Journey Begin with Node.js
A Journey Begin with Node.jsA Journey Begin with Node.js
A Journey Begin with Node.jsKhalid Farhan
 
LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?phegaro
 
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
 
Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?Pixel Crayons
 
Community day 2013 applied architectures
Community day 2013   applied architecturesCommunity day 2013   applied architectures
Community day 2013 applied architecturesPanagiotis Kefalidis
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of dockerPHP Indonesia
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoPaul Withers
 
Liberty: The Right Fit for Micro Profile?
Liberty: The Right Fit for Micro Profile?Liberty: The Right Fit for Micro Profile?
Liberty: The Right Fit for Micro Profile?Dev_Events
 
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...Dakiry
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopValeri Karpov
 
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...Binary Studio
 
NoSQL for SQL Server Developers using Couchbase
NoSQL for SQL Server Developers using CouchbaseNoSQL for SQL Server Developers using Couchbase
NoSQL for SQL Server Developers using CouchbaseBrant Burnett
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
 
MEAN Stack
MEAN StackMEAN Stack
MEAN StackDotitude
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?Balajihope
 
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
 

Was ist angesagt? (20)

A Journey Begin with Node.js
A Journey Begin with Node.jsA Journey Begin with Node.js
A Journey Begin with Node.js
 
LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?
 
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
 
Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?
 
Javantura Zagreb 2014 - Vaadin - Peter Lehto
Javantura Zagreb 2014 - Vaadin - Peter LehtoJavantura Zagreb 2014 - Vaadin - Peter Lehto
Javantura Zagreb 2014 - Vaadin - Peter Lehto
 
Community day 2013 applied architectures
Community day 2013   applied architecturesCommunity day 2013   applied architectures
Community day 2013 applied architectures
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of docker
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and Domino
 
Liberty: The Right Fit for Micro Profile?
Liberty: The Right Fit for Micro Profile?Liberty: The Right Fit for Micro Profile?
Liberty: The Right Fit for Micro Profile?
 
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona Workshop
 
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
 
Nodejs
NodejsNodejs
Nodejs
 
Santosh_Resume_Java
Santosh_Resume_JavaSantosh_Resume_Java
Santosh_Resume_Java
 
NoSQL for SQL Server Developers using Couchbase
NoSQL for SQL Server Developers using CouchbaseNoSQL for SQL Server Developers using Couchbase
NoSQL for SQL Server Developers using Couchbase
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
MEAN Stack
MEAN StackMEAN Stack
MEAN Stack
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
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 ...
 

Andere mochten auch

Node.js on microsoft azure april 2014
Node.js on microsoft azure april 2014Node.js on microsoft azure april 2014
Node.js on microsoft azure april 2014Brian Benz
 
Node.js X Windows Azure
Node.js X Windows AzureNode.js X Windows Azure
Node.js X Windows AzureCaesar Chi
 
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 on Windows Azure
Node.js on Windows AzureNode.js on Windows Azure
Node.js on Windows AzureNeil Mackenzie
 
Node.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale WebinarNode.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale Webinarjguerrero999
 
Develop & Deploy Node.js app on Windows Azure
Develop & Deploy Node.js app on Windows AzureDevelop & Deploy Node.js app on Windows Azure
Develop & Deploy Node.js app on Windows AzureAndri Yadi
 
Future Of Digital Marketing
Future Of Digital MarketingFuture Of Digital Marketing
Future Of Digital MarketingNeil Perkin
 
Surprising Data Around How We Work [Infographic]
Surprising Data Around How We Work [Infographic]Surprising Data Around How We Work [Infographic]
Surprising Data Around How We Work [Infographic]Citrix
 
Building Your First Node.js App and Publishing to Azure
Building Your First Node.js App and Publishing to AzureBuilding Your First Node.js App and Publishing to Azure
Building Your First Node.js App and Publishing to AzureSarah Sexton
 

Andere mochten auch (10)

Node.js on microsoft azure april 2014
Node.js on microsoft azure april 2014Node.js on microsoft azure april 2014
Node.js on microsoft azure april 2014
 
Node.js X Windows Azure
Node.js X Windows AzureNode.js X Windows Azure
Node.js X Windows 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
 
Node.js on Windows Azure
Node.js on Windows AzureNode.js on Windows Azure
Node.js on Windows Azure
 
Node.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale WebinarNode.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale Webinar
 
Develop & Deploy Node.js app on Windows Azure
Develop & Deploy Node.js app on Windows AzureDevelop & Deploy Node.js app on Windows Azure
Develop & Deploy Node.js app on Windows Azure
 
Disruptive Innovations in Education
Disruptive Innovations in EducationDisruptive Innovations in Education
Disruptive Innovations in Education
 
Future Of Digital Marketing
Future Of Digital MarketingFuture Of Digital Marketing
Future Of Digital Marketing
 
Surprising Data Around How We Work [Infographic]
Surprising Data Around How We Work [Infographic]Surprising Data Around How We Work [Infographic]
Surprising Data Around How We Work [Infographic]
 
Building Your First Node.js App and Publishing to Azure
Building Your First Node.js App and Publishing to AzureBuilding Your First Node.js App and Publishing to Azure
Building Your First Node.js App and Publishing to Azure
 

Ähnlich wie Varna conf nodejs-oss-microsoft-azure[final]

Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
Node js installation steps.pptx slide share ppts
Node js installation steps.pptx slide share pptsNode js installation steps.pptx slide share ppts
Node js installation steps.pptx slide share pptsHemaSenthil5
 
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
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNaveen S.R
 
.NET vs. Node.js: What to Choose for Web Development
.NET vs. Node.js: What to Choose for Web Development.NET vs. Node.js: What to Choose for Web Development
.NET vs. Node.js: What to Choose for Web DevelopmentDashTechnologiesInc
 
Node.js and Enterprise Web Apps: Know all About it
Node.js and Enterprise Web Apps: Know all About itNode.js and Enterprise Web Apps: Know all About it
Node.js and Enterprise Web Apps: Know all About itFibonalabs
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node jsHabilelabs
 
Node.js for .NET Developers
Node.js for .NET DevelopersNode.js for .NET Developers
Node.js for .NET DevelopersDavid Neal
 
node_js.pptx
node_js.pptxnode_js.pptx
node_js.pptxdipen55
 
All You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdfAll You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdfiDataScientists
 
Azure Bootcamp Louisville - Node js presentation
Azure Bootcamp Louisville - Node js presentationAzure Bootcamp Louisville - Node js presentation
Azure Bootcamp Louisville - Node js presentationAndrea Walker
 
Building Node.js Together | Radu Vunvulea
Building Node.js Together | Radu VunvuleaBuilding Node.js Together | Radu Vunvulea
Building Node.js Together | Radu VunvuleaRadu Vunvulea
 
Web Applications Development with MEAN Stack
Web Applications Development with MEAN StackWeb Applications Development with MEAN Stack
Web Applications Development with MEAN StackShailendra Chauhan
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRob O'Doherty
 
Node.js and .NET Core.pdf
Node.js and .NET Core.pdfNode.js and .NET Core.pdf
Node.js and .NET Core.pdfAppdeveloper10
 
Dot net platform and dotnet core fundamentals
Dot net platform and dotnet core fundamentalsDot net platform and dotnet core fundamentals
Dot net platform and dotnet core fundamentalsLalit Kale
 

Ähnlich wie Varna conf nodejs-oss-microsoft-azure[final] (20)

Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Node js installation steps.pptx slide share ppts
Node js installation steps.pptx slide share pptsNode js installation steps.pptx slide share ppts
Node js installation steps.pptx slide share ppts
 
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
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A Primer
 
.NET vs. Node.js: What to Choose for Web Development
.NET vs. Node.js: What to Choose for Web Development.NET vs. Node.js: What to Choose for Web Development
.NET vs. Node.js: What to Choose for Web Development
 
Node.js and Enterprise Web Apps: Know all About it
Node.js and Enterprise Web Apps: Know all About itNode.js and Enterprise Web Apps: Know all About it
Node.js and Enterprise Web Apps: Know all About it
 
Node ts1
Node ts1Node ts1
Node ts1
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 
Node.js for .NET Developers
Node.js for .NET DevelopersNode.js for .NET Developers
Node.js for .NET Developers
 
node_js.pptx
node_js.pptxnode_js.pptx
node_js.pptx
 
All You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdfAll You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdf
 
Azure Bootcamp Louisville - Node js presentation
Azure Bootcamp Louisville - Node js presentationAzure Bootcamp Louisville - Node js presentation
Azure Bootcamp Louisville - Node js presentation
 
Node js for enterprise
Node js for enterpriseNode js for enterprise
Node js for enterprise
 
Building Node.js Together | Radu Vunvulea
Building Node.js Together | Radu VunvuleaBuilding Node.js Together | Radu Vunvulea
Building Node.js Together | Radu Vunvulea
 
Web Applications Development with MEAN Stack
Web Applications Development with MEAN StackWeb Applications Development with MEAN Stack
Web Applications Development with MEAN Stack
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node.js and .NET Core.pdf
Node.js and .NET Core.pdfNode.js and .NET Core.pdf
Node.js and .NET Core.pdf
 
Dot net platform and dotnet core fundamentals
Dot net platform and dotnet core fundamentalsDot net platform and dotnet core fundamentals
Dot net platform and dotnet core fundamentals
 
NodeJS Presentation
NodeJS PresentationNodeJS Presentation
NodeJS Presentation
 

Mehr von Mihail Mateev

Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DBDealing with Azure Cosmos DB
Dealing with Azure Cosmos DBMihail Mateev
 
Clash of Technologies Google Cloud vs Microsoft Azure
Clash of Technologies Google Cloud vs Microsoft AzureClash of Technologies Google Cloud vs Microsoft Azure
Clash of Technologies Google Cloud vs Microsoft AzureMihail Mateev
 
Devday 2014 using_afs_in_your_cloud_app
Devday 2014 using_afs_in_your_cloud_appDevday 2014 using_afs_in_your_cloud_app
Devday 2014 using_afs_in_your_cloud_appMihail Mateev
 
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...Mihail Mateev
 
Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevMihail Mateev
 
Using SQL Local Database in Mobile Applications
Using SQL Local Database in Mobile ApplicationsUsing SQL Local Database in Mobile Applications
Using SQL Local Database in Mobile ApplicationsMihail Mateev
 
Spatial Data with SQL Server Reporting Services
Spatial Data with SQL Server Reporting ServicesSpatial Data with SQL Server Reporting Services
Spatial Data with SQL Server Reporting ServicesMihail Mateev
 

Mehr von Mihail Mateev (7)

Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DBDealing with Azure Cosmos DB
Dealing with Azure Cosmos DB
 
Clash of Technologies Google Cloud vs Microsoft Azure
Clash of Technologies Google Cloud vs Microsoft AzureClash of Technologies Google Cloud vs Microsoft Azure
Clash of Technologies Google Cloud vs Microsoft Azure
 
Devday 2014 using_afs_in_your_cloud_app
Devday 2014 using_afs_in_your_cloud_appDevday 2014 using_afs_in_your_cloud_app
Devday 2014 using_afs_in_your_cloud_app
 
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
 
Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateev
 
Using SQL Local Database in Mobile Applications
Using SQL Local Database in Mobile ApplicationsUsing SQL Local Database in Mobile Applications
Using SQL Local Database in Mobile Applications
 
Spatial Data with SQL Server Reporting Services
Spatial Data with SQL Server Reporting ServicesSpatial Data with SQL Server Reporting Services
Spatial Data with SQL Server Reporting Services
 

Varna conf nodejs-oss-microsoft-azure[final]

  • 1. Cherno More Hotel 12 July 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
  • 2. How this talk has started…. Боби, хайде да направим една презентация за Microsoft Azure
  • 3. How this talk has started…. Ами… щом е за облачни технолологии няма да откажа… но нека да е с Node.js
  • 4. How this talk has started…. А защо да не е за open source технологии в Microsoft Azure ? Да включим и други технологии ?
  • 5. How this talk has started…. Ето така се правят презентации…
  • 6. How this talk has started…. Момчета, това е една интересна тема за Varna Conf
  • 7. Mihail Mateev • About… Mihail Mateev is a Senior Technical Evangelist, Team Lead at Infragistics Inc., Community Lead for Europe, Microsoft Azure MVP Mihail works in various areas related to Microsoft technologies : Silverlight, WPF, WP, LightSwitch, WCF, ASP.Net MVC, MS SQL Server and Microsoft Azure
  • 8. Contents • Why Node.js • Comparing Node.js to .NET • Introduction to Node.js on Windows • Using Azure SQL Database with Node.js • Accessing Azure Storage with Node.js • Building a Web Site with Node.js • Deploying a Node.js Application • Node.js & Edge.js • Microsoft Azure Mobile Services and Node.js • Resources
  • 9. 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
  • 10. What is Node.js • 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
  • 11. Why Node.js? • Node.js uses JavaScript syntax. • There are more than 100 000 000 WEB developers! • The realistic reason: Cross platform applications with JS will be faster and easier
  • 12. 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
  • 13. Node.js Timeline 2009 2010 2011 2012 2013 2014 Jan 2009 Created Ryan Dahl April 2010 Heroku launches node support Nov 2011 Windows Azure support EBay releases API built on node Cloud9IDE azure support 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 Cloud9I DE 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
  • 14. Comparing Node.js to .NET • Traditional Web Server Model Client Server Request Response Dedicated Thread to service request
  • 15. Comparing Node.js to .NET • Traditional Web Server Model Request 1 thread 1 processes the request and blocks till completion Response 1 thread 1000 processes the request and 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
  • 16. 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 async operation is complete thread completes the request
  • 17. 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 parallel Except your code ! ” Response 99999
  • 18. Comparing Node.js to .NET • Mapping the Nomenclature IIS Node.js C# / VB JavaScript EF / SQL Server Mongoose/MongoDB or other Database ASP.NET Web Forms Express + EJS ASP.NET MVC/Razor Express + Jade/Razor ASP.NET Web API Express/Hapi SignalR WS / Socket.IO AngularJS / KnockoutJS AngularJS / KnockoutJS
  • 19. Introduction to Node.js on Windows • How Node.js works?
  • 20. Introduction to Node.js on Windows Node is Single Threaded!
  • 21. Introduction to Node.js on Windows ..but, Node is FAST!
  • 22. 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)
  • 23. Introduction to Node.js on Windows • How Node.js works?
  • 24. 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
  • 25. 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.
  • 26. Introduction to Node.js on Windows • Enabling a Node.js Server-Side App on Windows Azure (PaaS)
  • 27. 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
  • 28. 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
  • 29. MS SQLServer and Node.js • Node.js Modules for SQLServer #N % Node.js Module #1 20.7% node-sqlserver Microsoft Driver for Node.js for SQL Server #2 18.0% tedious A TDS driver, for connecting to MS SQLServer databases #3 12.3% tds TDS client for connecting to Microsoft SQL Server #4 1.5% mssqlhelper Microsoft SQL Server database helper #5 0.4% mssqlx NodeJs Microsoft SQL Server Command Line Interface #6 0.2% msnodesql Microsoft Driver for Node.js for SQL Server #7 N/A node-sqlserver-unofficial Microsoft Driver for Node.js for SQL Server – unofficial distribution
  • 30. MS SQLServer and Node.js • node-sqlserver & msnodesql • Microsoft Driver for Node.js for SQL Server and Azure SQL Database: Node.js module, based on SQL Server Native Client 11.0 - available as Microsoft SQL Server 2012 Native Client found in the SQL Server 2012 Feature Pack • The same repository, different npm packages
  • 31. MS SQLServer and Node.js • node-sqlserver-unofficial This is an unofficial binary distribution of that driver. • No need to compile from source (which requires Visual Studio and totally confuses people). • It runs on both x86 and x64 and with node versions 0.8 and 0.10. • No workarounds needed to run on Azure web sites. node-sqlserver-unofficial npm page
  • 32. MS SQLServer and Node.js • node-sqlserver-unofficial This is an unofficial binary distribution of that driver. • No need to compile from source (which requires Visual Studio and totally confuses people). • It runs on both x86 and x64 and with node versions 0.8 and 0.10. • No workarounds needed to run on Azure web sites. node-sqlserver-unofficial npm page
  • 33. MS SQLServer and Node.js • tedious • A TDS driver, for connecting to MS SQLServer databases. • Tedious is an implementation of the TDS protocol, which is used to interact with instances of Microsoft's SQL Server. It is intended to be a fairly slim implementation of the protocol, with not too much additional functionality. • Tedious is implemented only with JavaScript
  • 34. MS SQLServer and Node.js • node-tds • This is a module that allows you to access Microsoft SQL Server 2005 and later. • It is a pure JS implementation of the TDS protocol hosted on GitHub. • node-tds is similar to tedious
  • 35. MS SQLServer and Node.js • node-tds mssqlhelper • Microsoft SQL Server Helper nodejs • mssqlx • NodeJs Microsoft SQL Server Command Line Interface
  • 36. MS SQLServer and Node.js • Pros and Cons driver pros cons tedious, tds Lightweight , JS implementation, no dependencies Limited functionalities, Cannot use integrated authentication msnodesql, node-sqlserver More features Many dependencies, No actual builds Require custom build node-sqlserver- unofficial Same like msnodesql, node-sqlserver, fixed issues with the official distributions No official support Ende.js and Edge-sql can run any SQL expression, can connect using integrated security Requires .Net 4.5 Can run only on Windows
  • 37. MS SQLServer and Node.js • JSON to SQL Type Mappings JSON Value T-SQL Type Numeric values (integer, decimal, floating point) Float(53) Boolean Bit DateTime DateTimeOffset(3) String Nvarchar(max)
  • 38. Microsoft Azure and Node.js • Using Azure SQL Database with Node.js • Default Microsoft Driver for Node.JS for SQL Server • Open First – hosted on Github https://github.com/Azure/node-sqlserver • Simplicity by Design – keeps the simple API • Use in Windows Azure Web Sites
  • 39. Azure SQL Database with Node.js • Using Azure SQL Database with Node.js • Connecting to SQL Server Database with Node.JS – node- sqlserver 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“
  • 40. Azure SQL Database with Node.js • Connecting to SQL Server Database with Node.JS sql.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
  • 41. Azure SQL Database with Node.js • Using Azure SQL Database with Node.js • Connecting to SQL Server Database with Node.JS + tedious var Connection = require('tedious').Connection; var Request = require('tedious').Request; var config = { server: 'ic509d6puu.database.windows.net', userName: '[user]@[db-server].database.windows.net', password: [password], database: ' [database] ' , encrypt: true // for Azure users }
  • 42. Azure SQL Database with Node.js • Using Azure SQL Database with Node.js • Connecting to SQL Server Database with Node.JS + tedious function executeStatement() { request = new Request( "select 42, 'hello world'", function(err, rowCount) { if (err) { console.log(err); } else { console.log(rowCount + ' rows'); } connection.close(); }); request.on('done', function(rowCount, more) { console.log(rowCount + ' rows returned‘ ); }); connection.execSql(request); }
  • 43. Azure SQL Database with Node.js • Using Azure SQL Database with Node.js • Connecting to SQL Server Database with Node.JS + tedious var connection = new Connection(config); connection.on('connect' , function(err) { // If no error, then good to go... executeStatement(); } );
  • 44. Azure SQL Database with Node.js • Using Azure SQL Database with Node.js • Connecting to SQL Server Database with Node.JS + tedious – Insert Query connection.on('connect', function(err){ var request = new Request("INSERT INTO MyTable (uniqueIdCol, intCol, nVarCharCol) VALUES (@uniqueIdVal, @intVal, @nVarCharVal)", function(err){ if(err){ console.log(err); }; }); request.addParameter('uniqueIdVal', TYPES.UniqueIdentifierN,'ba46b824-487b-4e7d-8fb9-703acdf954e5'); request.addParameter('intVal', TYPES.Int, 435); request.addParameter('nVarCharVal', TYPES.NVarChar, 'hello world'); connection.execSql(request); });
  • 45. Azure SQL Database with Node.js • Using Azure SQL Database with Node.js • Connecting to SQL Server Database with Node.JS + node-sqlserver-unofficial var sql = require('node-sqlserver-unofficial'); sql.query(conn_str, "SELECT TOP 10 FirstName, LastName FROM Person.Person", function (err, results) { if (err) { res.writeHead(500, { 'Content-Type': 'text/plain' }); res.write( "Got error :-( " + err); res.end( "" ); return; } res.writeHead(200, { 'Content-Type': 'text/plain' }); for (var i = 0; i < results.length; i++) { res.write( "FirstName: " + results[i].FirstName + " LastName: " + results[i].LastName ); } res.end( "; Done." ); });
  • 46. Azure Storage with Node.js • Azure Storage • Blob Storage Table Storage Queue
  • 47. Azure Storage with Node.js • Azure Table Storage • Table Storage – Create Table var azureTable = require( 'azure-table-node' ); azureTable.setDefaultClient({ accountUrl: 'http://[accountName].table.core.windows.net/' , accountName: '[accountName] ' , accountKey: '[accountKey] ' }); var client = azureTable.getDefaultClient(); client.createTable( 'testtable' , function (err, data) { });
  • 48. Azure Storage with Node.js • Azure Table Storage • Table Storage – Display Table var azureTable = require( 'azure-table-node' ); client.queryEntities( 'testtable' , { query: azureTable.Query.create( 'PartitionKey' , '==', 'tests' ) }, function (err, data, continuation) { if (err) { res.writeHead(500, { 'Content-Type' : 'text/plain' }); res.write( "Got error :-( " + err); res.end( "" ); return; } var json = JSON.stringify(data); res.writeHead(200, { 'Content-Type' : 'text/plain' }) res.end( "Table displayed: " + json); });
  • 49. Building a Web Site with Node.js • Node Options in the Gallery
  • 50. Building a Web Site with Node.js • DEMO • Creating Azure Web Site with Node.js, tedious and Azure SQL Database • Creating Azure Web Site with Node.js, node- sqlserver-unofficial and Azure SQL Database • Creating Web App with Edge and Azure SQL Database
  • 51. Building a Web Site with Node.js • DEMO • Creating Azure Web Site with Node.js, azure-table-node and Azure Table Storage • Creating Azure Web Site with Node.js, azure and Azure Blob Storage
  • 52. Building and Deploying • No build needed • Deploy with Git (awesome)
  • 53. 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 error console.log(result) })
  • 54. Node.js and C# with Edge.js • Edge.js and SQL Server / Azure SQL Database • The Edge.js module for Node.js allows in-process interop beween Node.js and .NET code • The Edge-sql extension of Edge.js enables executing T-SQL scripts embedded within a Node.js application using asynchronous ADO.NET running in-process with Node.js code. • The Edge-sql extension currently supports the four basic CRUD operations: select, insert, update, and delete.
  • 55. Node.js and C# with Edge.js • Edge.js and SQL Server / Azure SQL Database • Connection string / using environment variables SETX EDGE_SQL_CONNECTION_STRING "Data Source=localhost;Initial Catalog=node-test;Integrated Security=True "
  • 56. Node.js and C# with Edge.js • Edge.js and SQL Server / Azure SQL Database • Query SQL Server directly using Edge.js var getTopUsers = edge.func('sql', function () { /* SELECT TOP 5 * FROM SampleUsers ORDER BY CreateDate DESC */ });
  • 57. Node.js and C# with Edge.js • Edge.js, Edge-sql and SQL Server / Azure SQL Database • Query SQL Server directly using Edge.js / code to set the ConnectionString in node.js var params = { connectionString: "Data Source=IGBGSOFEV06SQLEXPRESS;Initial Catalog=NodeJS;Integrated Security=True“ , source: "SELECT TOP 5 * FROM SampleUsers ORDER BY CreateDate DESC" }; var getTopUsers = edge.func( 'sql‘ , params);
  • 58. Node.js and C# with Edge.js • Edge.js , Edge-sql and SQL Server / Azure SQL Database • Query SQL Server directly using Edge.js getTopUsers(null, function (error, result) { if (error) { logError(error, res); return; } if (result) { res.write( "<ul>" ); result.forEach(function(user) { res.write( "<li>" + user.FirstName + " " + user.LastName + ": " + user.Email + "</li>" ); }); res.end( "</ul>" ); } else { } });
  • 59. Node.js and C# with Edge.js • Edge.js , Edge-sql and SQL Server / Azure SQL Database • Execute .NET code to query SQL Server • Create a .NET class library • Import the .Net assembly and use it’s API in Node.js + Edge application
  • 60. Node.js and C# with Edge.js • Edge.js , Edge-sql and SQL Server / Azure SQL Database • Create a .Net Class Library public class Sample1 { public async Task<object> Invoke(object input) { .... } public async Task<List<SampleUser>> QueryUsers(int pageNumber, int pageSize) { .... } }
  • 61. Node.js and C# with Edge.js • Edge.js , Edge-sql and SQL Server / Azure SQL Database • Create a .Net Class Library public class SampleUser { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } public DateTime CreateDate { get; set; } }
  • 62. Node.js and C# with Edge.js • Edge.js , Edge-sql and SQL Server / Azure SQL Database • Using a .Net Library from Node.js + Edje.js app // Set up the assembly to call from Node.js var querySample = edge.func({ assemblyFile: 'EdgeSampleLibrary.dll', typeName: 'EdgeSampleLibrary.Sample1', methodName: 'Invoke' });
  • 63. Node.js and C# with Edge.js • Edge.js , Edge-sql and SQL Server / Azure SQL Database • Using a .Net Library from Node.js + Edje.js app // This is the data we will pass to .NET var data = { pageNumber: 2, pageSize: 3 } // Invoke the .NET function querySample(data, function (error, result) { .... });
  • 64. Node.js and C# with Edge.js • Edge.js, Edge-sql and SQL Server / Azure SQL Database • DEMO
  • 65. Mobile Services & Node.js • Azure Mobile Services Review Data Authentication Notifications Scripts & Svcs
  • 66. Mobile Services & Node.js • Microsoft Azure Mobile Services Architecture
  • 67. Mobile Services & Node.js • Data Storage Services
  • 68. 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=“…” } RESToverHTTP
  • 69. Mobile Services & Node.js • Authentication Services
  • 70. Mobile Services & Node.js • Authentication
  • 71. Mobile Services & Node.js • Push Notification Services
  • 72. Mobile Services & Node.js • Push Notifications Insert, Update, Delete, Read on a Table Automatic or Manual Server Script An Event Script Runs in the Azure Mobile Service Windows Phone 8 iOS AndroidWindows 8
  • 73. Mobile Services & Node.js • Node Modules • Extensibility through numerous included modules
  • 74. Mobile Services & Node.js • DEMO
  • 75. 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
  • 76. Q & A