building node.js applications for microsoft azure cloud
DESCRIPTION
Building Node.js applications for Microsoft Azure cloud. Presentation held on 14 September 2014 in WebExpo, Prague.TRANSCRIPT
Building Node.js applications for Microsoft Azure cloudCatalin Fratila
2014 © Skype
September 2014
2014 © Skype
Agenda
• Why should you do it?
• Possibilities
• Where to store data?
• Development, Build and Deployment
• Demo
Slide 2
2014 © Skype
What is Azure?
Slide 3
2014 © Skype
Benefits of Azure – Powerful Capabilities
Slide 4
data
servicesTable
StorageHDInsightBlob
storageSQL
database
app
services
Media
HPCIntegration Analytics
Caching IdentityService
Bus
Web SitesMobile
Services
Cloud Services
infrastructure
servicesCDN
Virtual Machines
Virtual Network VPN
Traffic Manager
2014 © Skype
What is Node.js?• Server-side JavaScript
• Core in C++ on top of V8
• Open Source (MIT license)
• Provide an easy way to build scalable network programs
Slide 5
2014 © Skype
Benefits of Node.js• Server-side JavaScript
• Handles thousand of concurrent connections with minimal overhead on a single process
• Asynchronous I/O Framework
• Swiss army knife for network related work
• NPM
• Community
• Good for: real-time communications, custom network services, JSON web services etc.
Slide 6
2014 © Skype
How to build a web service in Azure
• Virtual machines
• Cloud Services
• Web Sites
Slide 7
2014 © Skype
Virtual machines
• Windows Server and Linux
• Flexible Workload Support
• Built-in Virtual Private Networking, Load Balancing
Slide 8
For current VM Linux pricing: http://azure.microsoft.com/en-us/pricing/details/virtual-machines/#linux For more information about Virtual Machines: http://msdn.microsoft.com/library/azure/dn197896.aspx
For current VM Windows pricing: http://azure.microsoft.com/en-us/pricing/details/virtual-machines
2014 © Skype
Cloud services
• Build infinitely scalable apps and services
• Support multi-tier architectures
• Automated application management
Slide 9
For current Cloud Services pricing: http://azure.microsoft.com/en-us/pricing/details/cloud-services/
For more information about Cloud Services: http://azure.microsoft.com/en-us/services/cloud-services/
2014 © Skype
Web Sites
• Build application using ASP.NET, Java, Python, Node.js or PHP
• Built-in AutoScale and Load Balancing
• Continuous Deployment with Git, TFS, GitHub
Slide 10
For current Websites pricing: http://azure.microsoft.com/en-us/pricing/details/web-sites/
For more information about Websites: http://azure.microsoft.com/en-us/services/web-sites
2014 © Skype
Where to store data?
• Azure Storage
• CDN
• Others
Slide 11
2014 © Skype
Storage
• Highly scalable
• Durable & highly available
• Designed for developers
• Global Reach
• Cost effective
Slide 12
For Storage pricing: http://azure.microsoft.com/en-us/pricing/details/storage/
For more information about Storage: http://azure.microsoft.com/en-us/services/storage/
2014 © Skype
Content Delivery Network
• Low latencies
• Massively scalable
• Capacity on demand
• Robust security
Slide 13
For CDN pricing: http://azure.microsoft.com/en-us/pricing/details/cdn/
For more information about CDN: http://msdn.microsoft.com/library/azure/ee795176.aspx
2014 © Skype
Others
• MongoDB
• Azure DocumentDB
• Azure SQL Database
Slide 14
For more information about MongoDB: http://azure.microsoft.com/en-us/gallery/store/mongodb/mongodb-inc/
For more information about DocumentDB: http://azure.microsoft.com/en-us/documentation/services/documentdb/
For more information about SQL: http://azure.microsoft.com/en-us/documentation/services/sql-database/
2014 © Skype
Development, Build and Deployment?
• Support in Visual Studio
• Grunt + Git
Slide 15
2014 © Skype
Node.js in Visual Studio• Node.js Tools for Visual Studio
• IntelliSense• Completions
• Signature help
• Debugging
• npm
• Azure Deployment• Web Site using Web Deploy
• Web Site using Git
• Cloud Service – Web Role and Worker Role
• Testing
Slide 16
2014 © Skype
Not used with Visual Studio?• Use Git to manage deployments and your own IDE to develop
Slide 17
Web Sites Git
2014 © Skype
Automate
• Grunt – the JavaScript Task Runner
Slide 18
2014 © Skype
DEMO
Slide 19
2014 © Skype
Azure Web Portal
Slide 20
2014 © Skype
Create new Web Site
Slide 21
2014 © Skype
New Website
Slide 22
2014 © Skype
Manage the Web Site
Slide 23
2014 © Skype
Set-up Git local repository
Slide 24
2014 © Skype
Setup credentials for the Git repository
Slide 25
2014 © Skype
Git deployment overview page
Slide 26
2014 © Skype
Write code locally and run it
Slide 27
2014 © Skype
Deploy application
Slide 28
2014 © Skype
Deploy application
Slide 29
2014 © Skype
Deploy application
Slide 30
2014 © Skype
Deploy application
Slide 31
2014 © Skype
Publish changes
Slide 32
2014 © Skype
Publish changes
Slide 33
2014 © Skype
Grunt
Slide 34
npm install grunt-cli
npm install grunt --save-devnpm install <dep-name> --save-dev
npm init
2014 © Skype
Grunt
• Package.json
Slide 35
2014 © Skype
Grunt
• Gruntfile.js
Slide 36
2014 © Skype
Why not introduce CDN?
Slide 37
2014 © Skype
Why not introduce CDN?
Slide 38
2014 © Skype
What changes?
Slide 39
2014 © Skype
What changes?
Slide 40
2014 © Skype
What changes?
Slide 41
2014 © Skype
Conclusions
Slide 42
• Azure, Node.js, Git, Grunt – all working together
• Web Sites - easy to use, not too many configurations
• Storage - cheap
• Development, build and deployment
2014 © Skype
Resources
Slide 43
• Azure - http://azure.microsoft.com/en-us/
• Node.js Developer Center - http://azure.microsoft.com/en-us/develop/nodejs/
• Grunt - http://gruntjs.com/
• Node.js - http://nodejs.org/
• Node.js Tools for VS - https://nodejstools.codeplex.com/documentation
• Proof of concept demo - https://onedrive.live.com/redir?resid=FE58AA4F21A81AE9%21105
2014 © Skype
Questions?
Slide 44