Deploying Springboot to Azure App Service

前端 未结 1 975
[愿得一人]
[愿得一人] 2020-11-30 15:46

I\'m trying to deploy my springboot project into Azure App Service. I created an App Service and uploaded via FTP two files: test.war and web.config as mentioned in their tu

相关标签:
1条回答
  • 2020-11-30 16:11

    @ItaiSoudry, According to the content of your web.config file, it seems that you want to use the embedded servlet container like embedded tomcat or jetty to start up the spring boot web application.

    Assumption that the IDE you used is Eclipse, you need to export your spring boot project as a runnable jar file, not a war file, please see the figure below.

    Note: The Launch configuration should be selected the Class which the main function contains SpringApplication.run.

    Meanwhile, you need to configure the listen port with %HTTP_PLATFORM_PORT% the Azure App service supported via the argument --server.port=%HTTP_PLATFORM_PORT% in the web.config file or set the port of the class ServerProperties with the value System.getenv("HTTP_PLATFORM_PORT").

    Here is a sample for web.config with --server.port=%HTTP_PLATFORM_PORT%.

    <?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\test.jar&quot;">
        </httpPlatform>
      </system.webServer>
    </configuration>
    

    If you want to deploy a war file, you need to configure the ApplicationSettings of your app service on Azure portal, then upload the war file into the path wwwroot/webapps.

    As references, please refer to the documents below.

    1. The Springboot subsection in the article https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/#application-configuration-examples
    2. Create a Java web app in Azure App Service

    Hope it helps.

    0 讨论(0)
提交回复
热议问题