你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az terraform

Note

此参考是 Azure CLI 的 terraform 扩展的一部分(版本 2.61.0 或更高版本)。 该扩展将在首次运行 az terraform 命令时自动安装。 了解更多关于扩展的信息。

此命令组处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus

Azure Terraform 体验。

命令

名称 说明 类型 Status
az terraform export-terraform

导出指定资源的 Terraform 配置。

Extension Preview

az terraform export-terraform

预览

命令组“az terraform”处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus

导出指定资源的 Terraform 配置。

az terraform export-terraform [--export-query]
                              [--export-resource]
                              [--export-resource-group]
                              [--full-properties {0, 1, f, false, n, no, t, true, y, yes}]
                              [--mask-sensitive {0, 1, f, false, n, no, t, true, y, yes}]
                              [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                              [--target-provider {azapi, azurerm}]

示例

将目标为“azurerm”提供程序的资源组导出

az terraform export-terraform --export-resource-group '{resource-group-name:my-rg}'

将目标为“azapi”提供程序的资源列表

az terraform export-terraform --full-properties false --target-provider azapi --export-resource '{resource-ids:[id1,id2,id3]}'

导出当前订阅中的所有虚拟网络及其子资源(例如子网)以“azapi”提供程序为目标

az terraform export-terraform --full-properties false --target-provider azapi --export-query "{query:'type =~ \"microsoft.network/virtualnetworks\"',recursive:true}"

可选参数

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--export-query

ARG(Azure Resource Graph)查询的资源的导出参数。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。

属性
Parameter group: ExportParameter Arguments
--export-resource

导出单个资源的参数。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。

属性
Parameter group: ExportParameter Arguments
--export-resource-group

导出资源组的参数。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。

属性
Parameter group: ExportParameter Arguments
--full-properties

是否输出生成的 Terraform 配置中的所有非计算属性? 这可能需要手动修改才能使其有效。

属性
Parameter group: ExportParameter Arguments
默认值: True
接受的值: 0, 1, f, false, n, no, t, true, y, yes
--mask-sensitive

在 Terraform 配置中屏蔽敏感属性。

属性
Parameter group: ExportParameter Arguments
默认值: True
接受的值: 0, 1, f, false, n, no, t, true, y, yes
--no-wait

不等待长时间运行的操作完成。

属性
接受的值: 0, 1, f, false, n, no, t, true, y, yes
--target-provider

目标 Azure Terraform 提供程序。

属性
Parameter group: ExportParameter Arguments
默认值: azurerm
接受的值: azapi, azurerm
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

仅显示错误,禁止显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

增加日志记录详细程度。 使用 --debug 获取完整的调试日志。

属性
默认值: False