将 Springboot 部署到 Azure 应用服务 [英] Deploying Springboot to Azure App Service

查看:41
本文介绍了将 Springboot 部署到 Azure 应用服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的 springboot 项目部署到 Azure 应用服务中.我创建了一个应用服务并通过 FTP 上传了两个文件:test.war 和 web.config,如他们的教程中所述.

web.config

我正在将 war 文件上传到站点/wwwroot 并将 web.config 文件也放在那里.

我的问题是:如何执行war文件?它应该在我自动完成部署时发生吗?因为现在我得到的只是服务不可用,Http 错误 503.

谢谢

解决方案

@ItaiSoudry, 根据你的 web.config 文件的内容,你似乎想使用嵌入式 servlet 容器嵌入式 tomcat 或 jetty 来启动 spring boot web 应用程序.

假设您使用的IDE是Eclipse,您需要将您的spring boot项目导出为可运行的jar文件,而不是war文件,请看下图.

注意:Launch configuration应该选择main函数包含的ClassSpringApplication.run.

同时,您需要使用%HTTP_PLATFORM_PORT%配置监听端口,通过--server.port=%HTTP_PLATFORM_PORT%中的参数--server.port=%HTTP_PLATFORM_PORT%支持Azure App服务code>web.config 文件或设置类的端口

作为参考,请参考以下文档.

  1. 文章中的 Springboot 小节 https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/#application-configuration-examples
  2. 在 Azure 中创建 Java Web 应用应用服务

希望有帮助.

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

web.config

<?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%injava.exe"
        arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar   &quot;%HOME%sitewwwroot	est.war&quot;">
    </httpPlatform> 
  </system.webServer>
</configuration>

I'm uploading the war file into the site/wwwroot and placed the web.config file there as well.

My question is: How do I execute the war file? is it supposed to happen when I finish deploy automatically? cause right now all I get is Service Unavailable, Http Error 503.

Thanks

解决方案

@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%injava.exe"
        arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%sitewwwroot	est.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.

这篇关于将 Springboot 部署到 Azure 应用服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