Christian HagerSoftware Engineer // Technical Director // Photographer

Deploying RAP to Windows Azure

Since I recently deployed my first application to Microsoft’s Cloud Services-Platform Windows Azure I wanted to share the steps taken to get the application up and running. As I promised in the title of my post my sample application will be an Eclipse RAP application (to keep things simple I will use the RAP Mail template).

Prerequisites

Before we can start we need to install some things first. Here is what we need to get started:

Installing IIS and ASP.NET [1]

Creating the RAP application

At this point we have to create the RAP application we want to deploy. To keep things simple this tutorial will use the RAP Mail template but any other RAP application should be fine as well. Since it is not in the focus of this post I will assume that you already know how to create a RAP application.
Packaging the application
Now that we have a running application we can go ahead and package it into a war archive. The Eclipse Indigo Help explains how to do that (http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.rap.help%2Fhelp%2Fhtml%2Fadvanced%2Fdeployment.html).
Deploying to Windows Azure
With our RAP application packaged into a war archive we can now go ahead and create a package for deployment to Windows Azure. The following steps are necessary to create this package.First of all we have to create a new Windows Azure Project via File –> New –> Project…. We name the new project MyAzureApp or whatever name you prefer and leave the rest of the values on their defaults.

After finishing the wizard the project will be created. At this point we should have a fresh Windows Azure Project which should look like this.

Now we can start modifying the project. First we have to add the following files to the folder /MyAzureProject/WorkerRole1/approot
  • A zipped version of the JRE (Since there is no zipped version of the JRE available for download I zipped C:\Program Files\Java\jre6)
  • A zipped version of tomcat (It is also possible to use other servers such as Jetty)
  • The WAR-archive we created earlier

Next we have to edit the file /MyAzureProject/WorkerRole1/approot/util/startup.cmd to contain the following lines:

@REM unzips the Tomcat Server
cscript /B /Nologo util\unzip.vbs apache-tomcat-7.0.22-windows-x64.zip "%ROLEROOT%\approot"

@REM unzips the JRE
cscript /B /Nologo util\unzip.vbs jre6.zip "%ROLEROOT%\approot"

@REM copies the war-archive to the server
md "%ROLEROOT%\approot\apache-tomcat-7.0.6\webapps\myapp"
copy rapmail.war "%ROLEROOT%\approot\apache-tomcat-7.0.22\webapps"

@REM starts the server
cd "%ROLEROOT%\approot\apache-tomcat-7.0.22\bin"
set JRE_HOME=%ROLEROOT%\approot\jre6
startup.bat

At this point we have to configure a public endpoint for the tomcat server to listen on. To do so we have to open the project properties of the azure project and navigate to Windows Azure –> Roles and edit WorkerRole1.

In the next dialog we have to add a new endpoint.
Now we assign a name, a public and a private port to the endpoint. The type of the endpoint should be left as input.

Testing in the emulator

To test our application in the Windows Azure emulator we first have to make sure that we build for the emulator. To do so we have to set Build For: Testing in emulator in the project settings of the azure project.

Now we can build the project by running the provided ant script package.xml. After a successful build we can use the scripts in the folder emulatorTools start the emulator and deploy the project.

If deployment was successful the Rap-Mail-Sample should be available via http://localhost:8080/rapmail/mail?startup=RapMail.mailapp

Deploying to the cloud

To build the project for deployment to the cloud we have change the project settings to Build For: Deployment to cloud.

Now we can build the project again using the ant script. If the build was successful there should be two new files in the deploy folder of the azure project:
  • WindowsAzurePackage.cspkg
  • ServiceConfiguration.cscfg

 

Using those two files the RAP Mail template can be deployed to Windows Azure.
Note: Make sure to stop the emulator before building for cloud deployment or otherwise the build will fail because the deploy folder is still locked by the application running in the emulator.

Tags: , ,

Leave a Reply

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