Published: 22 Feb 2012
By: Janani K

In this article we will see the steps involved in deploying the WAR created in the first part of this series to the compute emulator and to windows azure platform first in staging environment and later promote it to production. We will also have a look at different options available in Windows Azure management portal to deploy and maintain the deployed application.

Contents [hide]

Introduction

In Part I of this series we had seen the steps to install Windows Azure plugin for eclipse and we created a simple HelloWorld java project. We also create an Azure project using the installed plugin and made the WAR file ready for deployment.

In this article we will see the steps involved in deploying the WAR created to the compute emulator and to windows azure platform first in staging environment and later promote it to production. We will also have a look at different options available in Windows Azure management portal to deploy and maintain the deployed application.

Steps

In the last article, we saw how to export HelloWorld.war to the azure project. Now we will see how to build the azure project that we created.

For this we should copy over zips of your JDK and server to the approot folder. The file structure within the zip file impacts how the startup.cmd script is going to be used. If the zip files are created as mentioned below then no change will be needed in startup.cmd

File structure within the JDK zip:

JDK zip should contain a root folder named jdk and inside this folder will be your binaries, libraries, etc.

File Structure within the Server zip:

Application Server zip should contain server name with version as the root folder which will in turn contain rest of the binaries for the application server.

Copy both the zip files and paste it under HelloWorldAzureProject /WorkerRole1/approot in the project explorer. Your Azure project should now look as shown in the screen below.

Next, we need to customize our start up script. Under Samples folder in HelloWorldAzureProject you can see sample start up scripts for various application servers. Since we used tomcat for the purpose of this tutorial, copy the contents of startupApacheTomcat7.txt and paste it in the startup.cmd under HelloWorldAzureProject /WorkerRole1/approot/startup.cmd.

If you are using a different server name other than the value specified in SET SERVER_DIR_NAME=apache-tomcat-7.0.22, change the value appropriately.

Also ensure the zip files matches with the names specified in the following lines of the start-up script.

Save the start-up script after changes, if any.

Select HelloWorldAzureProject from the project explorer. Click on Project -> Build Project as shown in the screen below.

Ensure the build is successful from the Console window in Eclipse as shown in the screen below.

Steps to deploy application to the compute emulator

In the project explorer in eclipse, expand HelloWorldAzureProject and expand emulatorTools. Double click on RunInEmulator.cmd. This will deploy your application to the compute emulator. You will be prompted to allow this command to make changes to your computer. Click on Yes.

Examine your compute emulator UI for any issues in the project. If your project does not have any issues then the emulator UI looks as shown in the screen below.

Start your browser and use the URL http://localhost:8080/HelloWorld. You should see the output as shown in the screen below.

You can stop your application from running by either using the menu options in the compute emulator UI or by running RunInEmulator.cmd from eclipse under emulatorTools in HelloWorldAzureProject.

Steps to deploy application to Windows Azure

To prepare your application for deployment to the cloud, from the project explorer in eclipse, right click on HelloWorldAzureProject and click Properties as shown in the screen below.

In the Properties dialog that appears, select Windows Azure from the left pane, select Deployment to Cloud in the Build For drop down and click on OK as shown in the screen below.

For the purpose of this tutorial we will turn off Remote access for the Windows Azure project. To do this, expand Windows Azure in the Project Properties dialog and click Remote Access. In the Remote access dialog that appears, uncheck the Enable all roles to accept Remote Desktop connections with these login credentials and click on OK as shown in the screen below.

Click on Project -> Build All in eclipse and ensure the build runs successfully.

In the Project Explorer, expand HelloWorldAzureProject and expand Deploy. You will see three files under deploy. ServiceConfiguration.cscfg and WindowsAzurePackage.cspkg are the files that needs to be uploaded in the Windows Azure Management Portal. WindowsAzurePortal.url is the shortcut to the Windows Azure Management Portal.

Double click on WindowsAzurePortal.url. This will open up the Windows Azure Management Portal.

Log in to the Windows Azure Management Portal and click on Hosted Services, Storage Accounts & CDN tab as shown in the screen below.

Click New Hosted Service button at the top left corner as shown in the screen below.

Create a New Hosted Service pop up appears.

Select the subscription to be used for this service and enter a name for this service. This name is used to distinguish your services within this portal for the specified subscription.

Enter the URL for this service. The portal ensures that this URL is unique within the Azure platform and that it is not in use by anyone else's service.

Select Region from the dropdown available, say for example Anywhere Asia.

Select Deploy to stage environment in the deployment options. Also ensure Start after successful deployment is checked.

