az image

注意

此命令群組具有 Azure CLI 和至少一個擴充功能中定義的命令。 安裝每個擴充功能以受益於其擴充功能。 深入了解擴充功能。

管理自定義虛擬機映像。

命令

名稱 Description 類型 狀態
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

應該在其中建立最終映像之訂用帳戶的名稱或標識碼。

--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

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 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磁碟來源,包括虛擬機標識碼或名稱、OS 磁碟 Blob URI、受控 OS 磁碟識別碼或名稱,或 OS 快照集標識碼或名稱。

選擇性參數

--data-disk-caching

儲存體 映射數據磁碟的快取類型。

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

以空格分隔的數據源清單,包括非受控 Blob URI、受控磁碟標識碼或名稱,或快照集標識碼或名稱。

--edge-zone

邊緣區域的名稱。

--hyper-v-generation

從映像建立之虛擬機的 Hypervisor 產生。

接受的值: V1, V2
預設值: V1
--location -l

位置。​​ 來自的值: 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

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 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

一或多個資源識別碼 (以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--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

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 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

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 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

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

az image show

取得映像。

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

選擇性參數

--expand

要套用至作業的展開表達式。

--ids

一或多個資源識別碼 (以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--image-name --name -n

影像的名稱。

--resource-group -g

資源群組的名稱。 您可以使用 來設定預設群組 az configure --defaults group=<name>

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 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

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 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

一或多個資源識別碼 (以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--name -n

影像的名稱。 必要。

--remove

從清單中移除屬性或專案。 範例: --remove property.list <indexToRemove>--remove propertyToRemove

預設值: []
--resource-group -g

資源群組的名稱。 您可以使用 來設定預設群組 az configure --defaults group=<name>

--set

指定要設定的屬性路徑和值,以更新物件。 範例:--set property1.property2=<value>

預設值: []
--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 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

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 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

一或多個資源識別碼 (以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--image-name --name -n

影像的名稱。

--interval

輪詢間隔以秒為單位。

預設值: 30
--resource-group -g

資源群組的名稱。 您可以使用 來設定預設群組 az configure --defaults group=<name>

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 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

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。