1 / 41

Node.js on Windows Azure

Agenda. What is NodeJS?NodeJS on WindowsWhat is Windows Azure?NodeJS on Windows Azure. What is node.js?. JavaScript on the Server!Event driven I/O server-side JavaScriptNot thread based, each connection uses only a small heap allocationEfficient and highly scalable. JavaScript Server. Started

justice
Télécharger la présentation

Node.js on Windows Azure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Node.js on Windows Azure Eric ShangKuan (ericsk) Developer Evangelist Microsoft Taiwan Corporation

    2. Agenda What is NodeJS? NodeJS on Windows What is Windows Azure? NodeJS on Windows Azure

    3. What is node.js? JavaScript on the Server! Event driven I/O server-side JavaScript Not thread based, each connection uses only a small heap allocation Efficient and highly scalable

    4. JavaScript Server Started 2009 by @ryah Open Source (MIT license) Sponsored by Second most popular project on GitHub

    5. Async Model Single-threaded event loop Thread must not stop for anything!

    6. Node is

    7. Pros

    8. Application Frameworks

    9. Node.js on Windows Native node.exe IISNode a native IIS 7.x module that allows hosting of node.js applications in IIS Most modules supported as is Performance on par with Linux implementation

    10. IIS Node Process management Scalability on multi-core servers Auto-update Access to logs over HTTP Side by side with other content types Minimal changes to node.js application code Integrated management experience See: http://tomasz.janczuk.org/2011/08/hosting-nodejs-applications-in-iis-on.html See: http://tomasz.janczuk.org/2011/08/hosting-nodejs-applications-in-iis-on.html

    11. IIS Node <configuration> <system.webServer> <handlers> <add name="iisnode" path="app.js" verb="*" modules="iisnode" /> </handlers> </system.webServer> </configuration> IISNode load balances across the Node.exe instances - Auto-restarts when app.js changes - captures console output and logs it to disk - lets you host traditional ASP.NET code in the same IIS app (its just another handler) IISNode load balances across the Node.exe instances - Auto-restarts when app.js changes - captures console output and logs it to disk - lets you host traditional ASP.NET code in the same IIS app (its just another handler)

    12. Node Package Manager Package manager for node Allows you to easily add modules to your application Use through the command line: C:\nodehello> npm install express

    13. NPM Node Package Manager

    14. Install node.js on Windows Single Install: node.js + npm Download: bit.ly/nodejsdownload

    15. Hello World

    16. Node.js Hello World server.js File: var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello, world! '); }).listen(80);

    17. Run node.js Hello World C:\nodehello> node.exe server.js

    18. Node.js Hello World

    19. Node.js + Express demo

    20. Node.js On Windows Azure

    21. Windows Azure Comprehensive set of services that enable you to build, host and scale applications in Microsoft datacenters First introduced the platform 3 years ago at the 2008 Professional Developers Conference. Three key principles First introduced the platform 3 years ago at the 2008 Professional Developers Conference. Three key principles

    22. Windows Azure Speaking Points: 3 core services: Compute, Storage, Database Lets take a look at the platform starting with the core services. Compute: Scalable environment for running code Enables .NET, C++, PHP, Ruby, Python, Automated service management Storage: Scalable and highly available cloud storage Blobs, Tables, Queues, Drives REST APIs and several client libraries Database: SQL Relational Database Familiar programming model & tools -- Speaking Points: I suspect most if not all of you in this room are familiar with the Windows Azure today. Today the platform consists of a set of foundational services SQL Azure relational database Windows Azure provides services that can be used by any apps hosted in Windows Azure, on-premises, or hosted in another environment. Questions: How many of you are building applications for Windows Azure? How many are using SQL Azure? How many are using the Access Control service today? The Service Bus? Notes: Windows Azure Story We are building an open platform to run your applications in the cloud. Your apps are .NET, Java, PHP, etc. We love everyone. We are going to help you migrate your existing apps to the cloud. The cloud platform is the future. Enables scale, self-service, lowers friction, etc. We provide the best cloud platform for building new apps. (aka n-tier, web services, etc.) Speaking Points: 3 core services: Compute, Storage, Database Lets take a look at the platform starting with the core services. Compute: Scalable environment for running code Enables .NET, C++, PHP, Ruby, Python, Automated service management Storage: Scalable and highly available cloud storage Blobs, Tables, Queues, Drives REST APIs and several client libraries Database: SQL Relational Database Familiar programming model & tools -- Speaking Points: I suspect most if not all of you in this room are familiar with the Windows Azure today. Today the platform consists of a set of foundational services SQL Azure relational database Windows Azure provides services that can be used by any apps hosted in Windows Azure, on-premises, or hosted in another environment. Questions: How many of you are building applications for Windows Azure? How many are using SQL Azure? How many are using the Access Control service today? The Service Bus? Notes: Windows Azure Story We are building an open platform to run your applications in the cloud. Your apps are .NET, Java, PHP, etc. We love everyone. We are going to help you migrate your existing apps to the cloud. The cloud platform is the future. Enables scale, self-service, lowers friction, etc. We provide the best cloud platform for building new apps. (aka n-tier, web services, etc.)

    23. Windows Azure Storage Scalable storage in the cloud 100tb per storage account Auto-scale to meet massive volume and throughput Accessible via REST services Access from Windows Azure Compute Access from anywhere via internet Supporting .NET Client Library Various storage types Table - group of entities (name/value pairs) Queue - Simple non-transactional message queue Blob - Large binary storage Drives - NTFS VHD mounted into Compute instance Slide Objectives: Introduce Windows Azure Storage and some of the key features/capabilities of the storage service Speaking Points: The design point is for the cloud is availability of storage, there are 3 replicas of data, and we implement guaranteed consistency. In the future there will be some transaction support and this is why we use guaranteed consistency. There are 4 types of storage Tables = Key value store Queues = a simple queuing mechanism Blobs = Binary file storage in the cloud Drives = A mechanism that allows a VHD in a blob to be mounted as an NTFS drive into a Compute role Blobs, tables, and queues hosted in the cloud, close to your computation Authenticated access and triple replication to help keep your data safe Easy access to data with simple REST interfaces, available remotely and from the data center Access is via a storage account you can have multiple storage accounts per live id. Although the native API is REST web service, there is a .NET storage client in the SDK that. This makes working with storage much easier from .NET Slide Objectives: Introduce Windows Azure Storage and some of the key features/capabilities of the storage service Speaking Points: The design point is for the cloud is availability of storage, there are 3 replicas of data, and we implement guaranteed consistency. In the future there will be some transaction support and this is why we use guaranteed consistency. There are 4 types of storage Tables = Key value store Queues = a simple queuing mechanism Blobs = Binary file storage in the cloud Drives = A mechanism that allows a VHD in a blob to be mounted as an NTFS drive into a Compute role Blobs, tables, and queues hosted in the cloud, close to your computation Authenticated access and triple replication to help keep your data safe Easy access to data with simple REST interfaces, available remotely and from the data center Access is via a storage account you can have multiple storage accounts per live id. Although the native API is REST web service, there is a .NET storage client in the SDK that. This makes working with storage much easier from .NET

    24. SQL Azure Database SQL Server relational database model delivered as a service Support for existing APIs & tools Built for the cloud with high availability & fault tolerance Easily provision and manage databases across multiple datacenters SQL Azure provides logical server Gateway server that understands TDS protocol Looks like SQL Server to TDS Client Actual data stored on multiple backend data nodes Slide Objectives: Understand the key differentiators of SQL Azure Understand where a user has control and where the cloud runs things Speaking Points: SQL Azure provides highly available SQL Server. Appears to be a SQL Server to the client. In reality is 3 transitionally consistent copies of the database that are fronted by a Gateway that appears to be a SQL server Simple to provision- create a logical server in the Portal, execute a create DB Command to create a new database Can add and remove DBs easily from application to scale up and down Customers look after logical optimizations like indexes SQL Azure manages the physical database No need to install or patch software or other physical administration Automatic high availability and fault tolerance Simple provisioning and deployment of multiple databases Scale databases up or down based on business needs Multi-tenant Integration with SQL Server and tooling including Visual Studio Support for T-SQL based familiar relational database model Notes http://www.microsoft.com/windowsazure/sqlazure/ http://msdn.microsoft.com/en-us/windowsazure/sqlazure/default.aspx Slide Objectives: Understand the key differentiators of SQL Azure Understand where a user has control and where the cloud runs things Speaking Points: SQL Azure provides highly available SQL Server. Appears to be a SQL Server to the client. In reality is 3 transitionally consistent copies of the database that are fronted by a Gateway that appears to be a SQL server Simple to provision- create a logical server in the Portal, execute a create DB Command to create a new database Can add and remove DBs easily from application to scale up and down Customers look after logical optimizations like indexes SQL Azure manages the physical database No need to install or patch software or other physical administration Automatic high availability and fault tolerance Simple provisioning and deployment of multiple databases Scale databases up or down based on business needs Multi-tenant Integration with SQL Server and tooling including Visual Studio Support for T-SQL based familiar relational database model Notes http://www.microsoft.com/windowsazure/sqlazure/ http://msdn.microsoft.com/en-us/windowsazure/sqlazure/default.aspx

    25. Building Block Services Speaking Points: Building Block Services for developing connected applications You could write code and build any of these services yourselfbut you wouldnt want to Slide Objectives: Define and enumerate the Windows Azure Services Speaking Points: Much in the same way that SQL Services is about extending SQL Server to the cloud, we are also extending key .NET capabilities to the cloud as services. We call this the Windows Azure Services. These services are really key components you would need for building distributed, connected applications. When we talk about connecting to your existing on-premises applications and enabling the composition of hybrid (Cloud + on-premises) applications that is where these services really comes in. There are currently three services: Caching, Service Bus & the Access Control Service Service Bus: The Service Bus is designed to provide a general purpose application bus, available on the internet at internet scale. You can really thin of the Service Bus as being similar to an Enterprise Service Bus that many enterprise organizations have today. However, we believe that when providing a Service Bus as a programmable service on the internet, there are a wider range of scenarios for many more types of organizations. Fundamentally, the .NET Service Bus is about connecting applications across network and application boundaries and making key message exchange patterns such as publish and subscribe messaging very simple. Access Control: The Access Control service is designed to provide rules-driven, claims-based access control for applications. Essentially, this allows you to define authorization rules for your applications using the claims-based approach that we are adopting within many Microsoft products and technologies and that is becoming adopted in the industry. Notes: Windows Azure has the .NET Framework built into it so that you can use those services within your application. But just like your application must be designed to scale out, the services that we have built into Windows over time in .NET also need to be designed and built in a way that can scale out naturally. We want to create services for you, and that's the purpose of these services, creating a pool of resources available to you to take advantage of and do things within your application very simply. So we're including a built-in, scale-out implementation of a service bus. The service bus lets you connect your on-premises systems securely into the cloud, into the Azure environment, while allowing your data and your information to traverse firewalls, solving a problem that is a bane of many application developments. Speaking Points: Building Block Services for developing connected applications You could write code and build any of these services yourselfbut you wouldnt want to Slide Objectives: Define and enumerate the Windows Azure Services Speaking Points: Much in the same way that SQL Services is about extending SQL Server to the cloud, we are also extending key .NET capabilities to the cloud as services. We call this the Windows Azure Services. These services are really key components you would need for building distributed, connected applications. When we talk about connecting to your existing on-premises applications and enabling the composition of hybrid (Cloud + on-premises) applications that is where these services really comes in. There are currently three services: Caching, Service Bus & the Access Control Service Service Bus: The Service Bus is designed to provide a general purpose application bus, available on the internet at internet scale. You can really thin of the Service Bus as being similar to an Enterprise Service Bus that many enterprise organizations have today. However, we believe that when providing a Service Bus as a programmable service on the internet, there are a wider range of scenarios for many more types of organizations. Fundamentally, the .NET Service Bus is about connecting applications across network and application boundaries and making key message exchange patterns such as publish and subscribe messaging very simple. Access Control: The Access Control service is designed to provide rules-driven, claims-based access control for applications. Essentially, this allows you to define authorization rules for your applications using the claims-based approach that we are adopting within many Microsoft products and technologies and that is becoming adopted in the industry. Notes: Windows Azure has the .NET Framework built into it so that you can use those services within your application. But just like your application must be designed to scale out, the services that we have built into Windows over time in .NET also need to be designed and built in a way that can scale out naturally. We want to create services for you, and that's the purpose of these services, creating a pool of resources available to you to take advantage of and do things within your application very simply. So we're including a built-in, scale-out implementation of a service bus. The service bus lets you connect your on-premises systems securely into the cloud, into the Azure environment, while allowing your data and your information to traverse firewalls, solving a problem that is a bane of many application developments.

    26. Data Services

    27. Node.js on Windows Azure Web Role Uses IISNode Worker Role Runs node.exe as role entry point PowerShell Cmdlets Windows Azure SDK for node.js

    28. Visual Studio Not Required Create, run, and publish all from outside of Visual Studio Use command line and editor or IDE of your choice

    29. Installation Single Install using Web Platform Installer Node.js IISNode NPM for Windows Windows Azure Emulators Windows Azure Authoring Components Windows Azure PowerShell for node.js

    30. Node Roles

    31. PowerShell Cmdlets Create Hosted Service Launch Node application in local emulator Set configuration settings Deploy to Windows Azure

    32. Create a Project

    33. Add Web Role

    34. Start Local Emulator

    35. Windows Azure Node SDK Windows Azure Storage Blobs Tables Queues

    36. Blob Storage Examples varazure=require('azure'); varblobClient=azure.createBlobService(); //CreateBlobfromText vartext='thetextofmyblob'; blobClient.createBlockBlobFromText('mycontainer','myblob',text, function(error,blockBlob,response){ //Blobcreated }); //GetBlobText blobClient.getBlobToText('mycontainer','myblob', function(error,text,blockBlob,response){ //Blobtextretrieved }); //DeleteBlob blobClient.deleteBlob('mycontainer','myblob', function(error,isSuccessful,response){ //Containerdeleted });

    37. Table Storage Examples varazure=require('azure'); vartableClient=azure.createTableService(); //InsertEntity varitem=newMyEntity(); item.PartitionKey='part1'; item.RowKey=uuid(); tableClient.insertEntity('mytable',item, function(error,entity,response){ //Entitysaved }); //QueryEntity tableClient.queryEntity('mytable',item.PartitionKey,item.PartitionKey, function(error,successful,response){ //Dosomething }); //DeleteEntity tableClient.deleteEntity('mytable',item, function(error,entity,response){ //Entitydeleted });

    38. Storage Queue Example varazure=require('azure'); varqueueClient=azure.createQueueService(); //EnqueueaMessage queueClient.createMessage('myqueue','mymessagetext', function(error,queueMessageResult,response){ //Dosomething }); //GetMessages queueClient.getMessages('myqueue', function(error,queueMessageResults,response){ //DoSomething });

    39. Task List demo

    40. Summary Node.js Overview IIS Node Node Modules + NPM Node.js + Windows Azure Windows Azure SDK for node.js http://github.com/WindowsAzure

More Related