部署第一个简单Spring Boot到Azure应用服务中

 

一:创建Azure Web App Service on Windows

1. 在“Create a resource"中选择 "Web App"

    

2. 新建Resource Group并且为应用程序创建实例名                            

 3. 选择 "Runtime stack, Operating System", 创建 “Windows Plan", 其他保留默认设置

   

4. 点击"Review and create" 按钮,然后点击"Create"按钮来创建Azure Web App service.

5. 部署完后,回到 Web App Service主页,可以点击URL查询自己App Service.

6. 点击你的Web App Service URL, 一下信息证明你的Web App service创建成功!

 二:部署Spring Boot项目到Azure Web App Service

1. 安装Git, Maven, Java8, 详细步骤不在罗列。

2. 在本地克隆”Spring Boot Getting Start" sample project

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

3. 进入“complete" 目录结构

cd gs-spring-boot/complete

4. 用Maven构建Jar包

mvn clean package

5. 用Maven在本地启动Web App

mvn spring-boot:run

6. 在浏览器中测试Web App 

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上部署成功!

 

 

转载于:https://www.cnblogs.com/brightleowang/p/11112719.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值