Three ways to set up a Ruby stack on Azure

By: Nik Garkusha, May 3, 2013

Microsoft’s announcement of the Windows Azure SDK for Ruby opens up new alternatives and resources for Ruby developers to publish their apps in the cloud. This first version of the SDK (GitHub) supports working with Azure storage & Azure service bus, and deployment in a Linux VM on Azure IaaS.

The 3 options covered below are different ways to set up an Ubuntu Linux stack with Ruby 1.9.3. – running in a Windows Azure VM – on my MacBook Pro:

  1. An “official” PLATFORM IMAGE with Ruby Version Manager (RVM) via Azure Portal
  2. A VMDepot Ruby Stack from BitNami via Azure Portal
  3. A VMDepot Ruby Stack from BitNami via azure-cli command line (OSX)

The major difference in these approaches is the use of the “official” platform image is the supported Ubuntu Server 13.04 image where we’ll install pre-requisite packaged & RVM to end up with Ruby 1.9.3. vs an already pre-configured stack from BitNami available via VMDepot from the Microsoft OpenTech.

1. Ubuntu 13.04 + RVM via Azure Portal

In the Azure portal go to Virtual Machines. Pick NEW –> Virtual Machine –> From Gallery:

image

In the List of OS, pick the Ubuntu Server 13.04

image

As of last week, VM options include using key-based authentication for SSH, which I’ll choose for this install.
Open up terminal and go into the directory where you’d like to store your key & certificate. Then, to create the certificate/key combo:

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

Note the location of the .key, to be used in your SSH sessions to the VM we’re creating. Next, let’s upload the .pem in the following screen back in the Azure portal:
image

The other options include size of the vm, user name to be set up & the VM machine name. Click Next:

image

Here we’re providing the DNS name & choosing the region/affinity group where we’d like the VM to be located. For performance reasons it’s wise to keep the region consistent across your Azure VMs, services, etc. supporting your solution.
image

Shortly you should end up with a VM (in my case, named: “ubuntu13ruby”) that will get provisioned and started with the settings you specified. The only critical thing to note is the SSH port (under your VM –> Edndpoints). You’ll need this for your SSH session.

Back in my MacBook Terminal I’m going to connect to the VM & run a few updates and install git-core & curl:

sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y git-core curl

 

Next I’m choosing to install Ruby Version Manager (RVM) which provides many useful capabilities including sand-boxing multiple versions of Ruby and simplifying the install.

Run RVM installer (note the leading backslash)

\curl -L https://get.rvm.io | bash -s stable
 
 

Make RVM accessible from bash:

echo 'source ~/.rvm/scripts/rvm' >> ~/.bash_aliases && bash

 

Next we’ll use rvm to check any missing dependencies/packages:

rvm requirements

 

Output should contain information similar to this:

Missing required packages: gcc, make, libc6-dev, libreadline6-dev, zlib1g-dev, 
libssl-dev, libyaml-dev, libsqlite3-dev, sqlite3, libxml2-dev, libxslt1-dev,
autoconf, libc6-dev, libgdbm-dev, libncurses5-dev, automake, libtool, bison,
pkg-config, libffi-dev.
 
 

Use the output from rvm requirements to sudo install missing bits. In my case it’s:

sudo apt-get install gcc make libc6-dev libreadline6-dev zlib1g-dev libssl-dev 
libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev
libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev –y

 

For sanity check, run rvm requirements again, to ensure nothing else is missing.
Next let’s install Ruby 1.9.3:

rvm install 1.9.3

You should get output similar to below:

Installing Ruby from source to: /home/azureuser/.rvm/rubies/ruby-1.9.3-p392, this may take a while depending on your cpu(s)...
....
Install of ruby-1.9.3-p392 - #complete

 

Set Ruby 1.9.3 to default:

rvm use 1.9.3 --default

 

Finally, let’s make sure ruby 1.9.3 is installed correctly with :  ruby –v

On the VM installed, I get indication that we’re all set: ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]

 

2. BitNami Ubuntu Ruby stack using VMDepot via Azure Portal

VMDepot from the Microsoft OpenTech provides an amazing collection of various stacks for various apps & purposes to get a VM going very quickly on Azure

From the Azure Portal, choose Virtual Machines –> Images:

image

