Tag Archives: Node

Hack Tools #1: node.js on Azure with Linux VM

So you want to hack on node.js and you want a simple way to get up and running with minimum fuss. In this first of two node.js hack tools I want to show you how to spin up a node.js server running mongodb in a minimum amount of time. Assuming you have an Azure account, you can get started right now. Otherwise head over to http://azure.microsoft.com/en-us/pricing/free-trial/ and get started with your free trial.

Step 1: Sign in to the Azure Management Portal

Head over to http://portal.azure.com and sign in.


Step 2: Provision a Unbuntu Linux Server

Now, you can start to provision a Linux server. Start by clicking on the new button in the lower left corner.


Next choose “Compute” and then “Ubuntu Server 14”


Now you can start filling in the information about your Virtual Machine. First, you will need a unique host name for your machine. Next, you will assign a user name for you to login and begin working with your box. Next, you can specify a password, or use an SSH Public Key from ssh-keygen to use for authentication. Next, choose a pricing tier for the virtual machine that makes sense for the workload you are going to expect for this machine. Finally, verify the optional configuration, subscription and VM location. You are now ready to click the “Create” button to initiate the creation of your Linux VM.

Step 4: Open the endpoint in the Azure firewall for node server

Once the VM is configured and running, we need to open the firewall for the HTTP port so that the server can respond to requests. If you checked the “Add to Startboard” on the “Create VM” blade, you VM should show up on the home page of the preview portal. If not, you can find your VM by clicking Browse and navigating to the VMs.


In the VM blade, click on the “Settings” gear. This should bring the Settings blade out to the right. Next, click the Endpoints to show the configured endpoints blade. Notice that port 22 was created for us as part of the original configuration for our SSH port to connect for a secure shell (which will be used in a minute).

Click the “Add” button on the Endpoints blade to add a TCP port for port 80. Set the name to HTTP and the protocol to TCP with the public and private port values set to 80. Don’t worry about any access control on this port at this time.


Step 3: Install other software…nodejs and git

Once your VM is running, the next step is to connect to your VM in order to install the final pieces. You can easily find a putty tool at http://www.putty.org or you can follow a walkthrough at this MSDN blog. We’ll use “Putty” to get a client shell connection and install node.


Using  “yourhostname.cloudapp.net” and connecting to port 22 should give you a connection to your running VM. Enter the correct authentication credentials, and you should be logged in and ready to go.

First, be sure that everything on your new VM is up-to-date.

Next, point to nodesource and install nodejs:

Finally, install git so that you can deploy our code.

Step 5: Verify node installation

To verify that node is indeed installed and ready to go, you can run:

This should return the currently running version of node.

Step 6: Build and Deploy your code

You can now follow the normal procedures of cloning your repository to this newly set up server and you should be set to go. If you are just following along and want a repository to clone, you can grab a sample here:

Next, we need to ensure that the dependencies are installed. We will use the sample site for the rest of this step.

Finally, kick of the nodejs server with the following:

Now navigate to your new server and you should see your running web application.


Next Hack Tool

In the next Hack Tool we will be using the Azure Websites feature to deploy this same website…without the VM.