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

az image

Note

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

管理自定义虚拟机映像。

命令

名称 说明 类型 Status
az image builder

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

Core GA
az image builder cancel

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

Core GA
az image builder create

创建映像生成器模板。

Core GA
az image builder customizer

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

Core GA
az image builder customizer add

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

Core GA
az image builder customizer clear

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

Core GA
az image builder customizer remove

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

Core GA
az image builder delete

删除映像生成器模板。

Core GA
az image builder error-handler

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

Core GA
az image builder error-handler add

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

Core GA
az image builder error-handler remove

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

Core GA
az image builder error-handler show

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

Core GA
az image builder identity

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

Core GA
az image builder identity assign

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

Core GA
az image builder identity remove

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

Core GA
az image builder identity show

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

Core GA
az image builder list

列出映像生成器模板。

Core GA
az image builder optimizer

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

Core GA
az image builder optimizer add

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

Core GA
az image builder optimizer remove

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

Core GA
az image builder optimizer show

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

Core GA
az image builder optimizer update

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

Core GA
az image builder output

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

Core GA
az image builder output add

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

Core GA
az image builder output clear

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

Core GA
az image builder output remove

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

Core GA
az image builder output versioning

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

Core GA
az image builder output versioning remove

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

Core GA
az image builder output versioning set

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

Core GA
az image builder output versioning show

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

Core GA
az image builder run

生成映像生成器模板。

Core GA
az image builder show

显示映像生成器模板。

Core GA
az image builder show-runs

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

Core GA
az image builder trigger

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

Core GA
az image builder trigger create

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

Core GA
az image builder trigger delete

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

Core GA
az image builder trigger list

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

Core GA
az image builder trigger show

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

Core GA
az image builder trigger wait

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

Core GA
az image builder update

更新映像生成器模板。

Core GA
az image builder validator

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

Core GA
az image builder validator add

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

Core GA
az image builder validator remove

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

Core GA
az image builder validator show

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

Core GA
az image builder wait

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

Core GA
az image copy

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

Extension GA
az image create

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

Core GA
az image delete

删除图像。

Core GA
az image list

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

Core GA
az image show

获取图像。

Core GA
az image update

更新自定义 VM 映像。

Core GA
az image wait

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

Core 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

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

可选参数

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

--cleanup

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

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

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

属性
默认值: False
--parallel-degree

并行复制操作数。

属性
默认值: -1
--source-type

映像或 vm。

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

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

--target-name

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

--target-subscription

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

--temporary-resource-group-name

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

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

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

属性
默认值: 3600
全局参数
--debug

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

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

显示此帮助消息并退出。

--only-show-errors

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

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

输出格式。

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

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

--verbose

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

属性
默认值: False

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 或名称。

可选参数

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

--data-disk-caching

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

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

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

--edge-zone

边缘区域的名称。

--hyper-v-generation

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

属性
默认值: V1
接受的值: V1, V2
--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

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

属性
默认值: 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

az image delete

删除图像。

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

可选参数

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

--ids

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

属性
Parameter group: Resource Id Arguments
--image-name --name -n

图像的名称。

属性
Parameter group: Resource Id Arguments
--no-wait

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

属性
接受的值: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

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

属性
Parameter group: Resource Id Arguments
--subscription

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

属性
Parameter group: Resource Id Arguments
全局参数
--debug

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

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

显示此帮助消息并退出。

--only-show-errors

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

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

输出格式。

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

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

--verbose

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

属性
默认值: False

az image list

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

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

可选参数

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

--max-items

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

属性
Parameter group: Pagination Arguments
--next-token

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

属性
Parameter group: Pagination Arguments
--resource-group -g

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

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

az image show

获取图像。

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

可选参数

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

--expand

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

--ids

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

属性
Parameter group: Resource Id Arguments
--image-name --name -n

图像的名称。

属性
Parameter group: Resource Id Arguments
--resource-group -g

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

属性
Parameter group: Resource Id Arguments
--subscription

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

属性
Parameter group: Resource Id Arguments
全局参数
--debug

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

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

显示此帮助消息并退出。

--only-show-errors

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

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

输出格式。

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

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

--verbose

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

属性
默认值: False

az image update

更新自定义 VM 映像。

az image update [--add]
                [--force-string {0, 1, f, false, n, no, t, true, y, yes}]
                [--ids]
                [--image-name --name]
                [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                [--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

可选参数

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

--add

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

属性
Parameter group: Generic Update Arguments
--force-string

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

属性
Parameter group: Generic Update Arguments
接受的值: 0, 1, f, false, n, no, t, true, y, yes
--ids

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

属性
Parameter group: Resource Id Arguments
--image-name --name -n

图像的名称。

属性
Parameter group: Resource Id Arguments
--no-wait

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

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

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

属性
Parameter group: Generic Update Arguments
--resource-group -g

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

属性
Parameter group: Resource Id Arguments
--set

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

属性
Parameter group: Generic Update Arguments
--subscription

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

属性
Parameter group: Resource Id Arguments
--tags

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

属性
Parameter group: Parameters Arguments
全局参数
--debug

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

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

显示此帮助消息并退出。

--only-show-errors

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

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

输出格式。

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

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

--verbose

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

属性
默认值: False

az image wait

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

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

可选参数

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

--created

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

属性
Parameter group: Wait Condition Arguments
默认值: False
--custom

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

属性
Parameter group: Wait Condition Arguments
--deleted

等到删除为止。

属性
Parameter group: Wait Condition Arguments
默认值: False
--exists

等待资源存在。

属性
Parameter group: Wait Condition Arguments
默认值: False
--expand

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

--ids

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

属性
Parameter group: Resource Id Arguments
--image-name --name -n

图像的名称。

属性
Parameter group: Resource Id Arguments
--interval

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

属性
Parameter group: Wait Condition Arguments
默认值: 30
--resource-group -g

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

属性
Parameter group: Resource Id Arguments
--subscription

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

属性
Parameter group: Resource Id Arguments
--timeout

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

属性
Parameter group: Wait Condition Arguments
默认值: 3600
--updated

等到 provisioningState 更新为“Succeeded”。

属性
Parameter group: Wait Condition Arguments
默认值: False
全局参数
--debug

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

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

显示此帮助消息并退出。

--only-show-errors

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

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

输出格式。

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

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

--verbose

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

属性
默认值: False