Running a node.js application on a Microsoft Azure VM

Node.js is a server JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.

There's no shortage of Node.js tutorials on the web, but most of them cover specific use cases that only apply when you've already got Node up and running.

Here is a small summary of my first trial to run a Node.js web server on a virtualized Windows Server hosted on Microsoft Azure.

Step 1: Create a Virtual Machine on Windows Azure

Sign in to the Azure Management Portal. You can register for free and receive 170 EUR to evaluate the platform during a month.

On the Hub menu, click New > Compute > Windows Server 2012 R2 Datacenter.

After you select the image, you can use Azure's default settings for most of the configuration and quickly create the virtual machine.

On the Create virtual machine blade, click Basics. Enter a Name you want for the virtual machine, the administrative User name, and a strong Password.

Click Size and select an appropriate virtual machine size for your needs. Each size specifies the number of compute cores, memory, and other features, such as support for Premium Storage, which will affect the price.

Click Summary to review your configuration choices. When you're done reviewing or updating the settings, click Create.

While Azure creates the virtual machine, you can track the progress in Notifications, in the Hub menu. After Azure creates the virtual machine, you'll see it on your Startboard unless you cleared Pin to Startboard in the Create virtual machine blade.

Once the VM is created, select it and click on Connect to start a new RDP session.

Step 2: Install Node.js

Download the Windows installer from the Nodes.js web site.

Run the installer (the .msi file you downloaded in the previous step.)


Follow the prompts in the installer (Accept the license agreement, click the NEXT button a bunch of times and accept the default installation settings).

Step 3: Create a test application

Create a new directory for your first application. This is a very basic HTTP server returning a string when you send an HTTP request. Nothing more.

Create a new sample1.js file using your favorite text editor.

Type the following code:


Step 4: Start you server

Open a new command prompt.

Navigate to the folder containing your sample1.js file

Type the following command:



PS: If you receive a warning from Windows Firewall, accept it.

Step 5: Configure your Virtual Machines endpoints

All virtual machines that you create in Azure can automatically communicate using a private network channel with other virtual machines in the same cloud service or virtual network. However, computers on the Internet or other virtual networks require endpoints to direct the inbound network traffic to a virtual machine.

When you create a virtual machine in the Azure portal, endpoints for Remote Desktop, Windows PowerShell Remoting, and Secure Shell (SSH) are automatically created. You can configure additional endpoints while creating the virtual machine or afterwards as needed.

In our sample application, we are listening to all incoming HTTP requests on port 1337. The default port for HTTP is 80. Therefore, I will create a HTTP endpoint using the public port 80 and redirecting the data to the private port 1337.

Select your VM, then click on Settings

Click on Endpoints

Click on + to add a new HTTP endpoint

Name and configure your end point with the above settings

Step 6: Test your application

Open a web browser and type the address of your web server: