快速入门:使用 IntelliJ IDEA 创建和部署 Azure 资源管理器模板Quickstart: Create and deploy Azure Resource Manager templates by using the IntelliJ IDEA

了解如何使用 IntelliJ IDEA 将资源管理器模板部署到 Azure,以及如何直接从 IDE 编辑和更新该模板。Learn how to deploy a Resource Manager template to Azure using the IntelliJ IDEA, and the process of editing and update the template directly from the IDE. Resource Manager 模板为 JSON 文件,用于定义针对解决方案进行部署时所需的资源。Resource Manager templates are JSON files that define the resources you need to deploy for your solution. 若要了解与部署和管理 Azure 解决方案相关联的概念,请参阅 Azure Resource Manager 概述To understand the concepts associated with deploying and managing your Azure solutions, see Azure Resource Manager overview.

资源管理器模板快速入门门户图

完成本教程后,部署 Azure 存储帐户。After completing the tutorial, you deploy an Azure Storage account. 可以通过同一过程来部署其他 Azure 资源。The same process can be used to deploy other Azure resources.

如果没有 Azure 订阅,请在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.

先决条件Prerequisites

若要完成本文,需要做好以下准备:To complete this article, you need:

部署快速入门模板Deploy a Quickstart template

无需从头开始创建模板,可以通过 Azure 快速入门模板打开一个模板。Instead of creating a template from scratch, you open a template from Azure Quickstart Templates. Azure 快速入门模板是资源管理器模板的存储库。Azure Quickstart Templates is a repository for Resource Manager templates. 本快速入门中使用的模板称为创建标准存储帐户The template used in this quickstart is called Create a standard storage account. 该模板定义 Azure 存储帐户资源。It defines an Azure Storage account resource.

  1. 单击右键并将 azuredeploy.jsonazuredeploy.parameters.json 保存到本地计算机。Right-click and save the azuredeploy.json and azuredeploy.parameters.json to your local computer.

  2. 如果你已正确安装 Azure 工具包并已登录,IntelliJ IDEA 的侧栏中应会显示 Azure 资源管理器。If your Azure Toolkit are properly installed and signed-in, you should see Azure Explorer in your IntelliJ IDEA's sidebar. 右键单击“资源管理”并选择“创建部署”。 Right-click on the Resource Management and select Create Deployment.

    资源管理器模板 - 右键单击以创建部署

  3. 配置“部署名称”、“订阅”、“资源组”和“区域”。 Config your Deployment Name, Subscription, Resource Group, and Region. 此处,我们要将模板部署到新资源组 testRGHere we deploy the template into a new resource group testRG. 然后,选择 azuredeploy.json 作为资源模板的路径,并选择下载的 azuredeploy.parameters.json 作为资源参数Then, select path for Resource Template as azuredeploy.json and Resource Parameters as azuredeploy.parameters.json you downloaded.

    资源管理器模板 - 选择用于创建部署的文件

  4. 单击“确定”后,将启动部署。After you click OK, the deployment is started. 在部署完成之前,可以在底部的 IntelliJ IDEA 状态栏中查看进度。Until the deployment complete, you can find the progress from IntelliJ IDEA's status bar on the bottom.

    资源管理器模板部署状态

浏览现有部署Browse an existing deployment

  1. 部署完成后,可以看到新资源组 testRG 以及新建的部署。After the deployment is done, you can see the new resource group testRG and a new deployment created. 右键单击该部署可以看到可能的操作列表。Right-click on the deployment and you can see a list of possible actions. 现在请选择“显示属性”。 Now select Show Properties.

    资源管理器模板 - 浏览部署

  2. 此时会打开一个选项卡视图,其中显示了一些有用的属性,例如部署状态和模板结构。A tab view will be open to show some useful properties like deployment status and template structure.

    资源管理器模板 - 显示部署属性

编辑和更新现有部署Edit and update an existing deployment

  1. 从右键单击菜单或前面所示的“显示属性”视图中选择“编辑部署”。 Select Edit Deployment from right-click menu or the show properties view before. 此时会打开另一个选项卡视图,其中显示了 Azure 上的部署的模板和参数文件。Another tab view will be open, showing the template and parameter files for the deployment on Azure. 若要将这些文件保存到本地,可以单击“导出模板文件”或“导出参数文件”。 To save those files to local, you could click Export Template File or Export Parameter Files.

    资源管理器模板 - 编辑部署

  2. 可在此页上编辑这两个文件,并将更改部署到 Azure。You can edit the two files on this page and deploy the changes to Azure. 此处,我们将参数文件中 storageAccountType 的值从 Standard_LRS 更改为 Standard_GRSHere we modify the value of storageAccountType in parameter files, from Standard_LRS to Standard_GRS. 然后,单击底部的“更新部署”并确认更新。 Then, click Update Deployment on the bottom and confirm the update.

    资源管理器模板 - 编辑部署

  3. 完成更新部署后,可在门户中检查创建的存储帐户是否已更改为 Standard_GRSAfter update deployment completed, you can verify on the portal that the created storage account is changed to Standard_GRS.

清理资源Clean up resources

  1. 不再需要 Azure 资源时,请通过删除资源组来清理部署的资源。When the Azure resources are no longer needed, clean up the resources you deployed by deleting the resource group. 可在 Azure 门户或 Azure CLI 中执行此操作。You can do it from Azure portal or Azure CLI. 在 IntelliJ IDEA 的 Azure 资源管理器中,右键单击创建的资源组并选择“删除”。In Azure Explorer from IntelliJ IDEA, right click on your created resource group and select delete.

    从 IntelliJ IDEA 的 Azure 资源管理器中删除资源组

Note

请注意,删除某个部署不会删除该部署创建的资源。Notice that delete a deployment will not delete resources created by the deployment. 如果不再需要相应的资源组或特定资源,请将其删除。Please delete corresponding resource group or specific resources if you no longer need them.

后续步骤Next steps

本快速入门重点介绍了如何使用 IntelliJ IDEA 来部署 Azure 快速入门模板中的现有模板。The main focus of this quickstart is to use IntelliJ IDEA to deploy an existing template from Azure Quickstart templates. 此外,介绍了如何查看和更新 Azure 上的现有部署。You also learned how to view and update an existing deployment on Azure. Azure 快速入门模板中的模板可能并未提供你所需的一切。The templates from Azure Quickstart templates might not give you everything you need. 若要详细了解模板开发,请参阅新的初学者教程系列:To learn more about template development, see our new beginner tutorial series: