使用 IntelliJ 部署 Azure Spring Cloud 应用程序Use IntelliJ to deploy Azure Spring Cloud applications

适用于 Azure Spring Cloud 的 IntelliJ 插件支持从 IntelliJ IDEA 进行应用程序部署。The IntelliJ plug-in for Azure Spring Cloud supports application deployment from the IntelliJ IDEA.

在运行此示例之前,可以尝试基础知识快速入门Before running this example, you can try the basic quickstart.

先决条件Prerequisites

安装插件Install the plug-in

可以从 IntelliJ“插件”UI 添加 Azure Toolkit for IntelliJ IDEA 3.43.0。You can add the Azure Toolkit for IntelliJ IDEA 3.43.0 from the IntelliJ Plugins UI.

  1. 启动 IntelliJ。Start IntelliJ. 如果以前打开过某个项目,请关闭该项目以显示“欢迎”对话框。If you have opened a project previously, close the project to show the welcome dialog. 从右下方的链接中选择“配置”,然后单击“插件”以打开插件配置对话框,然后选择“从磁盘安装插件”。 Select Configure from link lower right, and then click Plugins to open the plug-in configuration dialog, and select Install Plugins from disk.

    选择“配置”

  2. 搜索“Azure Toolkit for IntelliJ”。Search for Azure Toolkit for IntelliJ. 单击“安装”。Click Install.

    安装插件

  3. 单击“重启 IDE”。Click Restart IDE.

教程过程Tutorial procedures

以下过程使用 IntelliJ IDEA 部署 Hello World 应用程序。The following procedures deploy a Hello World application using the IntelliJ IDEA.

  • 打开 gs-spring-boot 项目Open gs-spring-boot project
  • 部署到 Azure Spring CloudDeploy to Azure Spring Cloud
  • 显示流式处理日志Show streaming logs

打开 gs-spring-boot 项目Open gs-spring-boot project

  1. 下载本教程的源存储库并将其解压缩,或使用 Git: git clone https://github.com/spring-guides/gs-spring-boot.git 克隆它Download and unzip the source repository for this tutorial, or clone it using Git: git clone https://github.com/spring-guides/gs-spring-boot.git

  2. 通过 cd 命令进入 gs-spring-boot\complete。cd into gs-spring-boot\complete.

  3. 打开 IntelliJ 的“欢迎”对话框,选择“导入项目”以打开导入向导 。Open IntelliJ Welcome dialog, select Import Project to open the import wizard.

  4. 选择 gs-spring-boot\complete 文件夹。Select gs-spring-boot\complete folder.

    导入项目

部署到 Azure Spring CloudDeploy to Azure Spring Cloud

若要部署到 Azure,必须使用你的 Azure 帐户登录,然后选择你的订阅。In order to deploy to Azure you must sign-in with your Azure account, and choose your subscription. 有关登录的详细信息,请参阅安装和登录For sign-in details, see Installation and sign-in.

  1. 在 IntelliJ 项目资源管理器中右键单击你的项目,选择“Azure” -> “部署到 Azure Spring Cloud”。 Right-click your project in IntelliJ project explorer, and select Azure -> Deploy to Azure Spring Cloud.

    部署到 Azure 1

  2. 在“名称”字段中接受应用的名称。Accept the name for app in the Name field. “名称”是指配置,不是应用名称。Name refers to the configuration, not app name. 用户通常不需更改它。Users don't usually need to change it.

  3. 接受来自项目的标识符作为“生成工件”。Accept the identifier from the project for the Artifact.

  4. 选择“应用:”,然后单击“创建应用...”。 Select App: then click Create app....

    部署到 Azure 2

  5. 输入“应用名称”,然后单击“确定”。Enter App name , then click OK.

    部署到 Azure - 确定

  6. 单击“运行”按钮,开始部署。Start the deployment by clicking Run button.

    部署到 Azure 3

  7. 此插件会对项目运行命令 mvn package,然后创建新的应用并部署由 package 命令生成的 jar。The plug-in will run the command mvn package on the project and then create the new app and deploy the jar generated by the package command.

  8. 如果应用 URL 未显示在输出窗口中,请从 Azure 门户获取它。If the app URL is not shown in the output window, get it from the Azure portal. 从资源组导航到 Azure Spring Cloud 实例。Navigate from your resource group to the instance of Azure Spring Cloud. 然后单击“应用”。Then click Apps. 将会列出正在运行的应用。The running app will be listed.

    获取测试 URL

  9. 在浏览器中导航到该 URL。Navigate to the URL in browser.

    在浏览器中导航 2

显示流式处理日志Show streaming logs

若要获取日志,请执行以下操作:To get the logs:

  1. 选择“Azure 资源管理器”,然后选择“Spring Cloud”。Select Azure Explorer , then Spring Cloud.

  2. 右键单击正在运行的应用。Right-click the running app.

  3. 从下拉列表中选择“流式处理日志”。Select Streaming Logs from the drop-down list.

    选择流式处理日志

  4. 选择实例。Select instance.

    选择实例

  5. 流式处理日志将显示在输出窗口中。The streaming log will be visible in the output window.

    流式处理日志输出

后续步骤Next steps