This article walks you through deploying an application to Azure.

You are recommended to check out offical Azure docs for the latest instructions for the same task.

What you’ll build

You’ll clone a sample Spring Boot application from GitHub and then use Maven to deploy it to Azure.

What you’ll need

The following prerequisites are required in order to follow the steps in this article:

Build and run a sample Spring Boot web app locally

In this section, you will clone an already written Spring Boot application and test it locally:

  1. Open a terminal window.

  2. Create a local directory to hold your Spring Boot application by typing mkdir SpringBoot

  3. Change to that directory by typing cd SpringBoot.

  4. Clone the Spring Boot Getting Started sample project into the directory you created by typing git clone

  5. Change to the directory of the completed project by typing cd gs-spring-boot/complete

  6. Build the JAR file using Maven by typing ./mvnw clean package

  7. When the web app has been created, start it by typing ./mvnw spring-boot:run

  8. Test it locally by either visiting http://localhost:8080 or typing curl http://localhost:8080 from another terminal window.

  9. You should see the following message displayed: Greetings from Spring Boot!

Config and deploy the app to Azure

  1. From the terminal window, config your web app with Maven Plugin for Azure Web App by typing ./mvnw This maven goal will first authenticate with Azure, if you have logged in with Azure CLI, it will consume its existing authentication token. Otherwise, it will get you logged in with azure-maven-plugin automatically.

  2. Then you can configure the deployment, run the maven command in the Command Prompt and use the default configurations by pressing ENTER until you get the Confirm (Y/N) prompt, press 'y' and the configuration is done.

    [email protected]:~/gs-spring-boot/complete$ mvn azure-webapp:config
    [INFO] Scanning for projects...
    [INFO] -----------------< org.springframework:gs-spring-boot >-----------------
    [INFO] Building gs-spring-boot 0.1.0
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO] --- azure-webapp-maven-plugin:1.6.0:config (default-cli) @ gs-spring-boot ---
    [WARNING] The plugin may not work if you change the os of an existing webapp.
    Define value for OS(Default: Linux):
    1. linux [*]
    2. windows
    3. docker
    Enter index to use:
    Define value for javaVersion(Default: Java 8):
    1. Java 11
    2. Java 8 [*]
    Enter index to use:
    Please confirm webapp properties
    AppName : gs-spring-boot-1559091271202
    ResourceGroup : gs-spring-boot-1559091271202-rg
    Region : westeurope
    PricingTier : Premium_P1V2
    OS : Linux
    RuntimeStack : JAVA 8-jre8
    Deploy to slot : false
    Confirm (Y/N)? : Y
  3. Then, open your pom.xml to see all the configuration written, and add the <appSettings> section to the <configuration> section of <azure-webapp-maven-plugin> to listen on the 80 port.

           <!-- Begin of App Settings  -->
           <!-- End of App Settings  -->
  4. Once you have configured all of the settings in the preceding sections of this article, you are ready to deploy your web app to Azure with mvn azure-webapp:deploy. Maven will deploy your web app to Azure; if the web app or web app plan does not already exist, it will be created for you. It might take a few minutes before the web app is accessible at the URL shown in the output. Navigate to the URL in a Web browser. You should see the message displayed: Greetings from Spring Boot!


Congratulations! You built and deployed a Spring Boot app to Azure. You can visit the Azure portal to manage it.

Don’t forget to delete the Azure resources created if no longer needed.

See also

Additional information about using Spring with Azure is available here:

Want to write a new guide or contribute to an existing one? Check out our contribution guidelines.

All guides are released with an ASLv2 license for the code, and an Attribution, NoDerivatives creative commons license for the writing.