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

az image builder customizer

管理映像生成器模板定制器。

命令

名称 说明 类型 Status
az image builder customizer add

将映像生成器定制器添加到映像生成器模板。

核心 GA
az image builder customizer clear

从映像生成器模板中删除所有映像生成器自定义工具。

核心 GA
az image builder customizer remove

从映像生成器模板中删除映像生成器定制器。

核心 GA

az image builder customizer add

将映像生成器定制器添加到映像生成器模板。

必须与 --defer 一起使用。

az image builder customizer add --customizer-name
                                --type {file, powershell, shell, windows-restart, windows-update}
                                [--defer]
                                [--dest-path]
                                [--exit-codes]
                                [--file-source]
                                [--filters]
                                [--ids]
                                [--inline-script]
                                [--name]
                                [--resource-group]
                                [--restart-check-command]
                                [--restart-command]
                                [--restart-timeout]
                                [--script-url]
                                [--search-criteria]
                                [--subscription]
                                [--update-limit]

示例

将内联 shell 定制器添加到 cli 对象缓存中的图像模板

az image builder customizer add -n myTemplate -g myGroup \
    --inline-script "sudo mkdir /buildArtifacts" \
                    "sudo cp /tmp/index.html /buildArtifacts/index.html" \
    --customizer-name shellScriptInline --type shell --defer

将文件定制器添加到 cli 对象缓存中的映像模板

az image builder customizer add -n myTemplate -g myGroup \
    --customizer-name myFile --type file \
    --file-source "https://my-remote-file.html" --dest-path "/tmp/index.html" --defer

将 Windows 重启定制器添加到 cli 对象缓存中的映像模板

az image builder customizer add -n myTemplate -g myGroup \
--customizer-name shellScriptUrl \
--restart-check-command "echo Azure-Image-Builder-Restarted-the-VM  > \
                        c:\buildArtifacts\restart.txt" \
    --type windows-restart --restart-timeout 10m --defer

将 Windows 更新定制器添加到 cli 对象缓存中的映像模板。

az image builder customizer add -n myTemplate -g myGroup --customizer-name winUpdate --type windows-update --search-criteria IsInstalled=0 --filters "exclude:\$_.Title -like \'*Preview*\'" "include:\$true" --update-limit 20 --defer

必需参数

--customizer-name

定制器的名称。

--type -t

要添加到映像模板的定制器类型。

接受的值: file, powershell, shell, windows-restart, windows-update

可选参数

--defer

暂时将对象存储在本地缓存中,而不是发送到 Azure。 使用 az cache 命令查看/清除。

--dest-path

文件在 --file-source 中指定的绝对目标路径将下载到映像中。

--exit-codes -e

以整数形式分隔的有效退出代码的空格分隔列表。

--file-source

要下载到映像中的文件的 URI。 它可以是 github 链接、用于Azure 存储的 SAS URI 等。

--filters

用空格分隔的筛选器选择要应用的更新。 省略或指定空数组以使用默认值(无筛选器)。

--ids

一个或多个资源 ID(空格分隔)。 它应该是包含“资源 ID”参数的所有信息的完整资源 ID。 应提供 --id 或其他“资源 ID”参数。

--inline-script

用于自定义图像的内联脚本行的空间分隔列表。

--name -n

映像模板的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--restart-check-command

用于验证重启是否成功的命令。

--restart-command

用于执行重启操作的命令。

--restart-timeout

指定为包含数量级和单位的字符串(例如“5m”(5 分钟)或“2 小时”(2 小时)的重启超时。

默认值: 5m
--script-url

用于自定义映像的脚本 URL。 URL 必须可公开访问。

--search-criteria

搜索更新的条件。 省略或指定空字符串以使用默认值(全部搜索)。 有关此字段的示例和详细说明,请参阅上面的链接。

--subscription

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

--update-limit

一次应用的最大更新数。 省略或指定 0 以使用默认值 (1000)。

全局参数
--debug

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

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

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

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

--subscription

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

--verbose

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

az image builder customizer clear

从映像生成器模板中删除所有映像生成器自定义工具。

必须与 --defer 一起使用。

az image builder customizer clear [--defer]
                                  [--ids]
                                  [--name]
                                  [--resource-group]
                                  [--subscription]

可选参数

--defer

暂时将对象存储在本地缓存中,而不是发送到 Azure。 使用 az cache 命令查看/清除。

--ids

一个或多个资源 ID(空格分隔)。 它应该是包含“资源 ID”参数的所有信息的完整资源 ID。 应提供 --id 或其他“资源 ID”参数。

--name -n

映像模板的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--subscription

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

全局参数
--debug

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

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

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

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

--subscription

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

--verbose

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

az image builder customizer remove

从映像生成器模板中删除映像生成器定制器。

必须与 --defer 一起使用。

az image builder customizer remove --customizer-name
                                   [--defer]
                                   [--ids]
                                   [--name]
                                   [--resource-group]
                                   [--subscription]

必需参数

--customizer-name

定制器的名称。

可选参数

--defer

暂时将对象存储在本地缓存中,而不是发送到 Azure。 使用 az cache 命令查看/清除。

--ids

一个或多个资源 ID(空格分隔)。 它应该是包含“资源 ID”参数的所有信息的完整资源 ID。 应提供 --id 或其他“资源 ID”参数。

--name -n

映像模板的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--subscription

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

全局参数
--debug

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

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

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

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

--subscription

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

--verbose

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