Upload
johannes-hoppe
View
3.929
Download
3
Tags:
Embed Size (px)
DESCRIPTION
This talk concentrates on Microsoft's cloud platform, called Azure. Johannes gives an introduction to the new platform and speaks about its possibilities and limitations. By utilizing the Windows Azure SDK for Node.js he is going to demonstrate a simple JavaScript-driven browser game that bases on Node.js and MongoDB.
Citation preview
20.03.2012 Dipl.-Inf. (FH) Johannes Hoppe
Getting started with Node.js and MongoDB on MS Azure
®
Hello
01
JavaScript?
As a server side
language?
Executed inside
a database?
For a hardware-
accelerated
3D game?
Hosted on
WINDOWS?
Yes! .of course
Live Demo solartournament.org
solartournament.org
SDK for Node.js
02
PaaS / IaaS
Visual Studio 2010
Targets .NET, but also and now officially:
Java, PHP, Node.js… MongoDB
platform
Cloud
Event-driven Asynchronous I/O
JavaScript Google V8 engine
Server-side MIT License
www.windowsazure.com/en-us/develop/nodejs/
What you get › node.exe
› iisnode (native IIS module)
› NPM for Windows (package manager)
› […]
Live Demo / Windows PowerShell
› New-AzureService helloworld
› Add-AzureNodeWebRole
› Start-AzureEmulator -launch
server.js var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello world!'); }).listen(process.env.PORT);
Azure SDK for Node.js
Troubleshooter
Tricky Emulator › Webinstaller: Decide for IIS Express
› Start PowerShell with Admin Rights
Tricky Emulator › Check the Windows Event log
› Last resort: start node.exe manually
Deployment / Windows PowerShell
› Get-AzurePublishSettings
› Import-AzurePublishSettings filename.publishSettings
› Publish-AzureService -name UniqueName -location "North
Europe" -launch
Node.js Web Application Tutorial:
http://www.windowsazure.com/en-
us/develop/nodejs/tutorials/getting-started/
Roles & Storage
Windows Azure Compute
Web Role Worker Role VM Role
Windows Azure
Storage SQL Azure
Table / Queue / Blob
Azure Storage Explorer http://azurestorageexplorer.codeplex.com/
Supports blobs, queues and tables
MongoDB
03
“Microsoft has been working with 10gen
to provide MongoDB database
integration for Windows Azure,
including deployment packaging,
documentation, and code samples.” MSDN, December 2011: http://msdn.microsoft.com/en-us/library/gg441573.aspx
http://downloads.mongodb.org/azure/
AzureMongoDeploymentCmdlets.msi
PowerShell › Only once: Get-AzureMongoDBBinaries
› Add-AzureMongoWorkerRole
› Join-AzureNodeRoleToMongoRole WebRole1
› npm install mongodb
node-mongodb-native // the normal way
var mongoServer = new MongoServer("localhost", 27017, {});
mongoDb = new MongoDb(MONGO_DATABASE, mongoServer,
{ native_parser: false });
mongoDb.open(function () { });
On Azure var azureMongoEndpoints = new AzureMongoEndpoint('ReplicaSetRole', 'MongodPort');
azureMongoEndpoints.on('topologyChange', function () {
if (mongoDb != null) {
mongoDb.close();
mongoDb = null;
}
var mongoAzureServer = azureMongoEndpoints.getMongoDBServerConfig();
mongoDb = new MongoDb(MONGO_DATABASE, mongoAzureServer,
{ native_parser: false });
mongoDb.open(function () { });
});
azureMongoEndpoints.on('error', function (error) { throw error; }); }
Node.js Web Application
with Storage on MongoDB Tutorial:
https://www.windowsazure.com/en-
us/develop/nodejs/tutorials/web-app-with-mongodb/
Conclusion
04
Node.js on Azure? › Stable, works like expected
› Often fiddling on the startup scripts
› Installation binaries: slow upload
(a general Azure problem)
› Thumbs up to iisnode
MongoDB on Azure? › Development version (2.1.1-pre-) of MongoDB
› Not recommended for production.
› No Sharding!
› Works stable for me
Questions?
Thank you! blog.johanneshoppe.de
Next Speaking Engagements › 12.04.2012 – .NET UG Niederrhein: AOP / .NET
› 10.05.2012 – .NET UG Karlsruhe: NoSQL / .NET
› 14.05.2012 – .NET Developer Conference (DDC)
.Nürnberg: NoSQL / .NET (2 talks)
Picture credits
wave © THesIMPLIFY – Fotolia.com
Stressed businessman © Selecstock – Fotolia.com
Ausgewählter Ordner © Spectral-Design – Fotolia.com
Warnhinweis-Schild © Sascha Tiebel – Fotolia.com
Liste abhaken © Dirk Schumann – Fotolia.com