Spring Boot App on Microsoft Azure

8.9k Views Asked by At

I would like to know if it's possible to deploy a spring boot application with MySQL database to the azure cloud. I couldn't find any instructions or tutorials.

4

There are 4 best solutions below

0
On

Yes;

  • Create the web-app on the azure portal (tomcat or Jetty) (info)

  • create the war file from spring boot using your gradle/maven build scripts (info)

  • upload to Azure using the FTP options (info) & this

And you are done - it will be served on the default URL..

0
On

If you are looking at general Azure IAAS (Infrastructure as a service) part, then this question should not arise, since it is as good as any other IAAS offerring from other cloud service providers like Amazon. It can pretty much run anything, and yes, including Spring boot applications

If you are talking about a micro-service based hosting through Service fabric, question will be interesting, since Service fabric in itself provides the micro service hosting part and a plug and play there will be interesting.

0
On

This worked for me with an Azure API-App:

  • Create the API-App in Azure
  • Create the war file from Spring Tool Suite (File -> Export -> Web -> War-File) or via maven build
  • Name the war file "ROOT.war"
  • Put it in a folder "webapps"
  • Push the webapps-folder and the containing war to a git repository
  • Add the git repository to the Api-App Deployment Options in Azure

If the App is setup correctly (correct Java and Tomcat version selected), the war should be extracted automatically.

Additionally you can add a web.config file (parallel to the webapps folder), for more configuration options.

If the ROOT.war is not extracted, try removing the existing ROOT folder.

0
On

In additional to general information about java web apps, there's some Spring Boot-specific info in the Azure documentation:

https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/#springboot

In order to get a Springboot application running you need to upload your JAR or WAR file and add the following web.config file. The web.config file goes into the wwwroot folder. In the web.config adjust the arguments to point to your JAR file, in the following example the JAR file is located in the wwwroot folder as well.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
        arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\my-web-project.jar&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>