Specify a deployment name.

Click on Browse Locally next to Package location text box and navigate to <your project location>\HelloWorldAzureProject\deploy\ and select WindowsAzurePackage.cspkg.

Click on Browse Locally next to Configuration file text box and navigate to <your project location>\HelloWorldAzureProject\deploy\ and select ServiceConfiguration.cscfg.

With all these details entered in the Create New Hosted Service pop up, the screen looks as shown below.

You will receive a warning since there is only one worker role defined. For the purpose of this tutorial we will ignore this warning. So, click on Yes.

The status of the deployment can be verified under Hosted Services section under Windows Azure Management Portal as shown in the screen below.

You can now use URL http://e71e15c2150f42a9b54738c336c02e85.cloudapp.net/HelloWorld to access the deployed application.

With this we have deployed our application in the staging environment in Windows Azure. Now let us see how to promote this application to production environment.

Steps to promote this application to production environment

In the Windows Azure Management Portal click on Swap VIP as shown in the screen below.

Swap VIPs dialog pops up as shown in the screen below. Click on OK to proceed further.

The environment of the Hosted Service now changes from Staging to Production as shown in the screen below.

This completes the process of promoting an application from staging to production environment in Windows Azure Platform.

Steps to upgrade our application and deploying it in Windows Azure Cloud

Now we will make a minor change in our application and deploy the newer version in Windows Azure platform.

In eclipse, open index.jsp under WebContent in the HelloWorld project. Include <b>Version 2.0</b> inside <body> tags in the jsp as shown below.

Save index.jsp.

To export the latest HelloWorld.war to the HelloWorldAzureProject, right click on the HelloWorld project in the project explorer and click on Export -> WAR file. In the destination text box, browse to <your project location>\HelloWorldAzureProject\WorkerRole1\approot. Check Overwrite Existing File option in the WAR Export dialog and click on Finish.

Click on Project -> Build All to build our changes and ensure the build is successful.

In Windows Azure Management Portal, click on Hosted Services, Storage Accounts & CDN and click on Production deployments as shown in the screen below.

Click on HelloWorld Deployment and click on Upgrade icon as shown in the screen below.

Upgrade Deployment dialog pops up.

Click on Browse Locally next to Package location text box and navigate to <your project location>\HelloWorldAzureProject\deploy\ and select WindowsAzurePackage.cspkg.

Click on Browse Locally next to Configuration file text box and navigate to <your project location>\HelloWorldAzureProject\deploy\ and select ServiceConfiguration.cscfg.

With these details entered Upgrade Deployment screen looks as shown below.

Click on OK to proceed further. A warning pops up as before. Click on Yes to ignore the warning for the purpose of this tutorial. Wait till the deployment is ready.

Now click on the DNS URL http://helloworldtutorial.cloudapp.net/HelloWorld/ and we can see the latest changes (Version 2.0) as shown in the screen below.

Conclusion

In this article we saw the steps involved in deploying the java application to the compute emulator and then to the Windows Azure Platform. Steps for promoting a deployment from staging environment to production environment are explained. We also saw how to upgrade our deployment in future after additional changes in our java application.

<<  Previous Article Continue reading and see our next or previous articles Next Article >>

About Janani K

Sorry, no bio is available

This author has published 2 articles on DotNetSlackers. View other articles or the complete profile here.

Other articles in this category


Android for .NET Developers - Location and Maps
In Windows Phone and iOS getting the current position of the device in terms of latitude and longitu...
Developing a Hello World Java Application and Deploying it in Windows Azure - Part I
This article demonstrates how to install Windows Azure Plugin for Eclipse, create a Hello World appl...
Android for .NET Developers - Using Web Views
In this article, I'll show a native app that contains a web-based view. The great news is that HTML ...
Android for .NET Developers - Building a Twitter Client
In this article, I'll discuss the features and capabilities required by an Android application to ta...
Ref and Out (The Inside Story)
Knowing the power of ref and out, a developer will certainly make full use of this feature of parame...

You might also be interested in the following related blog posts


Updated SilverTwit Code for MSDN Magazine read more
Update on Silverstripe and the WebPI read more
Provisioning a UCMA application using ApplicationProvisioner.exe read more
Windows Azure How Do I videos for developers recently released read more
Modularization Status Update read more
Application vs. AppDomain read more
The Ajax Papers: Part III read more
Vista: RegisterApplicationRecoveryCallback read more
Happy 15th Birthday to Visual Basic! read more
Job Openings read more
Top
 
 
 

Please login to rate or to leave a comment.