一:创建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 "%HOME%\site\wwwroot\webapps\gs-spring-boot-0.1.0.jar""> </httpPlatform> </system.webServer> </configuration>
10. 验证Spring Boot代码部署
登陆到Azure web app service主界面,点击URL Link
至此,第一个Spring Boot项目成功在Azure Web App Service上部署成功!