Hello World! Windows Azure Spring Release is Here! (IaaS, Media Services, Web Sites…) – Part 2 Linux VMs

 

In the previous post we had saw the extremely easy process to create Windows VMs using the new Windows Azure Virtual Machines feature, but, the new IaaS features in Windows Azure are planned to be a complete cloud solution and as part of the new features now we can create Windows VMs and Linux VMs (yes, Linux VMs).

Are you ready to create a new Linux VM? Yes, ok let’s go:

Go to you Windows Azure Management Portal and sign in.

Click on Manage and enter in your new Windows Azure control panel. Go to Virtual Machines and there you can create new Virtual Machines, add new images or disks.

Click on Create a Virtual Machine.

image

You can create a new VM instance using the Quick Create menu or you can select From Gallery to browse the gallery of predefined images or your own images.

Click on From Gallery.

image
Select the Ubuntu Server 12.04 LTS image and click next. image
Procced with the VM Configuration. Important: If you want use certificates to authenticate the SSH connection, you need upload the SSH key.   To do that follow the next steps: image

To generate the SSH Certificate:

  1. Download and install GitHub for Windows from the following location: https://windows.github.com/
  2. Run Git Shell from the Start Menu > All Programs > GitHub, Inc (you use any other program to generate x.509 certificates)

openssl.exe req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out myCert.pem

Answer the questions that are asked. It would have created two files: myPrivateKey.key and myCert.pem. keep save this two files.
image
Ok, so go back to the Create Virtual Machine window and check the “Upload SSH key for authentication” option, select the myCert.pem file and click on next. image
Configure the VM Mode options and click on next. image
Specify if you want include this VM in an Availability Set (not in this case), and click on OK. image
Wait a few minutes and when the VM is ready it’s all yours image

OK, now we can connect to our Linux VM using SSH, the SSH port 22 is configured in the Endpoints of the VM, so we only need configure a SSH client to connecto to the VM. As we upload a SSH key to the VM during the VM creation, we can use certificates to authenticate the SSH connection, you can use a client as PuTTY to connecto to your VM as follow:

  

Create a PPK for Putty - Download and install puttygen from the following location: https://www.chiark.greenend.org.uk/~sgtatham/putty/download.html - Run puttygen.exe - Click the menu: File > Load a Private Key - Find your private key, which we named myPrivateKey.key. You will need to change the file filter to show All Files (*.*) - Click Open. You will receive a prompt which should look like this: - Click OK. - Click Save Private Key - Save the file as a PPK. linuxgoodforeignkey
- Run PuTTY. - Fill in the host name using the IP from the Management Portal. linuxputtyconfig
- Before selecting Open, click the Connection > SSH > Auth tab to choose your key (PPK file). See the screenshot below for the field to fill in. linuxputtyprivatekey
- Click Open to connect to your virtual machine. - Log on with the user created with the Manager, and the passphrase of the certificate: image
   

Now as in our previuos post, we can use our VM for whatever we want, for example to install a Wordpress server :) From your SSH terminal execute:

sudo apt-get install tasksel
sudo tasksel install lamp-server

sudo apt-get install wordpress php5-gd

sudo ln -s /usr/share/wordpress /var/www/wordpress
sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost

From the Windows Azure Manager add a new Endpoint for your VM to the port 80 (as in the previous post) in your VM and now you can start to use it opening the URL https://[yourserver].cloudapp.net/wordpress. Configure it and here is your Wordpress server:

image