Create Java Based Web App in Azure using Eclipse IDE

Introduction

We discussed creating a web app on Azure using Visual Studio here. In this Blog, we’ll elaborate the details of creating a Java-based Web App through Eclipse development Platform.

Create Web Apps in Azure using Eclipse

In this tutorial, let’s create sample Java web app in Eclipse and publish it to Azure.

  • Prerequisite
  1. Java Developer Kit (JDK), version 1.8 or later.
  2. Apache Tomcat server
  3. Active/Trial Azure Subscription
  4. Eclipse Neon or higher (We’ve used Eclipse Oxygen for this tutorial)
  • Azure Toolkit installation
  1. Start Eclipse
  2. Click Help -> Install new Software…
  3. In “Available Software” window, within “Work with” textbox copy this URL: http://dl.microsoft.com/eclipse/
  4. In Name pane, select only “Azure Toolkit for Java”, also uncheck “Contact all update sites during install to find required software” at the bottom. Click Next
  5. In “Install details dialogue” click Next.
  6. Accept terms of License Agreements and click Finish.
  7. Eclipse will download and install all required packages. Restart Eclipse once installation is complete.
  • Create Sample Java Project in Eclipse
    1. Click File -> New -> Project. Select Dynamic Web Project.
    2. In Project Name, provide project name as AzureSampleApp.
    3. In Project Explorer, expand newly created AzureSampleApp and inside WebContent folder add index.jsp file.
    4. Open index.jsp, and paste below snippet inside the existing <body> parameter and then save it.
    5. <body>
      <b><% out.println(“Azure web App”); %></b>
      </body>
    6. Build the app and run it on local application server such as Tomcat. You could see the page like below

  • Publish Application On Azure
  1. In Project Explorer, right-click the project and select Azure.
  2. Select Publish as Azure Web App
  3. On Azure Sign In page, select Interactive, where we will manually login using Azure Subscription credentials.
  4. After Sign In, you can see Your Subscriptions which are listed in the window. Select your appropriate subscription.
  5. In the Deploy Web App pane, click Create.
  6. In the Create App Service pane, enter the name for your Azure App. We are using the name as “azuresampleappdemp”.
  7. In-App Service Plan tab, select location and pricing tier as appropriate.
  8. In Resource Group tab, we are selecting existing Resource Group but you can anyways create a new one.
  9. And lastly in Java tab, select environment parameters such as Java version and Tomcat version.
  10. Click Create. Then Azure Toolkit displays progress and finally creates the web app in Azure Cloud.
  11. After creating, you can see the app in the Deploy Web App window along with its details. But wait, our app isn’t live yet.
  12. To make it go live we have to deploy the app.
  13. Before clicking Deploy, make sure you have selected Deploy to root If you don’t select it then your app will be deployed on https://azuresampleappdemo.azurewebsites.net/AzureSampleApp having the app name in URL path, but by selecting app with root level deployment, App URL would be https://azuresampleappdemo.azurewebsites.net
  14. You can see progress in the Azure Activity Log dialog box in Eclipse.
  15. Click Published after publishing gets completed. It will open the web application in the browser. Congratulations!! , you have successfully created and deployed Azure Web App from Eclipse

Concluding Note

In this blog, we have gone through the steps of creating a Java-based Web App through Eclipse IDE. Stay tuned for our next blog, where we would be discussing ‘How to Managing and Monitoring the Web App on Azure.