Create your first Java web app in Azure

Azure Web Apps provides a highly scalable, self-patching web hosting service. This quickstart shows how to deploy a Java web app to App Service by using the Eclipse IDE for Java EE Developers.

"Hello Azure!" example web app

Prerequisites

To complete this quickstart, install:

If you don't have an Azure subscription, create a free account before you begin.

Create a dynamic web project in Eclipse

In Eclipse, select File > New > Dynamic Web Project.

In the New Dynamic Web Project dialog box, name the project MyFirstJavaOnAzureWebApp, and select Finish.

New Dynamic Web Project dialog box

Add a JSP page

If Project Explorer is not displayed, restore it.

Java EE workspace for Eclipse

In Project Explorer, expand the MyFirstJavaOnAzureWebApp project. Right-click WebContent, and then select New > JSP File.

Menu for a new JSP file in Project Explorer

In the New JSP File dialog box:

  • Name the file index.jsp.
  • Select Finish.

    New JSP File dialog box

In the index.jsp file, replace the <body></body> element with the following markup:

<body>
<h1><% out.println("Hello Azure!"); %></h1>
</body>

Save the changes.

Publish the web app to Azure

In Project Explorer, right-click the project, and then select Azure > Publish as Azure Web App.

Publish as Azure Web App context menu

In the Azure Sign In dialog box, keep the Interactive option, and then select Sign in.

Follow the sign-in instructions.

Deploy Web App dialog box

After you have signed in to your Azure account, the Deploy Web App dialog box appears.

Select Create.

Deploy Web App dialog box

Create App Service dialog box

The Create App Service dialog box appears with default values. The number 170602185241 shown in the following image is different in your dialog box.

Create App Service dialog box

In the Create App Service dialog box:

  • Keep the generated name for the web app. This name must be unique across Azure. The name is part of the URL address for the web app. For example: if the web app name is MyJavaWebApp, the URL is myjavawebapp.azurewebsites.net.
  • Keep the default web container.
  • Select an Azure subscription.
  • On the App service plan tab:

    • Create new: Keep the default, which is the name of the App Service plan.
    • Location: Select West Europe or a location near you.
    • Pricing tier: Select the free option. For features, see App Service pricing.

      Create App Service dialog box

An App Service plan specifies the location, size, and features of the web server farm that hosts your app. You can save money when hosting multiple apps by configuring the web apps to share a single App Service plan.

App Service plans define:

  • Region (for example: North Europe, East US, or Southeast Asia)
  • Instance size (small, medium, or large)
  • Scale count (1 to 20 instances)
  • SKU (Free, Shared, Basic, Standard, or Premium)

Resource group tab

Select the Resource group tab. Keep the default generated value for the resource group.

Resource group tab

A resource group is a logical container into which Azure resources like web apps, databases, and storage accounts are deployed and managed.

Select Create.

The Azure Toolkit creates the web app and displays a progress dialog box.

Create App Service Progress dialog box

Deploy Web App dialog box

In the Deploy Web App dialog box, select Deploy to root. If you have an app service at wingtiptoys.azurewebsites.net and you do not deploy to the root, the web app named MyFirstJavaOnAzureWebApp is deployed to wingtiptoys.azurewebsites.net/MyFirstJavaOnAzureWebApp.

Deploy Web App dialog box

The dialog box shows the Azure, JDK, and web container selections.

Select Deploy to publish the web app to Azure.

When the publishing finishes, select the Published link in the Azure Activity Log dialog box.

Azure Activity Log dialog box

Congratulations! You have successfully deployed your web app to Azure.

"Hello Azure!" example web app

Update the web app

Change the sample JSP code to a different message.

<body>
<h1><% out.println("Hello again Azure!"); %></h1>
</body>

Save the changes.

In Project Explorer, right-click the project, and then select Azure > Publish as Azure Web App.

The Deploy Web App dialog box appears and shows the app service that you previously created.

Note

Select Deploy to root each time you publish.

Select the web app and select Deploy, which publishes the changes.

When the Publishing link appears, select it to browse to the web app and see the changes.

Manage the web app

Go to the Azure portal to see the web app that you created.

From the left menu, select Resource Groups.

Portal navigation to resource groups

Select the resource group. The page shows the resources that you created in this quickstart.

Resource group myResourceGroup

Select the web app (webapp-170602193915 in the preceding image).

The Overview page appears. This page gives you a view of how the app is doing. Here, you can perform basic management tasks like browse, stop, start, restart, and delete. The tabs on the left side of the page show the different configurations that you can open.

App Service page in Azure portal

Clean up resources

In the preceding steps, you created Azure resources in a resource group. If you don't expect to need these resources in the future, you can delete them by deleting the resource group.

  1. From your web app's Overview page in the Azure portal, select the myResourceGroup link under Resource group.
  2. On the resource group page, make sure that the listed resources are the ones you want to delete.
  3. Select Delete, type myResourceGroup in the text box, and then select Delete.

Next steps