« Using DebugView to Troubleshoot Windows Azure Deployments | Main | Configuring Tomcat Logging »

May 15, 2011

Running Java and Tomcat on Windows Azure VM Role

Just for an exercise I decided to see what is the experience for Java developers who would like to use Windows Azure as a cloud platform. Of course the easiest way to do this is to use the IaaS feature of Windows Azure – the VM Role.

Now, let’s go through the steps of preparing the VHD and deploying it to the cloud.


Preparing VM Role VHD with Java and Tomcat

In this particular case I used Hyper-V Manager on Windows Server 2008 R2 to prepare the VHD (for more details on VM Role you may refer to my previous post How to Deploy Windows Azure VM Role). As you may know at the time of this writing the only supported OS for VM Role is Windows Server 2008 R2. Here are the simple steps I went through:

  1. Started Hyper-V Manager on the local machine (running Windows Server 2008 R2 of courseSmile) and created new Virtual Machine

  2. Selected memory size

  3. Next was the Networking interface

  4. And finally the Virtual Disk (VHD)

    It is important to note that Windows Azure has limits on the Virtual Disk (VHD) size that you can mount in the cloud. Depending on how big your VM Role is (Extra Small, Small or Medium and above) you can mount different VHD sizes. For details look at the MSDN documentation for How to Create the Base VHD for a VM Role in Windows Azure. Oh, and yes, the screenshot is wrong Smile
  5. And I selected to install the operating system from the local DVD drive


Here the summary for my VM:



Configuring the Virtual Machine for Windows Azure

As mentioned in my previous post How to Deploy Windows Azure VM Role in order to run the VM in the cloud I have to install the Windows Azure VM Role Integration Components but before that I had to enable .Net 3.5 Framework.



As you can see from the screenshot above I selected the top node for .Net Framework 3.5.1 Features however this introduced some problems. It seems that WCF Activation feature occupies port 80 and I wasn’t able to run Tomcat on the default port. You don’t need WCF Activation in order to install and run the VM Role Integration Components so you don’t need to install it. Alternatively you can install the IIS Management Console and change the bindings for WCF to a different port (see How to change the TCP port for IIS service for details).


Installing Java and Tomcat on the Virtual Machine

Once I had the main operating system and Windows Azure Integration Components installed I had to install Java and Tomcat on the Virtual Machine. I decided to go with very simple configuration using Oracle’s JVM and Tomcat and downloaded the 32-bit/64-bit Windows Service Installer from Apache Tomcat’s web site. The reason I went with service installation was that I wanted Tomcat to start automatically when my instance is started.

Of course I changed the port for Tomcat from 8080 to 80 during the installation process.




Now that you have everything installed on your local Virtual Machine you can follow the instructions in How to Deploy Windows Azure VM Role to create a package and deploy the VHD to Windows Azure.


Some Tips

If I had more time to play with it I would have separated the base OS from the additional components (Java and Tomcat) in two different VHDs:

  • Base Image will contain the OS only + the Windows Azure VM Role Integration Components
  • Differencing Disk will contain the Java installation and the Tomcat installation

You can upload both the Base and Diff VHDs to Windows Azure and link them so that they are considered as one when your instance is started.


Feed You can follow this conversation by subscribing to the comment feed for this post.

Post a comment

Comments are moderated, and will not appear on this weblog until the author has approved them.

If you have a TypeKey or TypePad account, please Sign In