Deploy Spring boot in Azure

Markus#azure, #development, #java, #spring boot


The background of this post is to explain how to get a Spring boot application running in the Azure cloud.
This post will not explain in detail how to setup a full Spring boot application, it will only show the minimum dependencies needed and what you need to add to your code to make it work.

Preparing the Spring boot application
First minimum dependencies required for this is:


By default, a Spring boot application is self contained and the application server (Tomcat, Jetty) is embedded and can be started from the terminal using

But you can also specify that you want to run the application in a external application server. For this you will need to extend the SpringBootServletInitializer. and override the following method SpringApplicationBuilder configure(SpringApplicationBuilder application).


When this is done you need to build a war file that you can deploy to your application server.

For maven you run mvn package war:war this will create your war file under the target folder in your project.
This file can later be deployed to a tomcat server for example on Azure.
If you want the app to response to / and no context path rename the war file to ROOT.war. Then you can call the Api with http://azure-adress/api-name. If you deploy the war file with the name of the project example demo.war, the address will look something like this: http://azure-adress/demo/api-name

Setup Azure

First you need to add an api app. You can do that by first clicking the plus sign (+) then go to Web + mobility and in the list choose API App. If you can´t find it in the list go to marketplace.

Image of Yaktocat

When you have created the service you need to do some minor configuration:

Go to in to the API App go to Settings > Application Settings
Set the following
Java version
Web container


You can setup deployment under deployment source. You can choose to implement Local Git repository or some of the other services for deployment. If you want to test quicker you can always use the FTP to upload the war file. If Tomcat is used, a folder named webapps will be present under wwwroot. It’s under the webapps folder you put your war file.