Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Latest commit

 

History

History
64 lines (41 loc) · 2.84 KB

deploy-to-azure-web-app-tomcat-using-jenkins.md

File metadata and controls

64 lines (41 loc) · 2.84 KB

Deploy to Azure Web App for Tomcat using Jenkins

This tutorial shows you how to deploy a Java app to Azure Web App for Tomcat using Azure App Service Plugin. Below are the major steps in this tutorial.

Create Azure Web App

Create an Azure Web App with built-in support for Tomcat by Azure portal or Azure CLI.

Prepare Jenkins server

  1. Deploy a Jenkins Master on Azure

  2. Install the plugins in Jenkins. Click 'Manage Jenkins' -> 'Manage Plugins' -> 'Available', then search and install the following plugins: Azure App Service Plugin, EnvInject Plugin.

  3. Add a Credential in type "Microsoft Azure Service Principal" with your service principal.

Create job

  1. Add a new job in type "Pipeline".

  2. Enable "Prepare an environment for the run", and put the following environment variables in "Properties Content":

    AZURE_CRED_ID=[your credential id of service principal]
    RES_GROUP=[your resource group of the web app]
    WEB_APP=[the name of the web app]
    DOCUMENTDB_URI=[the URI of the DocumentDB]
    DOCUMENTDB_KEY=[the key of the DocumentDB]
    DOCUMENTDB_DBNAME=[the name of the DocumentDB]
    

    You can save your DocumentDB settings in your Web App Application settings if you would like to manage your application settings independently.

  3. This application's default package type is jar. So you have to make some changes to enable it create a deployable war file. Please refer to Spring Boot doc here.

  4. Choose "Pipeline script from SCM" in "Pipeline" -> "Definition".

  5. Fill in the SCM repo url and script path. (Script Example)

Build and Deploy Java application to Azure Web App

  1. Verify you can run your project successfully in your local environment. (Run project on local machine)

  2. Run jenkins job.

  3. Navigate to the website from your favorite browser. You will see this app successfully running on Azure Web App.

Clean Up Resources

Delete the Azure resources you just created by running below command:

az group delete -y --no-wait -n <your-resource-group-name>