The first deployment of a simple Spring Boot to Azure application service

 

One: Create Azure Web App Service on Windows

1. Select "Web App" in the "Create a resource" in

    

2. Create Resource Group and create an instance name for the application                            

 3. Select the "Runtime stack, Operating System", to create a "Windows Plan", others leave the default settings

   

4. Click on "Review and create" button, then click the "Create" button to create Azure Web App service.

5. After the deployment, return to Web App Service home page, you can click on the URL check their App Service.

6. Click your Web App Service URL, what information to prove your Web App service to create success!

 Two: Spring Boot project to deploy Azure Web App Service

1. Installation Git, Maven, Java8, detailed steps are not listed.

2. In the local clone "Spring Boot Getting Start" sample project

git clone https://github.com/spring-guides/gs-spring-boot

3. Go to "complete" Directory Structure

cd gs-spring-boot/complete

4. Construction Jar coated with Maven

mvn clean package

5. Start with the local Maven Web App

mvn spring-boot:run

6. Test Web App in a browser 

http://localhost:8080

出现"Greetings from Spring Boot!",证明 Spring Boot项目在本地构建成功!

 7. 下载并且解压FTP工具FileZilla

 8. 打开FileZilla程序,配置Host, UserName, Password

    

  找到第一部分创建好的Azure Web App, 到"Deployment Center"页面,选择"FTP"

     

     点击"Dashboard"页面,复制FTPS Endpoint 值到FileZilla的Host,复制Username跟Password值分别到FileZilla的Username 和 Password。

    

    将Host, Username, Password信息输入好之后,点击"Quickconnect",在弹出的对话框中选择Ok接受认证,这样就本地成功连接到Azure上的Web App service。

   

 

9. 上传Spring Boot Jar包跟web.config到Azure web app service上

    上传Maven构建好的Jar包到 Azure web app上的folder "webapps".

    

    上传web.config文件到Azure web app上的 "wwwroot" 文件夹下

    

    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%\bin\java.exe"
        arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\webapps\gs-spring-boot-0.1.0.jar&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>

10. 验证Spring Boot代码部署

     登陆到Azure web app service主界面,点击URL Link

   

   至此,第一个Spring Boot项目成功在Azure Web App Service上部署成功!

 

 

Guess you like

Origin www.cnblogs.com/brightleowang/p/11112719.html