az image builder
管理和生成映像生成器模板。
命令
az image builder cancel
根据映像模板取消长时间运行的映像生成。
az image builder cancel [--ids]
[--name]
[--resource-group]
[--subscription]
示例
取消映像生成。
az image builder cancel -n mytemplate -g my-group
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
映像模板的名称。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az image builder create
创建映像生成器模板。
az image builder create --name
--resource-group
[--build-timeout]
[--build-vm-identities]
[--checksum]
[--defer]
[--identity]
[--image-source]
[--image-template]
[--location]
[--managed-image-destinations]
[--no-wait]
[--os-disk-size]
[--proxy-vm-size]
[--scripts]
[--shared-image-destinations]
[--staging-resource-group]
[--subnet]
[--tags]
[--validator]
[--vm-size]
[--vnet]
示例
从 Ubuntu2204 映像创建映像生成器模板。 将其分发为托管映像和共享映像库映像版本。 将过渡资源组 ID 指定为将用于生成映像的映像模板。
scripts="https://my-script-url.net/customize_script.sh"
imagesource="Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:latest"
az image builder create --image-source $imagesource -n myTemplate -g myGroup \
--scripts $scripts --managed-image-destinations image_1=westus \
--shared-image-destinations my_shared_gallery/linux_image_def=westus,brazilsouth \
--identity myIdentity --staging-resource-group myStagingResourceGroup
使用映像模板文件创建映像生成器模板。
az image builder create -g my-group -n myTemplate --image-template filename
[高级]使用 CLI 的对象缓存通过 --defer 创建包含多个定制器和分发服务器的图像模板。 支持以下功能:定制器和输出名称、powershell 退出代码、内联脚本、windows 重启、文件定制器、项目标记和 vhd 输出分发服务器。
script="https://my-script-url.com/customize_script.ps1"
imagesource="MicrosoftWindowsServer:WindowsServer:2019-Datacenter:2019.0.20190214"
# create and update template object in local cli cache. Defers put request to ARM
# Cache object ttl set via az configure.
az image builder create --image-source $imagesource -n myTemplate \
-g myGroup --scripts $script --identity myIdentity --defer
# add customizers
az image builder customizer add -n myTemplate -g myGroup \
--customizer-name myPwshScript --exit-codes 0 1 --inline-script \
"mkdir c:\buildActions" "echo Azure-Image-Builder-Was-Here \
> c:\buildActions\Output.txt" --type powershell --defer
az image builder customizer add -n myTemplate -g myGroup \
--customizer-name myFileCustomizer --type file \
--file-source "https://my-file-source.net/file.txt" \
--dest-path "c:\buildArtifacts\file.txt" --defer
# add distributors
az image builder output add -n myTemplate -g myGroup --is-vhd \
--output-name myWinImageVhd --artifact-tags "is_vhd=True" --defer
az image builder output add -n myTemplate -g myGroup \
--output-name myWinImageManaged --managed-image winImage \
--managed-image-location eastus \
--artifact-tags "is_vhd=False" --defer
# Stop deferring put request to ARM. Create the template from the object cache.
# Cache object will be deleted.
az image builder update -n myTemplate -g myGroup
必需参数
映像模板的名称。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
生成映像模板时等待的最大持续时间(以分钟为单位)。 默认值为 60。
用于在其中部署生成虚拟机的虚拟网络的可选配置。 如果不需要使用任何特定的虚拟网络,则省略。
Red Hat ISO 映像的 SHA256 校验和。
属性 | 值 |
---|---|
Parameter group: | Image Source Arguments |
暂时将对象存储在本地缓存中,而不是发送到 Azure。 使用 az cache
命令查看/清除。
用户分配的标识(名称或 ID、分隔空格)图像模板的列表。
要自定义的基本映像。 必须是有效的平台映像 URN、平台映像别名、Red Hat ISO 映像 URI、托管映像名称/ID 或共享映像版本 ID。
属性 | 值 |
---|---|
Parameter group: | Image Source Arguments |
值来源: | az vm image list, az vm image show |
图像模板文件的本地路径或 URL。 使用 --image-template 时,除 -g 和 -n 之外,将忽略所有其他参数。 引用: https://learn.microsoft.com/azure/virtual-machines/linux/image-builder-json。
Location.
az account list-locations
中的值。 可以使用 az configure --defaults location=<location>
配置默认位置。
托管映像输出分发服务器信息。 键值对的空间分隔列表。 例如“image_1=westus2 image_2=westus”。 每个密钥都是要创建的托管映像的名称或资源 ID。 每个值都是图像的位置。
属性 | 值 |
---|---|
Parameter group: | Output Arguments |
不等待长时间运行的操作完成。
属性 | 值 |
---|---|
默认值: | False |
OS 磁盘的大小(以 GB 为单位)。 省略或指定 0 以使用 Azure 的默认 OS 磁盘大小。
用于生成、自定义和捕获映像的虚拟机的大小(第 1 代映像Standard_D1_v2,第 2 代映像Standard_D2ds_v4)。
用于自定义映像的 shell 或 powershell 脚本的空间分隔列表。 每个脚本必须是可公开访问的 URL。 从文件扩展名(“.sh”或“.ps1”)或源类型推断脚本的类型。 更多定制器选项和灵活性,请参阅:“az image template customizer add”。
属性 | 值 |
---|---|
Parameter group: | Customizer Arguments |
共享映像库 (sig) 输出分发服务器信息。 键值对的空间分隔列表。 例如“my_gallery_1/image_def_1=eastus,westus my_gallery_2/image_def_2=uksouth,canadaeast,francesouth”。每个键都是由“/”分隔的 sig 映像定义 ID 或 sig 库名称和 sig 映像定义。 每个值都是以逗号分隔的副本位置列表。
属性 | 值 |
---|---|
Parameter group: | Output Arguments |
与用于生成映像的映像模板相同的订阅中的暂存资源组 ID。
要部署生成虚拟机的子网的名称或 ID。
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。
要在映像上使用的验证类型。 例如,“Shell”可以是 shell 验证。
用于生成、自定义和捕获映像的虚拟机的大小。 省略或指定空字符串以使用默认值(Standard_D1_v2)。
要部署生成虚拟机的 VNET 的名称。 仅当子网是名称时,才应指定它。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az image builder delete
删除映像生成器模板。
az image builder delete [--ids]
[--name]
[--resource-group]
[--subscription]
示例
删除映像生成器模板。 (autogenerated)
az image builder delete --name MyImageTemplate --resource-group MyResourceGroup
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
映像模板的名称。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az image builder list
列出映像生成器模板。
az image builder list [--resource-group]
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az image builder run
生成映像生成器模板。
az image builder run [--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
示例
启动模板生成运行,然后等待它完成。
az image builder run -n mytemplate -g my-group --no-wait
az image builder wait -n mytemplate -g aibmdi \
--custom "lastRunStatus.runState!='Running'"
az image builder show -n mytemplate -g my-group
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
映像模板的名称。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
不等待长时间运行的操作完成。
属性 | 值 |
---|---|
默认值: | False |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az image builder show
显示映像生成器模板。
az image builder show [--ids]
[--name]
[--resource-group]
[--subscription]
示例
显示映像生成器模板(自动生成)
az image builder show --name mytemplate --resource-group my-group
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
映像模板的名称。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az image builder show-runs
显示映像生成器模板的运行输出。
az image builder show-runs [--ids]
[--name]
[--output-name]
[--resource-group]
[--subscription]
示例
运行模板生成运行,然后查看其运行输出。
az image builder run -n mytemplate -g my-group --no-wait
az image builder wait -n mytemplate -g aibmdi \
--custom "lastRunStatus.runState!='Running'"
az image builder show-runs -n mytemplate -g my-group
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
映像模板的名称。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
映像生成器运行输出的名称。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az image builder update
更新映像生成器模板。
当前不支持更新映像生成器模板。 此命令可与 --defer 结合使用来更新 CLI 缓存中的映像模板对象。 如果不延迟,它将从缓存中检索指定的映像模板,并将请求发送到 Azure 以创建映像模板。
az image builder update [--add]
[--defer]
[--force-string]
[--ids]
[--name]
[--remove]
[--resource-group]
[--set]
[--subscription]
示例
从 cli 缓存中的模板对象创建模板资源。 有关详细信息,请参阅“az image builder create/ output add / customizer add --help”和“az cache -h”
# create and write template object to local cli cache
az image builder create --image-source {image_source} -n mytemplate -g my-group \
--scripts {script} --managed-image-destinations image_1=westus --identity myidentity --defer
# add customizers and outputs to local cache template object via az image template output / customizer add
# one can also update cache object properties through generic update options, such as: --set
az image builder output add -n mytemplate -g my-group --output-name my-win-image-managed \
--artifact-tags "is_vhd=False" --managed-image winImage --managed-image-location eastus --defer
# send template create request to azure to create template resource
az image builder update -n mytemplate -g my-group
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
通过指定路径和键值对将对象添加到对象列表。 示例:--add property.listProperty <key=value, string or JSON string>
。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
暂时将对象存储在本地缓存中,而不是发送到 Azure。 使用 az cache
命令查看/清除。
使用“set”或“add”时,保留字符串文本,而不是尝试转换为 JSON。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | False |
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
映像模板的名称。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
从列表中删除属性或元素。 示例: --remove property.list <indexToRemove>
OR --remove propertyToRemove
.
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
通过指定要设置的属性路径和值来更新对象。 示例:--set property1.property2=<value>
。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az image builder wait
将 CLI 置于等待状态,直到满足模板的条件。
az image builder wait [--created]
[--custom]
[--deleted]
[--exists]
[--ids]
[--interval]
[--name]
[--resource-group]
[--subscription]
[--timeout]
[--updated]
示例
启动模板生成运行,然后等待它完成。
az image builder run -n mytemplate -g my-group --no-wait
az image builder wait -n mytemplate -g aibmdi \
--custom "lastRunStatus.runState!='Running'"
az image builder show -n mytemplate -g my-group
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
等待在“Succeeded”中使用“provisioningState”创建。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | False |
等待条件满足自定义 JMESPath 查询。 例如 provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running']。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
等到删除为止。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | False |
等待资源存在。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | False |
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
轮询间隔(以秒为单位)。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | 30 |
映像模板的名称。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
最大等待(以秒为单位)。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | 3600 |
等到 provisioningState 更新为“Succeeded”。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | False |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |