使用 ARM 模板和 Azure 门户部署资源Deploy resources with ARM templates and Azure portal

了解如何将 Azure 门户Azure 资源管理器模板(ARM 模板)配合使用来部署 Azure 资源。Learn how to use the Azure portal with Azure Resource Manager templates (ARM templates) to deploy your Azure resources. 若要了解有关管理资源的信息,请参阅通过 Azure 门户管理 Azure 资源To learn about managing your resources, see Manage Azure resources by using the Azure portal.

使用 Azure 门户部署 Azure 资源通常涉及两个步骤:Deploying Azure resources by using the Azure portal usually involves two steps:

  • 创建资源组。Create a resource group.
  • 将资源部署到资源组。Deploy resources to the resource group.

此外,还可以创建自定义 ARM 模板来部署 Azure 资源。Also, you can create a customized ARM template to deploy Azure resources.

本文介绍了这两种方法。This article shows both methods.

创建资源组Create a resource group

  1. 若要创建新资源组,请从 Azure 门户中选择“资源组”。To create a new resource group, select Resource groups from the Azure portal.


  2. 在“资源组”下,选择“添加”。Under Resource groups, select Add.


  3. 选择或输入以下属性值:Select or enter the following property values:

    • 订阅:选择 Azure 订阅。Subscription: Select an Azure subscription.

    • 资源组:为资源组指定名称。Resource group: Give the resource group a name.

    • 区域:指定 Azure 位置。Region: Specify an Azure location. 资源组在该位置存储有关资源的元数据。This location is where the resource group stores metadata about the resources. 出于合规性原因,你可能会想要指定该元数据的存储位置。For compliance reasons, you may want to specify where that metadata is stored. 一般情况下,建议指定大部分资源所在的位置。In general, we recommend that you specify a location where most of your resources will be. 使用相同位置可简化模板。Using the same location can simplify your template.


  4. 选择“查看 + 创建”。Select Review + create.

  5. 查看值,然后选择“创建”。Review the values, and then select Create.

  6. 选择“刷新”,然后才能在列表中看到新资源组。Select Refresh before you can see the new resource group in the list.

将资源部署到资源组Deploy resources to a resource group

创建资源组后,可以从市场将资源部署到该组。After you create a resource group, you can deploy resources to the group from the Marketplace. 市场为常见方案提供预定义的解决方案。The Marketplace provides pre-defined solutions for common scenarios.

  1. 若要开始部署,请从 Azure 门户中选择“创建资源”。To start a deployment, select Create a resource from the Azure portal.


  2. 查找希望部署的资源类型。Find the type of resource you would like to deploy. 资源将按类别进行组织。The resources are organized in categories. 如果看不到想要部署的特定解决方案,可以在市场中搜索。If you don't see the particular solution you would like to deploy, you can search the Marketplace for it. 以下屏幕截图显示已选择“Ubuntu Server”。The following screenshot shows that Ubuntu Server is selected.


  3. 根据所选资源的类型,需要在部署之前设置相关属性的集合。Depending on the type of selected resource, you have a collection of relevant properties to set before deployment. 对于所有类型,必须选择目标资源组。For all types, you must select a destination resource group. 下图显示了如何创建 Linux 虚拟机并将其部署到所创建的资源组。The following image shows how to create a Linux virtual machine and deploy it to the resource group you created.


    可以在部署资源时创建资源组。You can decide to create a resource group when deploying your resources. 选择“新建” 并为资源组指定名称。Select Create new and give the resource group a name.

  4. 部署开始。Your deployment begins. 部署可能需要几分钟的时间。The deployment could take several minutes. 有些资源比其他资源需要更长的时间。Some resources take longer time than other resources. 完成部署后,会看到一条通知。When the deployment has finished, you see a notification. 选择“转到资源”以将其打开Select Go to resource to open


  5. 部署资源后,可以通过选择“添加”将更多资源添加到资源组。After deploying your resources, you can add more resources to the resource group by selecting Add.


虽然你没有看到,但门户使用了一个 ARM 模板来部署所选资源。Although you didn't see it, the portal used an ARM template to deploy the resources you selected. 可以从部署历史记录中找到该模板。You can find the template from the deployment history. 有关详细信息,请参阅在部署之后导出模板For more information, see Export template after deployment.

从自定义模板部署资源Deploy resources from custom template

如果想要执行部署,但不使用市场中的任何模板,可以创建自定义模板来针对解决方案定义基础结构。If you want to execute a deployment but not use any of the templates in the Marketplace, you can create a customized template that defines the infrastructure for your solution. 若要了解如何创建模板,请参阅了解 ARM 模板的结构和语法To learn about creating templates, see Understand the structure and syntax of ARM templates.


门户界面不支持引用来自 Key Vault 的密码The portal interface doesn't support referencing a secret from a Key Vault. 请改用 PowerShellAzure CLI,从本地或从外部 URI 部署模板。Instead, use PowerShell or Azure CLI to deploy your template locally or from an external URI.

  1. 若要通过门户部署自定义模板,请选择“创建资源”,搜索“模板”,To deploy a customized template through the portal, select Create a resource, search for template. 然后选择“模板部署”。and then select Template deployment.


  2. 选择“创建” 。Select Create.

  3. 此时,会看到用于创建模板的几个选项:You see several options for creating a template:

    • 在编辑器中生成自己的模板:在门户模板编辑器中创建自己的模板。Build your own template in editor: Create your own template in the portal template editor.

    • 常用模板:从常见解决方案中进行选择。Common templates: Select from common solutions.

    • 加载 GitHub 快速启动模板:从快速启动模板中进行选择。Load a GitHub quickstart template: Select from quickstart templates.


    本教程提供了加载快速入门模板的说明。This tutorial provides the instruction for loading a quickstart template.

  4. 在“加载 GitHub 快速入门模板”下,键入或选择 101-storage-account-createUnder Load a GitHub quickstart template, type or select 101-storage-account-create.

    可以使用两个选项:You have two options:

    • 选择模板:部署模板。Select template: deploy the template.
    • 编辑模板:在部署快速入门模板之前对其进行编辑。Edit template: edit the quickstart template before you deploy it.
  5. 选择“编辑模板”,浏览门户模板编辑器。Select Edit template to explore the portal template editor. 模板会加载到编辑器中。The template is loaded in the editor. 请注意,有两个参数:storageAccountTypelocationNotice there are two parameters: storageAccountType and location.


  6. 对模板进行小的更改。Make a minor change to the template. 例如,将 storageAccountName 变量更新为:For example, update the storageAccountName variable to:

    "storageAccountName": "[concat('azstore', uniquestring(resourceGroup().id))]"
  7. 选择“保存” 。Select Save. 现在会看到门户模板部署界面。Now you see the portal template deployment interface. 请注意在模板中定义的两个参数。Notice the two parameters that you defined in the template.

  8. 输入或选择属性值:Enter or select the property values:

    • 订阅:选择 Azure 订阅。Subscription: Select an Azure subscription.
    • 资源组:选择“新建”并指定名称。Resource group: Select Create new and give a name.
    • 位置:选择 Azure 位置。Location: Select an Azure location.
    • 存储帐户类型:使用默认值。Storage Account Type: Use the default value. 在门户上显示时,模板中定义的驼峰式大小写参数名称 storageAccountType 将转换为以空格分隔的字符串。The camel-cased parameter name, storageAccountType, defined in the template is turned into a space-separated string when displayed on the portal.
    • 位置:使用默认值。Location: Use the default value.
    • 我同意上述条款和条件:(选中)I agree to the terms and conditions stated above: (select)
  9. 选择“购买”。Select Purchase.

后续步骤Next steps