Azure DevOps CI/CD — Deploying WAR file into Tomcat running in Azure App Service

Vicky AV
4 min readJul 4, 2020
Github + Azure DevOps Pipeline + Tomcat + Azure App Service

Step by step instruction on how to deploy Spring Boot application WAR file into Tomcat running in Azure App Service (using Azure DevOps Pipeline)

Remember, we are not gonna use Docker for this

Creating an Azure App Service

  • Login to https://portal.azure.com/ & click on App Service -> Create App Service
  • Create new resource group (E.g. sample-resource-group) by click on Create new hyperlink
Create new Resource Group
  • Under Instance Details, enter Name for our web app. This name will be appended as prefix to .azurewebsites.net & act as URL for our application

E.g. If web app name is sboot-jsp-sample, then application URL will be https://sboot-jsp-sample.azurewebsites.net

  • Choose type as “Code” under Publish option & Runtime stack as Tomcat 9.0

By choosing publish option as Code, we are enabling direct WAR deployment into Tomcat from pipeline (without need for Docker)

Creating new Web App in Azure App Service
  • Choose region of your choice & click on review & create
  • Once done, click on review & create & app service should get created by now

If you are interested on how to deploy web application as Docker image in Azure App service, please visit my other medium posts below

Lets create Azure DevOps Pipeline

Before list down steps, let me tell you what I am trying to do here

Since my project is based on Maven , I am gonna run mvn clean package & create WAR file first. Once the WAR file is ready, I am gonna deploy it into the Azure App Service we created in above steps

Steps

  • Go to https://dev.azure.com/ & create a new project
  • Click on Pipelines from left panel menu & choose Pipelines. Click on Create pipeline
Time to create Azure DevOps Pipeline
  • Click on the hyperlink Use the classic editor option as its the easy way to setup
Choose the Use the classic editor option
  • Select a source as Github & choose the repo and branch (Remember you have to authorize Azure to use your Github, otherwise it can’t pull the projects from your Github)
I am gonna deploy my sample Spring Boot MVC with JSP application App Service. (Refer https://github.com/iamvickyav/spring-boot-with-JSP)
  • Click on continue & choose Maven template under Select a template & click apply
Choose Maven or Gradle depends on your build needs
  • Remove all tasks added by default except the Maven pom.xml task (Refer image below). Make sure the Goal is set as Package
Make sure you have Maven pom.xml task alone in list (with Goal as Package)
  • Click on Add new task by clicking the + sign next to Agent Job 1. Choose Azure App Service Deploy from the tasks available
Lets deploy directly into Azure App Service from our pipeline
  • Choose the appropriate subscription. Choose App Service Type as Web App on Linux (Remember we created Operating System as Linux while creating our app service). App service name we created should be available in drop down by now. Choose the appropriate app service
Choose the appropriate App Service Type & App Service name from dropdown
  • Change the package or folder option value to $(System.DefaultWorkingDirectory)/**/*.war since we are gonna create WAR file
  • Choose the Run Time stack as Tomcat 9.0
Changing Package or folder option to WAR is mandatory
  • Click on Save & Queue. You should see the pipeline job getting triggered by now
  • Once the pipeline run successfully, you can access the application running in Azure App Service by hitting the URL —

https://<app-service-name>.azurewebsites.net

Sample Application running successfully in Azure App Service

Thats all folks !!!

--

--