Avkash Chauhan's Blog

Windows Azure, Windows 8, Cloud Computing, Big Data and Hadoop: All together at one place.. One problem, One solution at One time...

Using ProgramEntryPoint element in Service Definition to use custom application as role entry point using Windows Azure SDK 1.5

Using ProgramEntryPoint element in Service Definition to use custom application as role entry point using Windows Azure SDK 1.5

Rate This
  • Comments 1

Part 1: Basics of running Nodes.js from command line:

You can download node.exe from the link below:

Now lets create app.js as below:

var http = require('http');

http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write('<h1>Welcome. This is node.js page in Windows Azure</h1><br><br>');
res.write('<h2>Visit <a href="http://www.microsoft.com/windowsazure/">Windows Azure</a></h2>');
res.end();
}).listen(8080);

Now launch nodejs server application as below:

  • C:\node-v0.4.12\bin>node app.js

After that you can open http://localhost:8080/  url with your browser to verify it NodeJS server is running:

Part 2: Using nodes.js in Windows Azure 

Now you can use the steps below to use nodes.js with Windows Azure:

  1. Create Windows Azure application with one Worker role
  2. Now you can include all of your nodes related files
    1. In this example you can just include node.exe and app.js (which you used above in Part 1)
  3. After that your can delete app.config and workerRole.cs as we are going to use ProgramEntryPoint elements released with Windows Azure SDK 1.5. Edit the following highlighted text in your Service Definition to run node.exe as worker role entry point application:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureNodeJs15" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WorkerRole name="NodeJsWorkerRole" vmsize="Small">
<Runtime executionContext="limited">
<EntryPoint>
<ProgramEntryPoint commandLine="node.exe app.js" setReadyOnProcessStart="true" />
</EntryPoint>
</Runtime>
<Endpoints>
<InputEndpoint name="NodeJS" protocol="tcp" port="80" />
</Endpoints>
</WorkerRole>
</ServiceDefinition>

Now you can just package your application and then deploy it to Windows Azure. 

Many thanks to Nathan for his insight in his blog: http://ntotten.com/2011/08/nodejs-on-windows-azure/

Leave a Comment
  • Please add 7 and 1 and type the answer here:
  • Post
  • I like reading your blog because It gives me good information. I am new to Node.JS and want to know how I can take advantage of learning Node.JS with Cloud computing.

Page 1 of 1 (1 items)