Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot App on Microsoft Azure

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.

like image 424
Daniel Pinkpank Avatar asked Jun 09 '15 12:06

Daniel Pinkpank


People also ask

Can Azure deploy spring boot application?

Create a Spring Boot application, connect it to a MySQL database, and then deploy to Azure App Service.

How does spring boot integrate with Azure?

Open a terminal window. Create a local directory to hold your Spring Boot application by typing mkdir SpringBoot. Change to that directory by typing cd SpringBoot . Clone the Spring Boot Getting Started sample project into the directory you created by typing git clone https://github.com/spring-guides/gs-spring-boot.

How do I deploy a spring boot application in Azure Devops?

Setup CD PipelineIn the CD pipeline, provide connection details of Azure Subscription, App Service Type, Name of App Service, and path of the jar file. Click on Create release. In CD Pipeline, click on a small trigger icon next to the build name box and enable 'Continuous deployment trigger'. You are done.

Does Microsoft use spring boot?

Microsoft's making it easier, though. They've got a Spring Boot Starter just for Azure Key Vault, and clean integration with Azure Active Directory via Spring Security. I'm also looking forward to seeing managed identities in these developer SDKs. I like the support for Azure Active Directory B2C.


3 Answers

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..

like image 70
Mannie Avatar answered Oct 20 '22 16:10

Mannie


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> 
like image 41
herman Avatar answered Oct 20 '22 17:10

herman


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.

like image 20
Max 23 Avatar answered Oct 20 '22 17:10

Max 23