发现资源属性Discover resource properties

创建资源管理器模板之前,需要了解有哪些资源类型可用以及要在模板中使用哪些值。Before creating Resource Manager templates, you need to understand what resource types are available, and what values to use in your template. 本文介绍了一些可用于查找要在模板中包含的属性的方法。This article shows some ways you can find the properties to include in your template.

查找资源提供程序命名空间Find resource provider namespaces

ARM 模板中的资源是使用资源提供程序命名空间和资源类型来定义的。Resources in an ARM template are defined with a resource provider namespace and resource type. 例如,Microsoft.Storage/storageAccounts 是存储帐户资源类型的完整名称。For example, Microsoft.Storage/storageAccounts is the full name of the storage account resource type. Microsoft.Storage 是命名空间。Microsoft.Storage is the namespace. 如果你还不知道要使用的资源类型的命名空间,请参阅 Azure 服务的资源提供程序If you don't already know the namespaces for the resource types you want to use, see Resource providers for Azure services.

资源管理器资源提供程序命名空间映射

导出模板Export templates

为现有资源获取模板属性的最简单方法就是导出模板。The easiest way to get the template properties for your existing resources is to export the template. 有关详细信息,请参阅在 Azure 门户中将单个资源和多个资源导出到模板For more information, see Single and multi-resource export to a template in the Azure portal.

使用资源管理器工具扩展Use Resource Manager tools extension

Visual Studio Code 和 Azure 资源管理器工具扩展有助于确切了解每种资源类型需要哪些属性。Visual Studio Code and the Azure Resource Manager tools extension help you see exactly which properties are needed for each resource type. 它们提供 Intellisense 和代码片段,可简化在模板中定义资源的过程。They provide intellisense and snippets that simplify how you define a resource in your template. 有关详细信息,请参阅快速入门:使用 Visual Studio Code 创建 Azure 资源管理器模板For more information, see Quickstart: Create Azure Resource Manager templates with Visual Studio Code.

以下屏幕截图显示了如何将存储帐户资源添加到模板:The following screenshot shows a storage account resource is added to a template:

资源管理器资源提供程序命名空间映射

该扩展还提供了用于配置属性的选项列表。The extension also provides a list of options for the configuration properties.

资源管理器资源提供程序命名空间映射

使用资源浏览器Use Resource Explorer

资源浏览器是嵌入在 Azure 门户中的。Resource Explorer is embedded in the Azure portal. 在使用此方法之前,需要先有一个存储帐户。Before using this method, you need a storage account. 如果还没有,请选择以下按钮来创建一个:If you don't have one, select the following button to create one:

“部署到 Azure”Deploy to Azure

  1. 登录到 Azure 门户Sign in to the Azure portal.

  2. 在搜索框中,输入“资源浏览器”,然后选择“资源浏览器”。In the search box, enter resource explorer, and then select Resource Explorer.

    资源管理器资源提供程序命名空间映射

  3. 从左侧展开“订阅”,然后展开你的 Azure 订阅。From left, expand Subscriptions, and then expand your Azure subscription. 在“提供程序”或“ResourceGroups”下可找到存储帐户。You can find the storage account under either Providers or ResourceGroups.

    资源管理器资源提供程序命名空间映射

    • 提供程序:展开“提供程序” -> “Microsoft.Storage” -> “storageAccounts”,然后选择你的存储帐户。Providers: expand Providers -> Microsoft.Storage -> storageAccounts, and then select your storage account.
    • ResourceGroups:选择包含该存储帐户的资源组,选择“资源”,然后选择该存储帐户。ResourceGroups: select the resource group, which contains the storage account, select Resources, and then select the storage account.

    在右侧,可以看到现有存储帐户的 SKU 配置,如下所示:On the right, you see the SKU configuration for the existing storage account similar to:

    资源管理器资源提供程序命名空间映射

后续步骤Next steps

本文介绍了如何查找模板架构信息。In this article, you learned how to find template schema information. 若要详细了解如何创建资源管理器模板,请参阅了解 ARM 模板的结构和语法To learn more about creating Resource Manager templates, see Understand the structure and syntax of ARM templates.