April 15, 2015 · Engineering NodeJS

Setup MongoDB in Node.js Azure VM with attached Data Disk as DB storage.

To set up Node.js on Azure VM ckeckout the blog Create Azure Virtual Machine and Setup Node.js. So now moving forward, lets start with attaching a Data Disk to your previously set up Azure Virtual Machine.

Attach a Data Disk to Azure Virtual Machine :

1. In the left navigational bar select VIRTUAL MACHINES in Management Portal.

Now at bottom-left corner select +New.

2. For basic needs select QUICK CREATE.

  1. Give a name to your VM in the DNS NAME.
  2. Select Ubuntu Server image(14.04 LTS will be ideal).
  3. Based on your performance needs, select the SIZE of VM.
  4. Azure by default, creates USER NAME as azureuser.
  5. Next is PASSWORD (No need to describe what has to be done here).
  6. Last but quite important is REGION/AFFINITY GROUP. If you have created any Affinity Group and want your VM to be in that Group select it or select the region based on your location.
  7. As soon as you click Create A Virtual Machine Azure will create it in few moments.

If you are planning to create a cluster of VM with better latency between them, then first create a Virtual Network and later while creating VMs use FROM GALLERY and add the VN you want to use in REGION/AFFINITY GROUP/VIRTUAL NETWORK option. You can give desirable name to VM in FROM GALLERY mode.

Access your Virtual Machine :

For users operating from Windows OS preferred SSH client is PuTTY.
Whereas users operating from Linux OS might want to use SSH client such as OpenSSH.

Get your Host Name and Port information from the Management Portal. You can get all the information about your VM from the dashboard of the virtual machine. Click the virtual machine name and find your SSH Details.

Command to connect from Linux after having installed OpenSSH.

# ssh user_name@DNS_NAME

Where DNS_NAME is your host-name.cloudapp.net . Then enter your password. (Well now that you are on your VM feel free to play around it like any other Ubuntu Machine).

Azure by default opens port 22 for ssh and you can configure rest as per your need in ENDPOINTS in Management Portal.

Set up Node.js:

Node.js is built up on a Javascript runtime platform for building fast network applications. You can design network applications with both the front-end and the back-end utilizing Javascript within the same system providing more consistency. To get Node.js in your machine use the apt package manager.

sudo apt-get update
sudo apt-get install nodejs

Well to move on you will also want to install npm that is node.js package manager.

sudo apt-get install npm

This will enable you to easily install and manage the modules and packages to use with Node.js.

In Ubuntu the executable is called nodejs instead of node because of conflict with another package node.

To get the Node.js version of your choice you can also install it through PPA (personal package archive) of perhaps NVM (Node.js version manager) for more flexibility.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket
-