Node JS on Windows Azure

Posted: June 8, 2012 in Uncategorized

One of the latest things people have heard about is Node JS, actually when you develop on any cloud platform available, you will certainly hear about it and you may think of using it. So first of all what is Node JS and what can it do more to help you building your application? We all know that JS stands for JavaScript and for the Node, it means the server side. Yes JavaScript on the server side. The Node JS main target is to help you build very high scalable applications over the network… bla bla bla. How is that?

Let’s imagine that you get a number of X of requests on your web application, each one of these requests consume a certain amount of memory, so your hardware resources will only be able to handle the number of memory divided by X, which is somehow limited and costs a lot. (I got this example from this link from ibm developers works). Node JS allows you to execute the coming request with more parallelism using the JavaScript
Event-Driven programming language. In this post we will talk about the same thing but for the server side.

Node is a server-side JS interpreter, it changes all how the server works processing and working with the coming request. Node.JS is a based on V8 JavaScript engine, ultra-fast engine, you can download it, read its documentation and embedded into any of your application from this link.

Now let’s go into the example, first of all after the new features added for Windows Azure for June 2012, we will need to sign in to the portal, create new website and setting its URL and its GIT, you can download and install the Node.JS tools and GIT from these 2 links. Let’s start by opening the Windows Azure PowerShell, and don’t forget to run it as administrator. The coming few instructions will help you building your web application, just write the written commands in your PowerShell Command lines.

After creating the directory, you can now create the windows azure application. But first don’t forget to change directory to the directory created.

 

If you opened the directory you made and where you created the azure service, you will find the following:

So let’s create the new WebRole for our application.

If you didn’t name the WebRole it will be named webrole1. You can also see the folder created and the files added just by navigating to the browser, you must see the following in the folder named mywebrole.

You can open, modify the server.js by simply entering the following command, you will be able to see the server.js in the notepad as the following picture shows.

 

Let’s run and see our application result

The result should be like the following picture:

To modify the application or add new pages you can add new JavaScript or modify the server.js already created.

Now let’s upload to our azure accounts, supposing you have download the Git, created a new website and set the Git Publishing credentials. To do so, after creating a website application on the Windows Azure Portal you will find a link called set Git Publishing on the right most of the window, after clicking on this link:

Now depending on what you have chosen during the installation, I mean I have chosen the Git Bash, you may have gave it the permission so you can access it through the PowerShell. In both ways, you will choose the same commands.

Make sure you are in the right directory and start initializing GIT by the following commands

Now continue and enter the following command to make the connection and the deployment of the application to the portal.

You can get this URL from your portal from:

The last command line is

Now if you simply go to the link of your application you will find the hello world we create J

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s