Node.js is enjoying much popularity and Glenn Block is helping us to bring it on Windows Azure. I have divided this tutorial into the three parts, installing the required SDK, creating Web Applications and then publishing to the Windows Azure portal. The purpose of this tutorial is to help you in setting up an environment and publishing. In further tutorials we will dig deeper. Install Windows Azure SDK for Node.JSTo start with Node.JS on Windows Azure, you need to install Windows Azure SDK for Node.JS. You can Get Windows Azure SDK for Node.JS from here. You need to install it using the Web Installer. You will get the following dialog box to install Windows Azure SDK for Node.JSAfter successful installation, you should get the following confirmation dialog.By this, the SDK has been installed on your machine. Create Node Application To create the Node application, click on Start and then select Windows Azure PowerShell for Node.JS. Run this as administrator.On the command prompt create a Node directory in the C drive as below:After creating the Node directory you need to create a solution. You can create a solution as below:I have created a solution called MyApplication. You can see the files created inside the solution are as below:There are four files created. If you are coming from a Windows Azure background, you must be aware of the other three files than deploymentSettings.json file. The deploymentSettings.json file stores local setting for Windows Azure PowerShell deployment cmdlets. Next you need to add a WebRole to the solution. To add a WebRole, execute the following PowerShell command. If you don't provide any name then by default a WebRole name would be WebRole1. However I am using the name WebRoleForNodeJS.Now if you list files created inside WebRoleForNodeJS, you will find the configuration files and a JS file. The most important file is server.js. This file contains a starter code for Node.JS. You need to add codes in this file. Go ahead and open this file in NotePad. As of now, I am leaving the default code created by the tool.Server.jsvar http = require('http');var port = process.env.port || 1337;http.createServer(function (req, res) {res.writeHead(200, { 'Content-Type': 'text/plain' });res.end('Hello NodeJS from Debugmode\n');}).listen(port);Run Locally on Windows Azure Emulator To run it locally, go ahead and execute the following PS command to start Windows Azure Emulator. You can see it running in the emulator as below:Publish to Windows Azure Portal To publish it to the Windows Azure portal, first you need to specify a Publish Setting. You can specify that as below:You will be redirected to a live login page. Sign in to download the Publish Setting file. After login you should be able to download PublishSetting file. Download the file inside the Node folder you created in previous steps. Next you need to import PublishSetting file as below:After importing the PublishSetting file, you can it publish to the Windows Azure portal as below:In the above command, name is the unique name and location is one of the Windows Azure Data centers. After successfully publish operation , you should able to see Node.js running on Windows Azure portal. This is all that is required to create your first application. In a further article I will discuss much deeper on the subject. I hope this article is useful.Thanks for reading...
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: