We will create Java web app in Azure App Service by using the Azure portal. The Azure portal is a web interface that we can use to manage Azure resources.
Pre-requisite
We require a Microsoft Azure Subscription.
JAVA application options
There are several ways we can set up Java application in an App Service web app:
1) Use template from the Azure Marketplace
The Azure Marketplace includes templates that automatically create and configure Java web apps with Tomcat or Jetty web containers. Web containers that the templates set up are configurable.
2) Create app and then configure Application settings.
App Service provides several Tomcat and Jetty versions, with default configuration. If the application that we will be hosting will work with one of the built-in versions, this method of setting up web container is the easiest but it lacks configuration capabilities in other methods. For this method, we create app in portal and then go to app’s Application settings blade to choose our version of Java along with desired Java web container. When we use this method the app runs from local hard drive that is used by worker to host app, which does not take disk space away from tenant. When we use this model, we don’t have access to edit files in this part of file system.
3) Create app and then manually copy and edit configuration files
We might want to host custom Java application that does not deploy in any of the web containers provided by App Service.
Use JAVA template from the Azure Marketplace
We will use the Azure Marketplace to create Java web app. The same general flow can also be used to create Java-based mobile or API app.
1) Log in to http://portal.azure.com
2) Click New >> Marketplace.
3) Click Web + Mobile.
4) In search text box, enter name of Java application server and then press Enter.
5) In search result, click Java application server.
6) In first Apache Tomcat or Jetty blade, click Create.
7) In next Apache Tomcat or Jetty blade, enter name for web app in Web app box.
This name must be unique in azurewebsites.net domain because URL of web app will be .azurewebsites.net. If the name we enter isn’t unique, a red exclamation mark appears in text box.
8) Select Resource Group or create a new one.
9) Select App Service plan/Location or create new one.
10) Click Create.
In short time, typically less than a minute, Azure finishes creating new web app.
11) Click URL to browse new site.
Jetty doesn’t have default page set, so same JSP that is used for empty Java site is reused here.
We’ve created web app with an app container.