Skip to content

Latest commit

 

History

History
129 lines (79 loc) · 4.45 KB

File metadata and controls

129 lines (79 loc) · 4.45 KB
title Build and deploy to a Java web app on Linux
description Continuous integration and deployment (CI/CD) to a Java web app on Linux.
ms.topic tutorial
ms.custom devx-track-extended-java, linux-related-content
ms.assetid 49253EA0-9CD6-4082-A303-95F78C7599C2
ms.date 12/22/2021
monikerRange azure-devops

Build & deploy to Java web app

[!INCLUDE version-eq-azure-devops]

A web app is a lightweight way to host a web application. In this step-by-step guide, learn how to create a pipeline that continuously builds and deploys a Java app. Each commit can automatically build at GitHub and deploy to an Azure App Service. You can use whatever runtime you prefer, Tomcat, or Java SE.

For more information, see Java for Azure App Service.

Tip

If you only want to build a Java app, see Build Java apps.

Prerequisites

[!INCLUDE include] [!INCLUDE include]

Get the code

Select the runtime you want to use.

[!INCLUDE include]

https://github.com/spring-petclinic/spring-framework-petclinic

[!INCLUDE include]

https://github.com/spring-projects/spring-petclinic

Create an Azure App Service

[!INCLUDE include]

Create an Azure App Service on Linux.

# Create a resource group
az group create --location eastus2 --name myapp-rg

# Create an app service plan of type Linux
az appservice plan create -g myapp-rg -n myapp-service-plan --is-linux

# Create an App Service from the plan with Tomcat and JRE 8 as the runtime
az webapp create -g myapp-rg -p myapp-service-plan -n my-app-name --runtime "TOMCAT|8.5-jre8"
# Create a resource group
az group create --location eastus2 --name myapp-rg

# Create an app service plan of type Linux
az appservice plan create -g myapp-rg -n myapp-service-plan --is-linux

# Create an App Service from the plan with Java SE as the runtime
az webapp create -g myapp-rg -p myapp-service-plan -n my-app-name --runtime "JAVA|8-jre8"

Create the pipeline

[!INCLUDE include]

  1. When the Configure tab appears, select Show more, and then select Maven package Java project Web App to Linux on Azure.

  2. You can automatically create an Azure Resource Manager service connection when you create your pipeline. To get started, select your Azure subscription where you created a resource group.

  3. Select Validate and configure. The new pipeline includes a new Azure Resource Manager service connection.

    As Azure Pipelines creates an azure-pipelines.yml file, which defines your CI/CD pipeline, it:

    • Includes a Build stage, which builds your project, and a Deploy stage, which deploys it to Azure as a Linux web app.
    • As part of the Deploy stage, it also creates an Environment with default name same as the Web App. You can choose to modify the environment name.
  4. Make sure that all the default inputs are appropriate for your code.

  5. Select Save and run, after which you're prompted for a commit message because the azure-pipelines.yml file gets added to your repository. After editing the message, select Save and run again to see your pipeline in action.

See the pipeline run, and your app deployed

As your pipeline runs, your build and deployment stages go from blue (running) to green (completed). To watch your pipeline in action, you can select stages and jobs.

After the pipeline runs, check out your site!

https://my-app-name.azurewebsites.net/petclinic

After the pipeline runs, check out your site!

https://my-app-name.azurewebsites.net


Also explore deployment history for the app by going to the "environment". From the pipeline summary:

  1. Select the Environments tab.
  2. Select View environment.

[!INCLUDE include]

Next steps