Azure DevOps CI/CD — Deploying WAR file into Tomcat running in 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

- 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)

- 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

- Click on the hyperlink Use the classic editor option as its the easy way to setup

- 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)

- Click on continue & choose Maven template under Select a template & click apply

- Remove all tasks added by default except the Maven pom.xml task (Refer image below). Make sure the Goal is set 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

- 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

- 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

- 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

Thats all folks !!!