-
Notifications
You must be signed in to change notification settings - Fork 649
Deploying WAR files using wardeploy
This page talks about the wardeploy deployment mechanism for deploying WAR files to Azure Web Apps running Tomcat.
There are multiple ways to deploy a WAR (Web Application Arhcive) file to an Azure Web App running Tomcat, but the most common one is to use FTP to upload the WAR file in the /home/site/wwwroot/webapps directory. When Tomcat detects the presence of a new WAR file, it unpacks it and loads the web application from the directory the WAR file was unpacked to.
This works great when you have an Azure Web App that isn't scaled out. However, when you scale out the web app, multiple Tomcat instances race to unpack the WAR file leading to race conditions that may land one or more workers / instances in a bad state. This issue manifests in different ways, most common being a 404 status code when an incoming request is routed to any of the bad workers.
wardeploy is a deployment mechanism for addressing this problem.
wardeploy is available as a REST API - /api/wardeploy - and can be used to deploy to an Azure Web App running Tomcat on either Windows or Linux. The following sections explain how to use it from bash and Powershell.
Run the following script after editing the placeholder values for web app name, credentials, etc. This wiki page explains how you can get the credentials for your web app.
# *** BEGIN *** Customizations
sitename='site1' # if you site is site1.azurewebsites.net
username='yourusername' # Example: username='$site1' (NOT 'site1\$site1', NOT 'site1\site1'. Also, note the single quotes.)
password='yourpassword'
warFilePath='./test1.war'
# *** END *** Customizations
curl -X POST -u $username:$password https://$sitename.scm.azurewebsites.net/api/wardeploy --data-binary @$warFilePathRun the following script after editing the placeholder values for web app name, credentials, etc. This wiki page explains how you can get the credentials for your web app.
# *** BEGIN *** Customizations
$sitename='site1' # if you site is site1.azurewebsites.net
$username='yourusername' # Example: $username='$site1' (NOT 'site1\$site1', NOT 'site1\site1'. Also, note the single quotes.)
$password='yourpassword'
$warFilePath='D:\test1.war'
# *** END *** Customizations
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes((