Click here to Skip to main content
15,881,600 members
Articles / Hosted Services / Azure
Article

Modernizing Java Apps and Data on Azure Part Three: Migrating to Azure App Service

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
1 Mar 2022CPOL7 min read 3.3K   1  
How to lift and shift our Java app to Azure using Azure App Service
This is Part 1 of a 6-part series that demonstrates how to take a monolithic Java application and gradually modernize both the application and its data using Azure tools and services. This article shows how to create the app via the Azure Portal and then deploy it using an Azure IDE plugin (preferably IntelliJ).

This article is a sponsored article. Articles such as these are intended to provide you with information on products and services that we consider useful and of value to developers

Now that you’ve migrated your data, it’s time to lift and shift your Java application to Azure using Azure App Service. Microsoft’s Azure App Service is a platform as a service (PaaS) hosting applications on a highly available, secured, and monitored infrastructure fully integrated with the entire Azure platform. The service can host web applications developed in many frameworks and languages, including ASP.NET, Java, and Ruby on Windows and Linux hosts.

Although the Azure site details the full benefits, here’s a summary:

  • Integrate with other Azure services, such as Azure Active Directory, to control access and verify user identity.
  • The service is highly available, so you know your application is up and running.
  • Improve team development with CI/CD integrations to Git, GitHub, and other popular services.
  • Implement zero and low downtime deployments using deployment slots.
  • Use the monitoring features to determine and respond to demand.
  • Run applications and containers within the same environment so that you can refactor your monolithic application into containerized services over time.
  • Run applications built on both Windows and Linux so you can choose the technologies you use.

You won’t need to make any changes to the application to rehost it on Azure App Services. Spring Boot provides a complete runtime environment that requires only Java and because Azure App Services provides the infrastructure consistent with Spring Boot’s requirements.

Also, because you allowed Azure services to connect to your database when you migrated your data to Azure services in the previous article, your application will be able to connect to your database without any changes. You might consider upgrading in the future by adding authentication to add an application security layer above the network security you configured.

Deploying an application to Azure App Services is straightforward once you have a few tools in place in your development environment. This article uses IntelliJ’s Azure plugin to demonstrate the process. Many examples are available if you want to use other tools, such as Spring Boot’s tutorial and Microsoft’s tutorials for GitHub and Azure DevOps.

There are two parts to the deployment process. The first is to create the Azure App Service and deploy the application. However, you must install and configure the Azure Toolkit for IntelliJ before deploying since you’re using the IntelliJ IDE for development. This installation is a one-time precursor. Microsoft provides instructions for installing an Eclipse plugin if you prefer that environment.

Installing the Azure Toolkit for IntelliJ

IntelliJ integrates with Azure using the Azure Toolkit for IntelliJ. You can install it from the website.

Image 1

Make sure you have IntelliJ running when you click the installation button. After installing the plugin, you’ll see a success message in the browser’s lower right corner:

Image 2

The toolkit needs access to your Azure account, so sign in. To do this, select Tools/Azure/Azure Sign In.

Image 3

The sign-in options depend on the tools installed on your machine. Select OAuth 2.0 and sign in to Azure using the default browser.

Image 4

Once you’ve signed in, you can select your subscription.

Image 5

Creating the App Service

When you deploy an application, you need to create a Service Plan and request the supporting infrastructure. Do this by creating an App Service in the Azure Portal. Once configured, you can deploy the application to the service. The process starts by logging into your account in the Azure Portal.

Image 6

If you see the App Services icon, click it to open the App Services page. There, you can click the Create button to display the Create Web App blade, as the screenshot below shows:

Image 7

If you don't see the App Services icon, click Create a resource and search for “Web App.”

Image 8

Many similar services are in the Marketplace. Make sure you pick the Web App icon shown in the screenshot above and click the Create/Web App list. This action takes you to the Create Web App blade.

Image 9

Both paths take you to the same blade. As the screenshot above shows, you’ll need to select your subscription and choose a Resource Group or create a new one.

Next, in the Instance Details section, set the fields shown below. Set the Name of your app service, set Publish to Code, select Java 11 for the Runtime Stack, choose Linux for the Operating System, and select your preferred Region.

Image 10

Next, scroll down and set the App Service Plan. For this demonstration, click Change Size to display the Spec Picker page, then click Dev / Test and B1 to select the machine to use. Click Apply to apply this plan.

Image 11

Finally, click Review + Create to review your choices.

Image 12

Then click Create to create the Web App Service.

Image 13

The process takes a few minutes, so you’ll initially get an “Initializing deployment...” notification in the top-right corner.

Image 14

When the deployment is complete, you’ll get a “Your deployment is complete” message:

Image 15

Deploying the Application

Now that IntelliJ has access to your account, right-click on the project and select Azure from the context menu with your project open. Then click Deploy to Azure Web Apps.

Image 16

IntelliJ displays the page visible in the following screenshot. You may need to pick the Web App Service if you have more than one available.

Image 17

Click Run to build and deploy the application. When the process is complete, you’ll get a “Deploy succeed” message like in this screenshot:

Image 18

You can click the URL to verify that the application is running.

Image 19

You can also see the application’s information in the Azure portal.

Image 20

Monitoring Activity

Now that the application is running, you’ll need to tune performance. Scroll the Overview page down to view a dashboard with valuable metrics.

Image 21

You can monitor other metrics on the Metrics blade that hosts the Azure Metrics Explorer. You can learn more from Getting Started with Azure Metrics Explorer, but here’s a snapshot to show where to find the feature and to highlight what’s available.

Image 22

Additional metrics like CPU Time and Response Time provide the necessary information to identify performance blocks.

Reviewing Network Settings

You can review and change the network firewall rules by clicking the Access restrictions link in the Network blade’s Inbound Traffic section.

Image 23

You can create rules like limiting access to a select set of client machines by IP address.

Image 24

Next Steps

Do you need a custom domain or want to transfer your existing domain to the new host? You can click Custom domains and enter the relevant information like in the screenshot below.

Image 25

Does your application change often? Start by containerizing your application and then break it into multiple services in individual containers. This approach reduces deployment issues by using clean service boundaries to decrease hidden interactions.

Is demand growing? Select the Scale up or Scale out options that meet your needs.

Image 26

Do you need to scale quickly with rapidly-changing demand? Consider refactoring some containerized services to separate functions hosted by Azure Functions. You can create these lightweight functions on demand. They only exist if required, so they automatically scale down.

Do you need a more agile deployment cycle? You can easily update containers and Azure functions and automate the process entirely in your continuous integration and continuous deployment (CI/CD) pipeline.

Do you need to provide fine-grained role-based access control? Azure can assign an identity to your Azure Function to use with a secret-keeper, ensuring users access what they need but not more.

Image 27

You can explore all of Azure App Service’s benefits in the documentation site, which provides tutorials and samples for many languages and services. Free learning path modules will show how to use the platform’s features.

Carry on to the next part of this series to learn how to refactor the monolith. The steps are to containerize it, migrate to scalable data, and break out essential services, so the application becomes lighter, easier to deploy and maintain, and more agile.

If you'd like to discuss a specific Java app migration scenario with the Microsoft Java on Azure team, please fill out this questionnaire and a representative will contact you.

This article is part of the series 'Modernizing Java Apps and Data on Azure View All

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --