az image builder

管理和建置映像產生器範本。

命令

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

根據映像範本取消長時間執行的映像組建。

az image builder cancel [--ids]
                        [--name]
                        [--resource-group]
                        [--subscription]

範例

取消映像組建。

az image builder cancel -n mytemplate -g my-group

選擇性參數

--ids

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

--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 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 映射建立映像產生器範本。 將其散發為受控映像和共用映像庫映像版本。 將預備資源群組標識元指定為將用來建置映像的映像範本。

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

必要參數

--name -n

映像範本的名稱。

--resource-group -g

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

選擇性參數

--build-timeout

建置映像範本時要等候的最大持續時間,以分鐘為單位。 預設值為 60。

--build-vm-identities

要用來部署組建虛擬機的虛擬網路選擇性設定。 如果不需要使用任何特定的虛擬網路,請省略 。

--checksum

Red Hat ISO 映射的 SHA256 總和檢查碼。

--defer

暫時將物件儲存在本機快取中,而不是傳送至 Azure。 使用 az cache 命令來檢視/清除。

--identity

使用者指派的身分識別清單(名稱或標識符,以空格分隔)映像範本。

--image-source -i

要自定義的基底映像。 必須是有效的平臺映像 URN、平臺映像別名、Red Hat ISO 映射 URI、受控映射名稱/標識符或共用映像版本識別碼。

值來自: az vm image list, az vm image show
--image-template

映像範本檔案的本機路徑或URL。 使用 --image-template 時,除了 -g 和 -n 之外,會忽略所有其他參數。 參考: https://docs.microsoft.com/azure/virtual-machines/linux/image-builder-json

--location -l

位置。​​ 來自的值: az account list-locations。 您可以使用 az configure --defaults location=<location> 設定預設位置。

--managed-image-destinations

受控映像輸出散發者資訊。 索引鍵/值組的空間分隔清單。 例如 「image_1=westus2 image_2=westus」。。 每個金鑰都是要建立之受控映像的名稱或資源識別碼。 每個值都是影像的位置。

--no-wait

請勿等候長時間執行的作業完成。

預設值: False
--os-disk-size

以 GB 為單位的 OS 磁碟大小。 省略或指定 0 以使用 Azure 的預設 OS 磁碟大小。

--proxy-vm-size

用來建置、自定義和擷取映像的虛擬機大小(gen1 映像的Standard_D1_v2,以及 Gen2 映像Standard_D2ds_v4)。

--scripts

以空格分隔的殼層或PowerShell腳本清單,以自定義映像。 每個腳本都必須是可公開存取的URL。 從擴展名 ('.sh' or'.ps1' 或來源類型推斷腳本類型。 更多自定義工具選項和彈性,請參閱:『az image template customizer add』。

--shared-image-destinations

共用映像庫 (sig) 輸出散發者資訊。 索引鍵/值組的空間分隔清單。 例如 「my_gallery_1/image_def_1=eastus,westus my_gallery_2/image_def_2=uksouth,canadaeast,francesouth」。。每個索引鍵都是以 「/」 分隔的 sig 映射定義識別碼或 sig 資源庫名稱和 sig 映射定義。 每個值都是以逗號分隔的複本位置清單。

--staging-resource-group

與用來建置映像之映像範本相同訂用帳戶中的預備資源群組標識碼。

--subnet

要部署組建虛擬機的子網名稱或標識符。

--tags

以空格分隔的標記:key[=value] [key[=value] ...]。使用 「清除現有的標記」。

--validator

您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證。

--vm-size

用來建置、自定義和擷取映像的虛擬機大小。 省略或指定空字串以使用預設值 (Standard_D1_v2)。

--vnet

要部署組建虛擬機的 VNET 名稱。 只有當子網是名稱時,才應該指定它。

全域參數
--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 builder delete

刪除映像產生器範本。

az image builder delete [--ids]
                        [--name]
                        [--resource-group]
                        [--subscription]

範例

刪除映像產生器範本。 ( 自動產生 )

az image builder delete --name MyImageTemplate --resource-group MyResourceGroup

選擇性參數

--ids

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

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

列出影像產生器範本。

az image builder list [--resource-group]

選擇性參數

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

選擇性參數

--ids

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

--name -n

映像範本的名稱。

--no-wait

請勿等候長時間執行的作業完成。

預設值: False
--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 builder show

顯示影像產生器範本。

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

範例

顯示影像產生器樣本 (自動產生)

az image builder show --name mytemplate  --resource-group my-group

選擇性參數

--ids

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

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

選擇性參數

--ids

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

--name -n

映像範本的名稱。

--output-name

映射產生器執行輸出的名稱。

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

更新映像產生器範本。

目前不支援更新映像產生器範本。 此命令可以與 --defer 搭配使用,以更新 CLI 快取中的映射範本物件。 如果沒有 --defer,它會從快取擷取指定的映像範本,並將要求傳送至 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

選擇性參數

--add

藉由指定路徑和索引鍵值組,將物件加入物件清單。 範例:--add property.listProperty <key=value, string or JSON string>

預設值: []
--defer

暫時將物件儲存在本機快取中,而不是傳送至 Azure。 使用 az cache 命令來檢視/清除。

--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帳戶。

全域參數
--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 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

選擇性參數

--created

請等候在 'Succeeded' 使用 'provisioningState' 建立。

預設值: False
--custom

等到條件符合自定義 JMESPath 查詢為止。 例如 provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running']。

--deleted

等到刪除為止。

預設值: False
--exists

等候資源存在。

預設值: False
--ids

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

--interval

輪詢間隔以秒為單位。

預設值: 30
--name -n

映像範本的名稱。

--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 來取得完整偵錯記錄。