Click “Browse VM Depot” and filter to Ubuntu images on the left hand side:

image

I’m picking the Ruby Stack 1.9.3-9 from BitNami to be installed, and then specify a storage account where my BitNami image will be copied (and stored) before I can create a VM from it:

image

Because the image is quite large (30 gb) the copy process may take some time; after it completes I can see it under Virtual Machines –> Images. I need to Register it (bottom right of the options bar):

image

Finally, I go to NEW –> Virtual Machine –> From Gallery –> MY IMAGES, where I should see my image:

image

At this point I can create the VM from the BitNami  image, click Next & follow options similar to step 1 above.

 

3. BitNami Ubuntu Ruby stack using VMDepot via command line

An alternative to the Azure portal is using azure-cli command line tools which greatly simplify (and automate) Azure related tasks on any platform.

I’m starting with VM Depot website search for Ruby stack:

image

Once I find the stack I want (in my case Ruby Stack 1.9.3-9 on Ubuntu), I click “Deployment Script” and get the commands I need for azure-cli on my client machine:

image

On my MacBook, I need to have azure-cli installed (and my .profile imported), after which I can create the VM & enable the endpoints for HTTP/HTTPS (SSH is enabled on default port with the –ssh option) :

azure vm create bitnamiub13ruby -o vmdepot-323-1-1 -l "West US" azureuser <MyPassword> –ssh
azure vm endpoint create-multiple bitnamiub13ruby 80:80,443:443

 

At this point I should be able to SSH to my newly created Ruby-ready at bitnamiub13ruby.cloudapp.net with the user: azureuser & password specified. For sanity check I can see my VMs by using:

azure vm list 

Using either one of these 3 approaches I should have a Ruby stack on a Ubuntu VM running in Windows Azure, ready for development!

In a follow-on to this post I’m teaming up with Marc Gagné to explore Azure SDK for Ruby in a sample app running in one of my VMs.

Tagged with: , , , , , , , , , ,
Posted in Geek Speak, Training & Webcasts

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Avatar of Nik Garkusha

Nik Garkusha

What people are saying about #webnotwar

@CCEChirps @andrewmcampbell sorry I'm in transit to Mtl to make more #webnotwar Heard you have @richardpietro calling in! Gonna be amazing

.@richardpietro @ignumerique Special thanks to our city champion for making the #ogt14 event possible in QC!

And the #OGT14 #opengov conversation continues! Off to @SFLinux QC office to meet @leontalbot #WebNotWar

Thank you to our friends from France who stayed past 1:30am local for the Skype call #OGT14 All in the name of #opengov @OpenGovFr

Great to see an engaged #opengov community in Quebec City! #OGT14 #webnotwar

Where/how progress happens... @brucechau @ignumerique & Moussa Sarr making #WebNotWar before the Quebec city #OGT14 pic.twitter.com/rjBvi8qppN

Retweeted by #WeAreOpen

Get caught up on Open Government in Canada via the #OGT14! webnotwar.ca/ogt14/ Let's Make #WebNotWar together Retweeted by #WeAreOpen

Where/how progress happens... @brucechau @ignumerique & Moussa Sarr making #WebNotWar before the Quebec city #OGT14 pic.twitter.com/rjBvi8qppN

Retweeted by brucechau

Where/how progress happens... @brucechau @ignumerique & Moussa Sarr making #WebNotWar before the Quebec city #OGT14 pic.twitter.com/rjBvi8qppN

Retweeted by Jean-F Gauthier

Get caught up on Open Government in Canada via the #OGT14! webnotwar.ca/ogt14/ Let's Make #WebNotWar together Retweeted by Ashleigh Weeden

Get caught up on Open Government in Canada via the #OGT14! webnotwar.ca/ogt14/ Let's Make #WebNotWar together

Where/how progress happens... @brucechau @ignumerique & Moussa Sarr making #WebNotWar before the Quebec city #OGT14 pic.twitter.com/rjBvi8qppN

Ne manquez pas la webdiffision de l'évènement de Québec du tour du gouvernement ouvert de Richard Pietro: eventbrite.ca/e/tour-du-gouv… #OGT14

<3 we love making #webnotwar with you. Truly a privilege and a pleasure ^KL @richardpietro: .@6t6qt @brucechau @microsoftcanada @WebNotWar