az image
Note
此命令组具有在 Azure CLI 和至少一个扩展中定义的命令。 安装每个扩展,使其受益于其扩展功能。 了解更多关于扩展的信息。
管理自定义虚拟机映像。
命令
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"
必需参数
映像或 vm 资源的名称。
源资源的资源组的名称。
用于创建图像的空间分隔位置列表(例如 westeurope 等)。
要在其中创建映像的资源组的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
包括此开关,以在完成后删除临时资源。
| 属性 | 值 |
|---|---|
| 默认值: | False |
包括此开关以将副本导出为快照而不是图像。
| 属性 | 值 |
|---|---|
| 默认值: | False |
并行复制操作数。
| 属性 | 值 |
|---|---|
| 默认值: | -1 |
映像或 vm。
| 属性 | 值 |
|---|---|
| 默认值: | image |
| 接受的值: | image, vm |
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。
将创建的最终映像的名称。
应在其中创建最终映像的订阅的名称或 ID。
将在其中创建临时存储帐户的资源组名称。
| 属性 | 值 |
|---|---|
| 默认值: | image-copy-rg |
复制操作完成的时间(以秒为单位)。 如果要复制大型映像(磁盘),例如 512GB 或更高版本,请增加此时间。
| 属性 | 值 |
|---|---|
| 默认值: | 3600 |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --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
必需参数
新映像名称。
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
来自同一区域的 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.
映像数据磁盘的存储缓存类型。
| 属性 | 值 |
|---|---|
| 接受的值: | None, ReadOnly, ReadWrite |
数据磁盘源的空间分隔列表,包括非托管 Blob URI、托管磁盘 ID 或名称,或快照 ID 或名称。
边缘区域的名称。
从映像创建的虚拟机的虚拟机监控程序生成。
| 属性 | 值 |
|---|---|
| 默认值: | V1 |
| 接受的值: | V1, V2 |
Location.
az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。
映像 OS 磁盘的存储缓存类型。
| 属性 | 值 |
|---|---|
| 接受的值: | None, ReadOnly, ReadWrite |
| 属性 | 值 |
|---|---|
| 接受的值: | Linux, Windows |
用于创建 VM 映像的存储帐户的 SKU。 如果未指定源 VM,则未使用。
| 属性 | 值 |
|---|---|
| 接受的值: | PremiumV2_LRS, Premium_LRS, Premium_ZRS, StandardSSD_LRS, StandardSSD_ZRS, Standard_LRS, UltraSSD_LRS |
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。
指定图像是否具有区域复原能力。 默认值为 false。 只能在提供区域冗余存储的区域中创建区域复原映像。
| 属性 | 值 |
|---|---|
| 接受的值: | false, true |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
增加日志记录详细程度。 使用 --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.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
图像的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
不等待长时间运行的操作完成。
| 属性 | 值 |
|---|---|
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
资源组的名称。 可以使用 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 |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --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.
命令输出中要返回的项总数。 如果可用的项总数大于指定的值,则会在命令的输出中提供令牌。 若要恢复分页,请在后续命令的 --next-token 参数中提供令牌值。
| 属性 | 值 |
|---|---|
| Parameter group: | Pagination Arguments |
用于指定开始分页的位置的令牌。 这是先前截断的响应中的令牌值。
| 属性 | 值 |
|---|---|
| Parameter group: | Pagination Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
增加日志记录详细程度。 使用 --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.
要应用于作的展开表达式。
一个或多个资源 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 |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --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 property.listProperty <key=value, string or JSON string>。
| 属性 | 值 |
|---|---|
| Parameter group: | Generic Update Arguments |
使用“set”或“add”时,保留字符串文本,而不是尝试转换为 JSON。
| 属性 | 值 |
|---|---|
| Parameter group: | Generic Update Arguments |
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
图像的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
不等待长时间运行的操作完成。
| 属性 | 值 |
|---|---|
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
从列表中删除属性或元素。 示例: --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 |
资源标记支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
| 属性 | 值 |
|---|---|
| Parameter group: | Parameters Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --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.
等待在“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: | Resource Id Arguments |
轮询间隔(以秒为单位)。
| 属性 | 值 |
|---|---|
| Parameter group: | Wait Condition Arguments |
| 默认值: | 30 |
资源组的名称。 可以使用 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 |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |