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

az image

注意

此命令组具有在 Azure CLI 和至少一个扩展中定义的命令。 安装每个扩展,使其受益于其扩展功能。 详细了解扩展。

管理自定义虚拟机映像。

命令

名称 说明 类型 状态
az image builder

管理和生成映像生成器模板。

核心 GA
az image builder cancel

根据映像模板取消长时间运行的映像生成。

核心 GA
az image builder create

创建映像生成器模板。

核心 GA
az image builder customizer

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

核心 GA
az image builder customizer add

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

核心 GA
az image builder customizer clear

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

核心 GA
az image builder customizer remove

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

核心 GA
az image builder delete

删除映像生成器模板。

核心 GA
az image builder error-handler

管理映像生成器模板错误处理程序。

核心 GA
az image builder error-handler add

将错误处理程序添加到现有映像生成器模板。

核心 GA
az image builder error-handler remove

从现有映像生成器模板中删除错误处理程序。

核心 GA
az image builder error-handler show

显示现有映像生成器模板的错误处理程序。

核心 GA
az image builder identity

管理映像生成器模板的标识。

核心 GA
az image builder identity assign

将托管标识添加到现有映像生成器模板。 目前,仅支持一个用户标识。

核心 GA
az image builder identity remove

从现有映像生成器模板中删除托管标识。

核心 GA
az image builder identity show

显示映像生成器模板的托管标识。

核心 GA
az image builder list

列出映像生成器模板。

核心 GA
az image builder optimizer

管理映像生成器模板优化器。

核心 GA
az image builder optimizer add

将优化器添加到现有映像生成器模板。

核心 GA
az image builder optimizer remove

从现有映像生成器模板中删除优化器。

核心 GA
az image builder optimizer show

显示现有映像生成器模板的优化器。

核心 GA
az image builder optimizer update

从现有映像生成器模板更新优化器。

核心 GA
az image builder output

管理映像生成器模板输出分发服务器。

核心 GA
az image builder output add

将映像生成器输出分发服务器添加到映像生成器模板。

核心 GA
az image builder output clear

从映像生成器模板中删除所有映像生成器输出分发服务器。

核心 GA
az image builder output remove

从映像生成器模板中删除映像生成器输出分发服务器。

核心 GA
az image builder output versioning

管理映像生成器模板输出版本器。

核心 GA
az image builder output versioning remove

删除指定输出上的所有版本控制选项。

核心 GA
az image builder output versioning set

设置映像生成器模板的映像生成器输出版本器。

核心 GA
az image builder output versioning show

显示指定输出上的版本控制选项。

核心 GA
az image builder run

生成映像生成器模板。

核心 GA
az image builder show

显示映像生成器模板。

核心 GA
az image builder show-runs

显示映像生成器模板的运行输出。

核心 GA
az image builder trigger

管理映像生成器模板触发器。

核心 GA
az image builder trigger create

为指定的虚拟机映像模板创建触发器。

核心 GA
az image builder trigger delete

删除指定虚拟机映像模板的触发器。

核心 GA
az image builder trigger list

列出指定图像模板资源的所有触发器。

核心 GA
az image builder trigger show

获取指定映像模板资源的指定触发器。

核心 GA
az image builder trigger wait

将 CLI 置于等待状态,直到满足条件。

核心 GA
az image builder update

更新映像生成器模板。

核心 GA
az image builder validator

管理映像生成器模板验证。

核心 GA
az image builder validator add

向现有映像生成器模板添加验证。

核心 GA
az image builder validator remove

从现有映像生成器模板中删除验证。

核心 GA
az image builder validator show

显示现有映像生成器模板的验证。

核心 GA
az image builder wait

将 CLI 置于等待状态,直到满足模板的条件。

核心 GA
az image copy

将托管映像(或 vm)复制到其他区域。 它要求源磁盘可用。

扩展 GA
az image create

从托管磁盘或快照创建自定义虚拟机映像。

核心 GA
az image delete

删除图像。

核心 GA
az image list

列出资源组下的图像列表。

核心 GA
az image show

获取图像。

核心 GA
az image update

更新自定义 VM 映像。

核心 GA
az image wait

将 CLI 置于等待状态,直到满足条件。

核心 GA

az image copy

将托管映像(或 vm)复制到其他区域。 它要求源磁盘可用。

az image copy --source-object-name
              --source-resource-group
              --target-location
              --target-resource-group
              [--cleanup]
              [--export-as-snapshot]
              [--parallel-degree]
              [--source-type {image, vm}]
              [--tags]
              [--target-name]
              [--target-subscription]
              [--temporary-resource-group-name]
              [--timeout]

示例

将映像复制到多个区域,并在末尾进行清理。

az image copy --source-resource-group mySources-rg --source-object-name myImage \
    --target-location uksouth northeurope --target-resource-group "images-repo-rg" --cleanup

使用已通用 VM 在其他区域中创建映像。

az image copy --source-resource-group mySources-rg --source-object-name myVm \
    --source-type vm --target-location uksouth northeurope --target-resource-group "images-repo-rg"

必需参数

--source-object-name

映像或 vm 资源的名称。

--source-resource-group

源资源的资源组的名称。

--target-location

用于创建图像的空间分隔位置列表(例如 westeurope 等)。

--target-resource-group

要在其中创建映像的资源组的名称。

可选参数

--cleanup

包括此开关,以在完成后删除临时资源。

默认值: False
--export-as-snapshot

包括此开关以将副本导出为快照而不是图像。

默认值: False
--parallel-degree

并行复制操作数。

默认值: -1
--source-type

映像或 vm。

接受的值: image, vm
默认值: image
--tags

空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。

--target-name

将创建的最终映像的名称。

--target-subscription

应在其中创建最终映像的订阅的名称或 ID。

--temporary-resource-group-name

将在其中创建临时存储帐户的资源组名称。

默认值: image-copy-rg
--timeout

复制操作完成的时间(以秒为单位)。 如果要复制大型映像(磁盘),例如 512GB 或更高版本,请增加此时间。

默认值: 3600
全局参数
--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 create

从托管磁盘或快照创建自定义虚拟机映像。

az image create --name
                --resource-group
                --source
                [--data-disk-caching {None, ReadOnly, ReadWrite}]
                [--data-disk-sources]
                [--edge-zone]
                [--hyper-v-generation {V1, V2}]
                [--location]
                [--os-disk-caching {None, ReadOnly, ReadWrite}]
                [--os-type {Linux, Windows}]
                [--storage-sku {PremiumV2_LRS, Premium_LRS, Premium_ZRS, StandardSSD_LRS, StandardSSD_ZRS, Standard_LRS, UltraSSD_LRS}]
                [--tags]
                [--zone-resilient {false, true}]

示例

从现有磁盘创建映像。

az image create -g MyResourceGroup -n image1 --os-type Linux \
    --source /subscriptions/db5eb68e-73e2-4fa8-b18a-0123456789999/resourceGroups/rg1/providers/Microsoft.Compute/snapshots/s1

通过捕获同一资源组中的现有通用化虚拟机来创建映像。

az image create -g MyResourceGroup -n image1 --source MyVm1

必需参数

--name -n

新映像名称。

--resource-group -g

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

--source

来自同一区域的 OS 磁盘源,包括虚拟机 ID 或名称、OS 磁盘 blob URI、托管 OS 磁盘 ID 或名称,或 OS 快照 ID 或名称。

可选参数

--data-disk-caching

存储映像数据磁盘的缓存类型。

接受的值: None, ReadOnly, ReadWrite
--data-disk-sources

数据磁盘源的空间分隔列表,包括非托管 Blob URI、托管磁盘 ID 或名称,或快照 ID 或名称。

--edge-zone

边缘区域的名称。

--hyper-v-generation

从映像创建的虚拟机的虚拟机监控程序生成。

接受的值: V1, V2
默认值: V1
--location -l

Location。 az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。

--os-disk-caching

存储映像 OS 磁盘的缓存类型。

接受的值: None, ReadOnly, ReadWrite
--os-type
接受的值: Linux, Windows
--storage-sku

用于创建 VM 映像的存储帐户的 SKU。 如果未指定源 VM,则未使用。

接受的值: PremiumV2_LRS, Premium_LRS, Premium_ZRS, StandardSSD_LRS, StandardSSD_ZRS, Standard_LRS, UltraSSD_LRS
--tags

空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。

--zone-resilient

指定图像是否具有区域复原能力。 默认为 false。 只能在提供区域冗余存储的区域中创建区域复原映像。

接受的值: false, true
全局参数
--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 delete

删除图像。

az image delete [--ids]
                [--image-name]
                [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                [--resource-group]
                [--subscription]

可选参数

--ids

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

--image-name --name -n

映像的名称。

--no-wait

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

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--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 list

列出资源组下的图像列表。

az image list [--max-items]
              [--next-token]
              [--resource-group]

可选参数

--max-items

命令输出中要返回的项总数。 如果可用的项总数大于指定的值,则会在命令的输出中提供令牌。 若要恢复分页,请在后续命令的参数中 --next-token 提供令牌值。

--next-token

用于指定开始分页的位置的令牌。 这是先前截断的响应中的令牌值。

--resource-group -g

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

全局参数
--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 show

获取图像。

az image show [--expand]
              [--ids]
              [--image-name]
              [--resource-group]
              [--subscription]

可选参数

--expand

要应用于操作的展开表达式。

--ids

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

--image-name --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 update

更新自定义 VM 映像。

az image update [--add]
                [--force-string]
                [--ids]
                [--name]
                [--remove]
                [--resource-group]
                [--set]
                [--subscription]
                [--tags]

示例

添加或更新标记。

az image update -n ImageName -g ResourceGroup --tags tag1=val1 tag2=val2

删除所有标记。

az image update -n ImageName -g resourceGroup --tags

可选参数

--add

通过指定路径和键值对将对象添加到对象列表。 示例:--add property.listProperty <key=value, string or JSON string>

默认值: []
--force-string

使用“set”或“add”时,保留字符串文本,而不是尝试转换为 JSON。

默认值: False
--ids

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

--name -n

映像的名称。 必需。

--remove

从列表中删除属性或元素。 示例: --remove property.list <indexToRemove> OR --remove propertyToRemove.

默认值: []
--resource-group -g

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

--set

通过指定要设置的属性路径和值来更新对象。 示例:--set property1.property2=<value>

默认值: []
--subscription

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

--tags

空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。

全局参数
--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 wait

将 CLI 置于等待状态,直到满足条件。

az image wait [--created]
              [--custom]
              [--deleted]
              [--exists]
              [--expand]
              [--ids]
              [--image-name]
              [--interval]
              [--resource-group]
              [--subscription]
              [--timeout]
              [--updated]

可选参数

--created

等待在“Succeeded”中使用“provisioningState”创建。

默认值: False
--custom

等待条件满足自定义 JMESPath 查询。 例如 provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running']。

--deleted

等到删除为止。

默认值: False
--exists

等待资源存在。

默认值: False
--expand

要应用于操作的展开表达式。

--ids

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

--image-name --name -n

映像的名称。

--interval

轮询间隔(以秒为单位)。

默认值: 30
--resource-group -g

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

--subscription

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

--timeout

最大等待(以秒为单位)。

默认值: 3600
--updated

等到 provisioningState 更新为“Succeeded”。

默认值: False
全局参数
--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 获取完整的调试日志。