Full Startup task based Tomcat/Java Worker Role Application for Windows Azure

This Windows Azure Tomcat Solution is designed in a way that you can update your Tomcat project outside VS2010 project. The VS2010 application will be deployed once however whenever you would need to update, Tomcat, Java Run time or your own Tomcat based solution, you can update without updating your Windows Azure application. This project is based on Startup task in which Tomcat, Java and your project is downloaded from Azure Storage and then installed in Azure VM. Full source code is available for startup task and solution. 

Download Source code : http://tomcatazure.codeplex.com/

Step 1: Preparation for the files to be download from Azure Storage:

Java Run Time: 

- Download Java Run Time from Java web site and the zip the runtime from the installed location.  

- The JRE zip file should have a root folder as "jre7"

Tomcat Installation Package:

- Please download desired Tomcat installation zip file from http://tomcat.apache.org/download-70.cgi

- Please unzip the ZIP file to a location in your machine and edit \conf\server.xml as below: (MUST)

       <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />

Your Tomcat application project

- In most of the cases your Tomcat application will be inside "webapp"s folder in a folder itself. Please package your whole application into a ZIP file.

The above 3 zip files should have the root folder as below:


Step 2: Uploading all the files to Windows Azure Storage

Once you upload all 3 files (or more) to Windows Azure Storage your Windows Azure Storage container will look like as below:


Step 3: Opening Windows Azure Tomcat Solution in VS2010.

After you open Windows Azure Solution in Visual Studio 2010, the solution will look like as below:


Edit startup\startup.bat to have correct Windows Azure Storage credentials:


@REM Setting up Azure Stroage Credentials
set azurestoragename=*********azure_storage_name**************** set azurestoragekey=**********azure_storage_key***************** set storagecontainername=*****azure_storage_container_name******

@REM Download Tomcat ZIP
set filename=apache-tomcat-7.0.19-windows-x64.zip
startup\packagedownloader.exe "%azurestoragename%" "%azurestoragekey%" "%storagecontainername%" "%filename%"

@REM Download JRE Runtime ZIP
set filename=jre7.zip
startup\packagedownloader.exe "%azurestoragename%" "%azurestoragekey%" "%storagecontainername%" "%filename%"

@REM Download Tomcat/Java Applicaiton ZIP
set filename=myproject.zip
startup\packagedownloader.exe "%azurestoragename%" "%azurestoragekey%" "%storagecontainername%" "%filename%"

@REM unzip Tomcat
cscript //B //Nologo startup\unzip.vbs apache-tomcat-7.0.19-windows-x64.zip "%ROLEROOT%\approot"

@REM unzip JRE
cscript //B //Nologo startup\unzip.vbs jre7.zip "%ROLEROOT%\approot\apache-tomcat-7.0.19"

@REM unzip project files to tomcatServer\webapps folder
md "%ROLEROOT%\approot\apache-tomcat-7.0.19\webapps"
cscript //B //Nologo startup\unzip.vbs myproject.zip "%ROLEROOT%\approot\apache-tomcat-7.0.19\webapps"

set JRE_HOME=%ROLEROOT%\approot\apache-tomcat-7.0.19\jre7
set CATALINA_HOME=%ROLEROOT%\approot\apache-tomcat-7.0.19

@REM Edit Server.xml
@REM cd "%ROLEROOT%\approot\apache-tomcat-7.0.19\conf"
@REM copy server.xml server.orig.xml
@REM cscript //nologo startup\editserverxml.vbs server.xml 80

@REM start the server
cd "%ROLEROOT%\approot\apache-tomcat-7.0.19\bin"
copy startup.bat startup.back
set > %RoleRoot%\approot\env.txt
startup.bat > %RoleRoot%\approot\tomcat.txt
exit /b 0

The provided solution already have port 80 based TCP endpoint defined. IF you would need to add HTTPS endpont please look the "Adding SSL to Tomcat Solution" documentation section. 


Step 4: Adding RDP access to application and packaging for deployment

It is good to add RDP access to your application when you are ready to publish the application, add RDP access as well. If you dont know how to do, please follow link below:


Now just deploy your application to Windows Azure. 


Step 5:  Verifying that Zip files are downloaded from Windows Azure Blob storage

After your VM will start and download your zip file the download completion log will be available on Azure Storage as below


Step 6: Running Tomcat Application

After some time your worker role will be ready as below:

Download Source code : http://tomcatazure.codeplex.com/

Comments (4)

  1. rogerj says:


    I wasn't able to find a link to the source code you mentioned at the start of your post.


    Roger Jennings

    OakLeaf Blog: oakleafblog.blogspot.com

  2. aha… missed the important info… updated…


    Thank you so much!!

  3. Ole H. Oftedal says:

    Hi Avkash!

    This looks really interesting!

    Any chance you can relink the pictures. I only see red X's.


    Ole H. Oftedal

    Timeflex Systemer AS



  4. Yury says:

    Avkash, how to install SSL on my Azure VM where I use Tomcat7 and do not use VS att all? Is it possible?

Skip to main content