Java web app deployment on Azure App Service

App Service:

Samiksha Jadhav
4 min readAug 13, 2021

Azure App Service is an HTTP-based service for hosting web applications, REST APIs, and mobile back ends. You can develop in your favorite language, be it .NET, .NET Core, Java, Ruby, Node.js, PHP, or Python. Applications run and scale with ease on both Windows and Linux-based environments.

App Service not only adds the power of Microsoft Azure to your application, such as security, load balancing, auto scaling, and automated management. You can also take advantage of its DevOps capabilities, such as continuous deployment from Azure DevOps, GitHub, Docker Hub, and other sources, package management, staging environments, custom domain, and TLS/SSL certificates.

Deploy java web application on Azure App Service:

Azure App Service provides a highly scalable, self-patching web hosting service. This article will show 2 approaches by which you can deploy your web app:

  1. Using Local Git
  2. Deploy war using CLI

Both the approaches are quite simple, will also describe how to verify both the deployments.

1. Using Local Git :

Prerequisites : Git must be installed on your system and App service created on azure.

Follow below steps to deploy your web app to the app service:

a. Go to your app service and then click on deployment center on the left.

b. Now go to settings and click on local git:

c. Click on save and after that you will get a git clone uri.

d. Now click on manage publish profile and download it:

e. Once you download the publish profile, you will get the username and password to push your code to the git.

Ex:

userName=”$yourusername”

userPWD=”passwrd”

f. That’s all you need to push your web app to the app service.

g. Now open Git bash and clone url which we have created via Local git option.

h. Copy your code to git repo, add it, commit it and push it to the master. Once successfully pushed, you will see the below output:

i. Now click on the browse, and it will take you to your deployed web app.

j. You can also verify the deployment using Kudo. On the app service just search for advance option and click on Kudo. This will take you to the kudo dashboard. Click on deployment logs:

And it will show you all the deployments:

This is the 1st way by which you can deploy your static java web-app to Azure App Service using Local Git.

2. Deploy war using CLI : Here we are going to deploy using az cli.

Prerequisite: az cli must be installed on your system

a. Login to azure. using:

az login

b. Use below command to push war file to azure app service :

az webapp deployment source config-zip –resource-group {group-name} –name {Webapp-name} –src {location-of-war}

c. Go to the overview page and click on the app service URL:

This will take you to the web app:

Troubleshooting : If you are working on web app, it is very important to know how to troubleshoot if there is any issue. Below are few pointers :

1. When you are not deploying via package, make sure below flag is disabled, because it will not let your application deploy even after logs says web-app successfully deployed:

WEBSITE_RUN_FROM_PACKAGE

To know more about this flag please refer below URL:

https://docs.microsoft.com/en-us/azure/app-service/deploy-run-package

2. To view deployment logs, it is very Important to know how kudos work.

Whenever an application is deployed to azure app service a file named status.txt is created.

To check if it is created, go to kudos dashboard, open bash and go to /appsvctmp folder.

3. In the backend, docker containers will be created when you deploy your web app, to check that open /home/site/deployments folder. There you will find all your deployments, you can go to that container and check logs if any issue is there or it is successfully running.

--

--