共用方式為


Microsoft.VirtualMachineImages imageTemplates

Bicep 資源定義

imageTemplates 資源類型可以使用目標作業來部署:

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔

資源格式

若要建立 Microsoft.VirtualMachineImages/imageTemplates 資源,請將下列 Bicep 新增至範本。

resource symbolicname 'Microsoft.VirtualMachineImages/imageTemplates@2024-02-01' = {
  identity: {
    type: 'string'
    userAssignedIdentities: {
      {customized property}: {}
    }
  }
  location: 'string'
  name: 'string'
  properties: {
    autoRun: {
      state: 'string'
    }
    buildTimeoutInMinutes: int
    customize: [
      {
        name: 'string'
        type: 'string'
        // For remaining properties, see ImageTemplateCustomizer objects
      }
    ]
    distribute: [
      {
        artifactTags: {
          {customized property}: 'string'
        }
        runOutputName: 'string'
        type: 'string'
        // For remaining properties, see ImageTemplateDistributor objects
      }
    ]
    errorHandling: {
      onCustomizerError: 'string'
      onValidationError: 'string'
    }
    managedResourceTags: {
      {customized property}: 'string'
    }
    optimize: {
      vmBoot: {
        state: 'string'
      }
    }
    source: {
      type: 'string'
      // For remaining properties, see ImageTemplateSource objects
    }
    stagingResourceGroup: 'string'
    validate: {
      continueDistributeOnFailure: bool
      inVMValidations: [
        {
          name: 'string'
          type: 'string'
          // For remaining properties, see ImageTemplateInVMValidator objects
        }
      ]
      sourceValidationOnly: bool
    }
    vmProfile: {
      osDiskSizeGB: int
      userAssignedIdentities: [
        'string'
      ]
      vmSize: 'string'
      vnetConfig: {
        containerInstanceSubnetId: 'string'
        proxyVmSize: 'string'
        subnetId: 'string'
      }
    }
  }
  tags: {
    {customized property}: 'string'
  }
}

ImageTemplateCustomizer 物件

設定 類型 屬性,以指定物件的類型。

針對 檔案,請使用:

{
  destination: 'string'
  sha256Checksum: 'string'
  sourceUri: 'string'
  type: 'File'
}

針對 PowerShell,請使用:

{
  inline: [
    'string'
  ]
  runAsSystem: bool
  runElevated: bool
  scriptUri: 'string'
  sha256Checksum: 'string'
  type: 'PowerShell'
  validExitCodes: [
    int
  ]
}

針對 Shell,請使用:

{
  inline: [
    'string'
  ]
  scriptUri: 'string'
  sha256Checksum: 'string'
  type: 'Shell'
}

針對 windowsRestart,請使用:

{
  restartCheckCommand: 'string'
  restartCommand: 'string'
  restartTimeout: 'string'
  type: 'WindowsRestart'
}

若為 WindowsUpdate,請使用:

{
  filters: [
    'string'
  ]
  searchCriteria: 'string'
  type: 'WindowsUpdate'
  updateLimit: int
}

ImageTemplateInVMValidator 物件

設定 類型 屬性,以指定物件的類型。

針對 檔案,請使用:

{
  destination: 'string'
  sha256Checksum: 'string'
  sourceUri: 'string'
  type: 'File'
}

針對 PowerShell,請使用:

{
  inline: [
    'string'
  ]
  runAsSystem: bool
  runElevated: bool
  scriptUri: 'string'
  sha256Checksum: 'string'
  type: 'PowerShell'
  validExitCodes: [
    int
  ]
}

針對 Shell,請使用:

{
  inline: [
    'string'
  ]
  scriptUri: 'string'
  sha256Checksum: 'string'
  type: 'Shell'
}

ImageTemplateSource 物件

設定 類型 屬性,以指定物件的類型。

針對 ManagedImage,請使用:

{
  imageId: 'string'
  type: 'ManagedImage'
}

針對 PlatformImage,請使用:

{
  offer: 'string'
  planInfo: {
    planName: 'string'
    planProduct: 'string'
    planPublisher: 'string'
  }
  publisher: 'string'
  sku: 'string'
  type: 'PlatformImage'
  version: 'string'
}

針對 SharedImageVersion,請使用:

{
  imageVersionId: 'string'
  type: 'SharedImageVersion'
}

ImageTemplateDistributor 物件

設定 類型 屬性,以指定物件的類型。

針對 ManagedImage,請使用:

{
  imageId: 'string'
  location: 'string'
  type: 'ManagedImage'
}

針對 SharedImage,請使用:

{
  excludeFromLatest: bool
  galleryImageId: 'string'
  replicationRegions: [
    'string'
  ]
  storageAccountType: 'string'
  targetRegions: [
    {
      name: 'string'
      replicaCount: int
      storageAccountType: 'string'
    }
  ]
  type: 'SharedImage'
  versioning: {
    scheme: 'string'
    // For remaining properties, see DistributeVersioner objects
  }
}

針對 VHD,請使用:

{
  type: 'VHD'
  uri: 'string'
}

DistributeVersioner 物件

設定 設定 屬性,以指定物件的類型。

針對 Latest,請使用:

{
  major: int
  scheme: 'Latest'
}

針對 Source,請使用:

{
  scheme: 'Source'
}

屬性值

DistributeVersioner

名字 描述 價值
方案 將 類型設為 'Latest',DistributeVersionerLatest。 將 類型設定為 'Source' DistributeVersionerSource 'Latest'
'Source' (必要)

DistributeVersionerLatest

名字 描述 價值
主要 所產生版本號碼的主要版本。 根據以此值作為主要版本的版本,判斷什麼是「最新」。 -1 相當於將它取消設定。 int

約束:
最小值 = -1
方案 要使用的版本編號配置。 'Latest' (必要)

DistributeVersionerSource

名字 描述 價值
方案 要使用的版本編號配置。 'Source' (必要)

ImageTemplateAutoRun

名字 描述 價值
啟用此欄位將會在映像範本建立或更新時觸發自動建置。 'Disabled'
'Enabled'

ImageTemplateCustomizer

名字 描述 價值
名字 易記名稱,提供此自定義步驟的內容 字串
類型 針對 imageTemplateFileCustomizer 類型 設定為 'File',。 針對 imageTemplatePowerShellCustomizer 類型 設定為 'PowerShell',。 針對 imageTemplateShellCustomizer 類型 設定為 'Shell',。 針對 imageTemplateRestartCustomizer類型 設定為 'WindowsRestart'。 針對 imageTemplateWindowsUpdateCustomizer 類型 設定為 'WindowsUpdate', 'File'
'PowerShell'
'Shell'
'WindowsRestart'
'WindowsUpdate' (必要)

ImageTemplateDistributor

名字 描述 價值
artifactTags 散發者建立/更新成品后,將會套用至成品的標記。 ImageTemplateDistributorArtifactTags
runOutputName 要用於相關聯 RunOutput 的名稱。 字串

約束:
模式 = ^[A-Za-z0-9-_.]{1,64}$ (必要)
類型 針對 imageTemplateManagedImageDistributor 類型 設定為 'ManagedImage',。 針對 imageTemplateSharedImageDistributor 類型 設定為 'SharedImage',。 針對 imageTemplateVhdDistributor 類型 設定為 'VHD', 'ManagedImage'
'SharedImage'
'VHD' (必要)

ImageTemplateDistributorArtifactTags

名字 描述 價值

ImageTemplateFileCustomizer

名字 描述 價值
目的地 檔案的絕對路徑(已建立巢狀目錄結構),其中檔案 (from sourceUri) 會在 VM 中上傳至 字串
sha256Checksum 上述 sourceUri 字段中提供的檔案 SHA256 總和檢查碼 字串
sourceUri 要上傳以自定義 VM 之檔案的 URI。 它可以是 Github 連結、Azure 記憶體的 SAS URI 等等 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'File' (必要)

ImageTemplateFileValidator

名字 描述 價值
目的地 檔案的絕對路徑(已建立巢狀目錄結構),其中檔案 (from sourceUri) 會在 VM 中上傳至 字串
sha256Checksum 上述 sourceUri 字段中提供的檔案 SHA256 總和檢查碼 字串
sourceUri 要上傳至 VM 以進行驗證之檔案的 URI。 它可以是 github 連結、Azure 記憶體 URI(已授權或 SAS),等等 字串
類型 您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證 'File' (必要)

ImageTemplateIdentity

名字 描述 價值
類型 用於映像範本的身分識別類型。 類型 『None』 會從映像範本中移除任何身分識別。 'None'
'UserAssigned'
userAssignedIdentities 與資源相關聯的使用者指派身分識別集。 userAssignedIdentities 字典索引鍵的格式為 ARM 資源標識符:'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}。 字典值可以是要求中的空白物件({})。 UserAssignedIdentities

ImageTemplateInVMValidator

名字 描述 價值
名字 易記名稱,提供此驗證步驟的內容 字串
類型 針對 imageTemplateFileValidator 類型設定為 'File'。 針對 imageTemplatePowerShellValidator 類型 設定為 'PowerShell',。 針對 imageTemplateShellValidator類型 設定為 'Shell'。 'File'
'PowerShell'
'Shell' (必要)

ImageTemplateManagedImageDistributor

名字 描述 價值
imageId 受控磁碟映像的資源標識碼 字串 (必要)
位置 映射的 Azure 位置,如果映射已經存在,則應該相符 字串 (必要)
類型 分佈類型。 'ManagedImage' (必要)

ImageTemplateManagedImageSource

名字 描述 價值
imageId 客戶訂用帳戶中受控映像的 ARM 資源識別碼 字串 (必要)
類型 指定您想要開頭的來源影像類型。 'ManagedImage' (必要)

ImageTemplatePlatformImageSource

名字 描述 價值
提供 azure 資源庫映像映像供應專案。 字串
planInfo 平臺映像的選擇性購買方案設定。 PlatformImagePurchasePlan
發行人 Azure 資源庫映像中的映像發行者 字串
sku 來自 Azure 資源庫映像的映像 sku 字串
類型 指定您想要開頭的來源影像類型。 'PlatformImage' (必要)
版本 Azure 資源庫映像中的映射版本。 如果在這裡指定了 'latest',則會在映射組建發生時評估版本,而不是在提交範本時評估。 字串

ImageTemplatePowerShellCustomizer

名字 描述 價值
內嵌 要執行的PowerShell命令陣列 string[]
runAsSystem 如果指定,PowerShell 腳本將會使用本機系統使用者提高的許可權來執行。 只有當上述 runElevated 字段設定為 true 時,才能為 true。 bool
runElevated 如果指定,PowerShell 腳本將會以更高的許可權執行 bool
scriptUri 要執行以進行自定義之 PowerShell 腳本的 URI。 它可以是 Github 連結、Azure 記憶體的 SAS URI 等等 字串
sha256Checksum 上述 scriptUri 字段中提供的 Power Shell 腳本 SHA256 總和檢查碼 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'PowerShell' (必要)
validExitCodes PowerShell 腳本的有效結束代碼。 [預設值: 0] int[]

ImageTemplatePowerShellValidator

名字 描述 價值
內嵌 要執行的PowerShell命令陣列 string[]
runAsSystem 如果指定,PowerShell 腳本將會使用本機系統使用者提高的許可權來執行。 只有當上述 runElevated 字段設定為 true 時,才能為 true。 bool
runElevated 如果指定,PowerShell 腳本將會以更高的許可權執行 bool
scriptUri 要執行以進行驗證的PowerShell腳本 URI。 它可以是 github 連結、Azure 記憶體 URI 等 字串
sha256Checksum 上述 scriptUri 字段中提供的 Power Shell 腳本 SHA256 總和檢查碼 字串
類型 您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證 'PowerShell' (必要)
validExitCodes PowerShell 腳本的有效結束代碼。 [預設值: 0] int[]

ImageTemplateProperties

名字 描述 價值
autoRun 指出是否要在範本建立或更新時自動執行映像範本組建。 ImageTemplateAutoRun
buildTimeoutInMinutes 建置映像範本時要等候的最大持續時間(包括所有自定義專案、優化、驗證和散發套件)。 省略或指定 0 以使用預設值 (4 小時)。 int

約束:
最小值 = 0
最大值 = 960
自訂 指定用來描述映像自定義步驟的屬性,例如影像來源等 ImageTemplateCustomizer[]
分發 影像輸出需要前往的散發目標。 ImageTemplateDistributor[] (必要)
errorHandling 建置失敗時的錯誤處理選項 ImageTemplatePropertiesErrorHandling
managedResourceTags 將套用至服務所建立之資源群組和/或資源的標記。 ImageTemplatePropertiesManagedResourceTags
優化 指定要在映像上執行的優化。 ImageTemplatePropertiesOptimize
指定用來描述來源影像的屬性。 ImageTemplateSource (必要)
stagingResourceGroup 與用來建置映像之映像範本相同訂用帳戶中的預備資源群組標識碼。 如果此欄位是空的,將會建立具有隨機名稱的資源群組。 如果此欄位中指定的資源群組不存在,則會以相同的名稱建立。 如果指定的資源群組存在,它必須是空的,且位於與映像範本相同的區域中。 如果此欄位是空的,或指定的資源群組不存在,則會在範本刪除期間刪除建立的資源群組,但如果指定的資源群組存在,則會在範本刪除期間刪除資源群組,而且資源群組本身將會保留。 字串
驗證 要對產生的映像執行的組態選項和驗證清單。 ImageTemplatePropertiesValidate
vmProfile 描述虛擬機如何設定以建置映像 ImageTemplateVmProfile

ImageTemplatePropertiesErrorHandling

名字 描述 價值
onCustomizerError 如果自定義工具發生錯誤,且此字段設定為 「清除」,則會清除組建 VM 和相關聯的網路資源。 這是預設行為。 如果自定義工具發生錯誤,且此字段設定為 「中止」,則會保留組建 VM。 'abort'
'cleanup'
onValidationError 如果發生驗證錯誤,且此字段設定為 「清除」,則會清除組建 VM 和相關聯的網路資源。 這是預設行為。 如果發生驗證錯誤,且此字段設定為 『abort』,則會保留組建 VM。 'abort'
'cleanup'

ImageTemplatePropertiesManagedResourceTags

名字 描述 價值

ImageTemplatePropertiesOptimize

名字 描述 價值
vmBoot 優化會在映像上套用,以加快 VM 開機速度。 ImageTemplatePropertiesOptimizeVmBoot

ImageTemplatePropertiesOptimizeVmBoot

名字 描述 價值
啟用此欄位可藉由優化最終自定義映像輸出來改善 VM 開機時間。 'Disabled'
'Enabled'

ImageTemplatePropertiesValidate

名字 描述 價值
continueDistributeOnFailure 如果驗證失敗,且此字段設定為 false,則不會散發輸出影像。 這是預設行為。 如果驗證失敗,且此字段設定為 true,輸出影像仍會散發。 請謹慎使用此選項,因為它可能會導致散發不正確的映像以供使用。 不論是哪一種情況(true 或 false),端對端映射執行都會回報為在驗證失敗時失敗。 [注意:如果驗證成功,此字段就沒有作用。] bool
inVMValidations 要執行的驗證清單。 ImageTemplateInVMValidator[]
sourceValidationOnly 如果此欄位設定為 true,則會直接驗證 'source' 區段中指定的影像。 不會執行個別的組建來產生,然後驗證自定義映像。 bool

ImageTemplateRestartCustomizer

名字 描述 價值
restartCheckCommand 檢查重新啟動是否成功的命令 [預設值: ''] 字串
restartCommand 執行重新啟動的命令 [預設值: 'shutdown /r /f /t 0 /c “packer restart”'] 字串
restartTimeout 指定為大小和單位字串的重新啟動逾時,例如 '5m' (5 分鐘) 或 '2h' (2 小時) [預設值: '5m'] 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'WindowsRestart' (必要)

ImageTemplateSharedImageDistributor

名字 描述 價值
excludeFromLatest 旗標,指出是否應該從最新版本中排除已建立的映像版本。 請省略以使用預設值 (false)。 bool
galleryImageId Azure 計算資源庫映像的資源標識碼 字串 (必要)
replicationRegions [已淘汰]將複寫映像的區域清單。 只有在未指定 targetRegions 時,才能指定此列表。 此欄位已被取代 - 請改用 targetRegions。 string[]
storageAccountType [已淘汰]用來儲存共用映像的記憶體帳戶類型。 請省略以使用預設值 (Standard_LRS)。 只有在指定 replicationRegions 時,才能指定此字段。 此欄位已被取代 - 請改用 targetRegions。 'Premium_LRS'
'Standard_LRS'
'Standard_ZRS'
targetRegions 要復寫分散式映像版本的目標區域。 這個物件會取代 replicationRegions,而且只有在未指定 replicationRegions 時才可指定。 TargetRegion[]
類型 分佈類型。 'SharedImage' (必要)
versioning 描述如何為散發產生新的 x.y.z 版本號碼。 DistributeVersioner

ImageTemplateSharedImageVersionSource

名字 描述 價值
imageVersionId 映像版本的 ARM 資源識別碼。 映射版本名稱為「最新」時,映射組建發生時會評估版本。 字串 (必要)
類型 指定您想要開頭的來源影像類型。 'SharedImageVersion' (必要)

ImageTemplateShellCustomizer

名字 描述 價值
內嵌 要執行的殼層命令陣列 string[]
scriptUri 要執行以進行自定義之殼層腳本的 URI。 它可以是 Github 連結、Azure 記憶體的 SAS URI 等等 字串
sha256Checksum scriptUri 字段中提供的Shell腳本 SHA256 總和檢查碼 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'Shell' (必要)

ImageTemplateShellValidator

名字 描述 價值
內嵌 要執行的殼層命令陣列 string[]
scriptUri 要執行以進行驗證的殼層腳本 URI。 它可以是 github 連結、Azure 記憶體 URI 等 字串
sha256Checksum scriptUri 字段中提供的Shell腳本 SHA256 總和檢查碼 字串
類型 您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證 'Shell' (必要)

ImageTemplateSource

名字 描述 價值
類型 針對 imageTemplateManagedImageSource 類型 設定為 'ManagedImage',。 針對 imageTemplatePlatformImageSource 類型 設定為 'PlatformImage',。 針對 imageTemplateSharedImageVersionSource 類型 設定為 'SharedImageVersion', 'ManagedImage'
'PlatformImage'
'SharedImageVersion' (必要)

ImageTemplateVhdDistributor

名字 描述 價值
類型 分佈類型。 'VHD' (必要)
uri 分散式 VHD Blob 的選擇性 Azure 記憶體 URI。 省略以使用預設的 (空字串),在此情況下,VHD 會發佈至預備資源群組中的記憶體帳戶。 字串

ImageTemplateVmProfile

名字 描述 價值
osDiskSizeGB 以 GB 為單位的 OS 磁碟大小。 省略或指定 0 以使用 Azure 的預設 OS 磁碟大小。 int

約束:
最小值 = 0
userAssignedIdentities 在組建 VM 和驗證 VM 上設定的使用者指派受控識別資源標識碼的選擇性數位。 這可能包括映像範本的身分識別。 string[]
vmSize 用來建置、自定義和擷取映像的虛擬機大小。 省略或指定空字串,以使用 Gen1 映像的預設值 (Standard_D1_v2,以及 Gen2 映射的Standard_D2ds_v4)。 字串
vnetConfig 用來部署組建 VM 和驗證 VM 的虛擬網路選擇性設定。 如果不需要使用任何特定的虛擬網路,請省略 。 VirtualNetworkConfig

ImageTemplateWindowsUpdateCustomizer

名字 描述 價值
過濾器 要選取要套用之更新的篩選陣列。 省略或指定空陣列以使用預設值 (沒有篩選條件)。 如需此欄位的範例和詳細描述,請參閱上述連結。 string[]
searchCriteria 搜尋更新的準則。 省略或指定空字串以使用預設值(全部搜尋)。 如需此欄位的範例和詳細描述,請參閱上述連結。 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'WindowsUpdate' (必要)
updateLimit 一次要套用的更新數目上限。 省略或指定 0 以使用預設值 (1000) int

約束:
最小值 = 0

Microsoft.VirtualMachineImages/imageTemplates

名字 描述 價值
身份 如果已設定,則為映像範本的身分識別。 ImageTemplateIdentity (必要)
位置 資源所在的地理位置 字串 (必要)
名字 資源名稱 字串

約束:
模式 = ^[A-Za-z0-9-_.]{1,64}$ (必要)
性能 映像範本的屬性 ImageTemplateProperties
標籤 資源標籤 標記名稱和值的字典。 請參閱範本中的 標籤

PlatformImagePurchasePlan

名字 描述 價值
planName 購買方案的名稱。 字串 (必要)
planProduct 購買方案的產品。 字串 (必要)
planPublisher 購買方案的發行者。 字串 (必要)

TargetRegion

名字 描述 價值
名字 區域的名稱。 字串 (必要)
replicaCount 要在此區域中建立之映像版本的複本數目。 省略以使用預設值 (1)。 int

約束:
最小值 = 1
storageAccountType 指定要用來在此區域中儲存映像的記憶體帳戶類型。 請省略以使用預設值 (Standard_LRS)。 'Premium_LRS'
'Standard_LRS'
'Standard_ZRS'

TrackedResourceTags

名字 描述 價值

UserAssignedIdentities

名字 描述 價值

UserAssignedIdentity

名字 描述 價值

VirtualNetworkConfig

名字 描述 價值
containerInstanceSubnetId 將針對隔離組建部署 Azure 容器實例之預先存在的子網資源標識碼。 只有在同時指定 subnetId 且必須與 subnetId中指定的子網位於相同的虛擬網路上時,才能指定此欄位。 字串
proxyVmSize 用來將流量傳遞至組建 VM 和驗證 VM 的 Proxy 虛擬機大小。 如果指定 containerInstanceSubnetId,則不得指定此項目,因為在此情況下不會部署 Proxy 虛擬機。 省略或指定空字串以使用預設值 (Standard_A1_v2)。 字串
subnetId 將部署組建 VM 和驗證 VM 之預先存在的子網資源識別碼 字串

使用範例

Azure 已驗證的模組

下列 Azure 驗證模組 可用來部署此資源類型。

模組 描述
虛擬機映像範本 虛擬機映像範本的AVM資源模組

Azure 快速入門範例

下列 Azure 快速入門範本 包含用於部署此資源類型的 Bicep 範例。

Bicep 檔案 描述
使用 Azure Windows 基準 Azure Image Builder 建立 Azure Image Builder 環境,並建置已套用最新 Windows Update 和 Azure Windows 基準的 Windows Server 映射。
設定開發箱服務 此範本會根據 Dev Box 快速入門指南 (/azure/dev-box/quickstart-create-dev-box) 建立所有 Dev Box 管理員資源。 您可以檢視所有建立的資源,或直接移至 DevPortal.microsoft.com 來建立您的第一個開發方塊。

ARM 樣本資源定義

imageTemplates 資源類型可以使用目標作業來部署:

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔

資源格式

若要建立 Microsoft.VirtualMachineImages/imageTemplates 資源,請將下列 JSON 新增至範本。

{
  "type": "Microsoft.VirtualMachineImages/imageTemplates",
  "apiVersion": "2024-02-01",
  "name": "string",
  "identity": {
    "type": "string",
    "userAssignedIdentities": {
      "{customized property}": {
      }
    }
  },
  "location": "string",
  "properties": {
    "autoRun": {
      "state": "string"
    },
    "buildTimeoutInMinutes": "int",
    "customize": [ {
      "name": "string",
      "type": "string"
      // For remaining properties, see ImageTemplateCustomizer objects
    } ],
    "distribute": [ {
      "artifactTags": {
        "{customized property}": "string"
      },
      "runOutputName": "string",
      "type": "string"
      // For remaining properties, see ImageTemplateDistributor objects
    } ],
    "errorHandling": {
      "onCustomizerError": "string",
      "onValidationError": "string"
    },
    "managedResourceTags": {
      "{customized property}": "string"
    },
    "optimize": {
      "vmBoot": {
        "state": "string"
      }
    },
    "source": {
      "type": "string"
      // For remaining properties, see ImageTemplateSource objects
    },
    "stagingResourceGroup": "string",
    "validate": {
      "continueDistributeOnFailure": "bool",
      "inVMValidations": [ {
        "name": "string",
        "type": "string"
        // For remaining properties, see ImageTemplateInVMValidator objects
      } ],
      "sourceValidationOnly": "bool"
    },
    "vmProfile": {
      "osDiskSizeGB": "int",
      "userAssignedIdentities": [ "string" ],
      "vmSize": "string",
      "vnetConfig": {
        "containerInstanceSubnetId": "string",
        "proxyVmSize": "string",
        "subnetId": "string"
      }
    }
  },
  "tags": {
    "{customized property}": "string"
  }
}

ImageTemplateCustomizer 物件

設定 類型 屬性,以指定物件的類型。

針對 檔案,請使用:

{
  "destination": "string",
  "sha256Checksum": "string",
  "sourceUri": "string",
  "type": "File"
}

針對 PowerShell,請使用:

{
  "inline": [ "string" ],
  "runAsSystem": "bool",
  "runElevated": "bool",
  "scriptUri": "string",
  "sha256Checksum": "string",
  "type": "PowerShell",
  "validExitCodes": [ "int" ]
}

針對 Shell,請使用:

{
  "inline": [ "string" ],
  "scriptUri": "string",
  "sha256Checksum": "string",
  "type": "Shell"
}

針對 windowsRestart,請使用:

{
  "restartCheckCommand": "string",
  "restartCommand": "string",
  "restartTimeout": "string",
  "type": "WindowsRestart"
}

若為 WindowsUpdate,請使用:

{
  "filters": [ "string" ],
  "searchCriteria": "string",
  "type": "WindowsUpdate",
  "updateLimit": "int"
}

ImageTemplateInVMValidator 物件

設定 類型 屬性,以指定物件的類型。

針對 檔案,請使用:

{
  "destination": "string",
  "sha256Checksum": "string",
  "sourceUri": "string",
  "type": "File"
}

針對 PowerShell,請使用:

{
  "inline": [ "string" ],
  "runAsSystem": "bool",
  "runElevated": "bool",
  "scriptUri": "string",
  "sha256Checksum": "string",
  "type": "PowerShell",
  "validExitCodes": [ "int" ]
}

針對 Shell,請使用:

{
  "inline": [ "string" ],
  "scriptUri": "string",
  "sha256Checksum": "string",
  "type": "Shell"
}

ImageTemplateSource 物件

設定 類型 屬性,以指定物件的類型。

針對 ManagedImage,請使用:

{
  "imageId": "string",
  "type": "ManagedImage"
}

針對 PlatformImage,請使用:

{
  "offer": "string",
  "planInfo": {
    "planName": "string",
    "planProduct": "string",
    "planPublisher": "string"
  },
  "publisher": "string",
  "sku": "string",
  "type": "PlatformImage",
  "version": "string"
}

針對 SharedImageVersion,請使用:

{
  "imageVersionId": "string",
  "type": "SharedImageVersion"
}

ImageTemplateDistributor 物件

設定 類型 屬性,以指定物件的類型。

針對 ManagedImage,請使用:

{
  "imageId": "string",
  "location": "string",
  "type": "ManagedImage"
}

針對 SharedImage,請使用:

{
  "excludeFromLatest": "bool",
  "galleryImageId": "string",
  "replicationRegions": [ "string" ],
  "storageAccountType": "string",
  "targetRegions": [
    {
      "name": "string",
      "replicaCount": "int",
      "storageAccountType": "string"
    }
  ],
  "type": "SharedImage",
  "versioning": {
    "scheme": "string"
    // For remaining properties, see DistributeVersioner objects
  }
}

針對 VHD,請使用:

{
  "type": "VHD",
  "uri": "string"
}

DistributeVersioner 物件

設定 設定 屬性,以指定物件的類型。

針對 Latest,請使用:

{
  "major": "int",
  "scheme": "Latest"
}

針對 Source,請使用:

{
  "scheme": "Source"
}

屬性值

DistributeVersioner

名字 描述 價值
方案 將 類型設為 'Latest',DistributeVersionerLatest。 將 類型設定為 'Source' DistributeVersionerSource 'Latest'
'Source' (必要)

DistributeVersionerLatest

名字 描述 價值
主要 所產生版本號碼的主要版本。 根據以此值作為主要版本的版本,判斷什麼是「最新」。 -1 相當於將它取消設定。 int

約束:
最小值 = -1
方案 要使用的版本編號配置。 'Latest' (必要)

DistributeVersionerSource

名字 描述 價值
方案 要使用的版本編號配置。 'Source' (必要)

ImageTemplateAutoRun

名字 描述 價值
啟用此欄位將會在映像範本建立或更新時觸發自動建置。 'Disabled'
'Enabled'

ImageTemplateCustomizer

名字 描述 價值
名字 易記名稱,提供此自定義步驟的內容 字串
類型 針對 imageTemplateFileCustomizer 類型 設定為 'File',。 針對 imageTemplatePowerShellCustomizer 類型 設定為 'PowerShell',。 針對 imageTemplateShellCustomizer 類型 設定為 'Shell',。 針對 imageTemplateRestartCustomizer類型 設定為 'WindowsRestart'。 針對 imageTemplateWindowsUpdateCustomizer 類型 設定為 'WindowsUpdate', 'File'
'PowerShell'
'Shell'
'WindowsRestart'
'WindowsUpdate' (必要)

ImageTemplateDistributor

名字 描述 價值
artifactTags 散發者建立/更新成品后,將會套用至成品的標記。 ImageTemplateDistributorArtifactTags
runOutputName 要用於相關聯 RunOutput 的名稱。 字串

約束:
模式 = ^[A-Za-z0-9-_.]{1,64}$ (必要)
類型 針對 imageTemplateManagedImageDistributor 類型 設定為 'ManagedImage',。 針對 imageTemplateSharedImageDistributor 類型 設定為 'SharedImage',。 針對 imageTemplateVhdDistributor 類型 設定為 'VHD', 'ManagedImage'
'SharedImage'
'VHD' (必要)

ImageTemplateDistributorArtifactTags

名字 描述 價值

ImageTemplateFileCustomizer

名字 描述 價值
目的地 檔案的絕對路徑(已建立巢狀目錄結構),其中檔案 (from sourceUri) 會在 VM 中上傳至 字串
sha256Checksum 上述 sourceUri 字段中提供的檔案 SHA256 總和檢查碼 字串
sourceUri 要上傳以自定義 VM 之檔案的 URI。 它可以是 Github 連結、Azure 記憶體的 SAS URI 等等 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'File' (必要)

ImageTemplateFileValidator

名字 描述 價值
目的地 檔案的絕對路徑(已建立巢狀目錄結構),其中檔案 (from sourceUri) 會在 VM 中上傳至 字串
sha256Checksum 上述 sourceUri 字段中提供的檔案 SHA256 總和檢查碼 字串
sourceUri 要上傳至 VM 以進行驗證之檔案的 URI。 它可以是 github 連結、Azure 記憶體 URI(已授權或 SAS),等等 字串
類型 您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證 'File' (必要)

ImageTemplateIdentity

名字 描述 價值
類型 用於映像範本的身分識別類型。 類型 『None』 會從映像範本中移除任何身分識別。 'None'
'UserAssigned'
userAssignedIdentities 與資源相關聯的使用者指派身分識別集。 userAssignedIdentities 字典索引鍵的格式為 ARM 資源標識符:'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}。 字典值可以是要求中的空白物件({})。 UserAssignedIdentities

ImageTemplateInVMValidator

名字 描述 價值
名字 易記名稱,提供此驗證步驟的內容 字串
類型 針對 imageTemplateFileValidator 類型設定為 'File'。 針對 imageTemplatePowerShellValidator 類型 設定為 'PowerShell',。 針對 imageTemplateShellValidator類型 設定為 'Shell'。 'File'
'PowerShell'
'Shell' (必要)

ImageTemplateManagedImageDistributor

名字 描述 價值
imageId 受控磁碟映像的資源標識碼 字串 (必要)
位置 映射的 Azure 位置,如果映射已經存在,則應該相符 字串 (必要)
類型 分佈類型。 'ManagedImage' (必要)

ImageTemplateManagedImageSource

名字 描述 價值
imageId 客戶訂用帳戶中受控映像的 ARM 資源識別碼 字串 (必要)
類型 指定您想要開頭的來源影像類型。 'ManagedImage' (必要)

ImageTemplatePlatformImageSource

名字 描述 價值
提供 azure 資源庫映像映像供應專案。 字串
planInfo 平臺映像的選擇性購買方案設定。 PlatformImagePurchasePlan
發行人 Azure 資源庫映像中的映像發行者 字串
sku 來自 Azure 資源庫映像的映像 sku 字串
類型 指定您想要開頭的來源影像類型。 'PlatformImage' (必要)
版本 Azure 資源庫映像中的映射版本。 如果在這裡指定了 'latest',則會在映射組建發生時評估版本,而不是在提交範本時評估。 字串

ImageTemplatePowerShellCustomizer

名字 描述 價值
內嵌 要執行的PowerShell命令陣列 string[]
runAsSystem 如果指定,PowerShell 腳本將會使用本機系統使用者提高的許可權來執行。 只有當上述 runElevated 字段設定為 true 時,才能為 true。 bool
runElevated 如果指定,PowerShell 腳本將會以更高的許可權執行 bool
scriptUri 要執行以進行自定義之 PowerShell 腳本的 URI。 它可以是 Github 連結、Azure 記憶體的 SAS URI 等等 字串
sha256Checksum 上述 scriptUri 字段中提供的 Power Shell 腳本 SHA256 總和檢查碼 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'PowerShell' (必要)
validExitCodes PowerShell 腳本的有效結束代碼。 [預設值: 0] int[]

ImageTemplatePowerShellValidator

名字 描述 價值
內嵌 要執行的PowerShell命令陣列 string[]
runAsSystem 如果指定,PowerShell 腳本將會使用本機系統使用者提高的許可權來執行。 只有當上述 runElevated 字段設定為 true 時,才能為 true。 bool
runElevated 如果指定,PowerShell 腳本將會以更高的許可權執行 bool
scriptUri 要執行以進行驗證的PowerShell腳本 URI。 它可以是 github 連結、Azure 記憶體 URI 等 字串
sha256Checksum 上述 scriptUri 字段中提供的 Power Shell 腳本 SHA256 總和檢查碼 字串
類型 您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證 'PowerShell' (必要)
validExitCodes PowerShell 腳本的有效結束代碼。 [預設值: 0] int[]

ImageTemplateProperties

名字 描述 價值
autoRun 指出是否要在範本建立或更新時自動執行映像範本組建。 ImageTemplateAutoRun
buildTimeoutInMinutes 建置映像範本時要等候的最大持續時間(包括所有自定義專案、優化、驗證和散發套件)。 省略或指定 0 以使用預設值 (4 小時)。 int

約束:
最小值 = 0
最大值 = 960
自訂 指定用來描述映像自定義步驟的屬性,例如影像來源等 ImageTemplateCustomizer[]
分發 影像輸出需要前往的散發目標。 ImageTemplateDistributor[] (必要)
errorHandling 建置失敗時的錯誤處理選項 ImageTemplatePropertiesErrorHandling
managedResourceTags 將套用至服務所建立之資源群組和/或資源的標記。 ImageTemplatePropertiesManagedResourceTags
優化 指定要在映像上執行的優化。 ImageTemplatePropertiesOptimize
指定用來描述來源影像的屬性。 ImageTemplateSource (必要)
stagingResourceGroup 與用來建置映像之映像範本相同訂用帳戶中的預備資源群組標識碼。 如果此欄位是空的,將會建立具有隨機名稱的資源群組。 如果此欄位中指定的資源群組不存在,則會以相同的名稱建立。 如果指定的資源群組存在,它必須是空的,且位於與映像範本相同的區域中。 如果此欄位是空的,或指定的資源群組不存在,則會在範本刪除期間刪除建立的資源群組,但如果指定的資源群組存在,則會在範本刪除期間刪除資源群組,而且資源群組本身將會保留。 字串
驗證 要對產生的映像執行的組態選項和驗證清單。 ImageTemplatePropertiesValidate
vmProfile 描述虛擬機如何設定以建置映像 ImageTemplateVmProfile

ImageTemplatePropertiesErrorHandling

名字 描述 價值
onCustomizerError 如果自定義工具發生錯誤,且此字段設定為 「清除」,則會清除組建 VM 和相關聯的網路資源。 這是預設行為。 如果自定義工具發生錯誤,且此字段設定為 「中止」,則會保留組建 VM。 'abort'
'cleanup'
onValidationError 如果發生驗證錯誤,且此字段設定為 「清除」,則會清除組建 VM 和相關聯的網路資源。 這是預設行為。 如果發生驗證錯誤,且此字段設定為 『abort』,則會保留組建 VM。 'abort'
'cleanup'

ImageTemplatePropertiesManagedResourceTags

名字 描述 價值

ImageTemplatePropertiesOptimize

名字 描述 價值
vmBoot 優化會在映像上套用,以加快 VM 開機速度。 ImageTemplatePropertiesOptimizeVmBoot

ImageTemplatePropertiesOptimizeVmBoot

名字 描述 價值
啟用此欄位可藉由優化最終自定義映像輸出來改善 VM 開機時間。 'Disabled'
'Enabled'

ImageTemplatePropertiesValidate

名字 描述 價值
continueDistributeOnFailure 如果驗證失敗,且此字段設定為 false,則不會散發輸出影像。 這是預設行為。 如果驗證失敗,且此字段設定為 true,輸出影像仍會散發。 請謹慎使用此選項,因為它可能會導致散發不正確的映像以供使用。 不論是哪一種情況(true 或 false),端對端映射執行都會回報為在驗證失敗時失敗。 [注意:如果驗證成功,此字段就沒有作用。] bool
inVMValidations 要執行的驗證清單。 ImageTemplateInVMValidator[]
sourceValidationOnly 如果此欄位設定為 true,則會直接驗證 'source' 區段中指定的影像。 不會執行個別的組建來產生,然後驗證自定義映像。 bool

ImageTemplateRestartCustomizer

名字 描述 價值
restartCheckCommand 檢查重新啟動是否成功的命令 [預設值: ''] 字串
restartCommand 執行重新啟動的命令 [預設值: 'shutdown /r /f /t 0 /c “packer restart”'] 字串
restartTimeout 指定為大小和單位字串的重新啟動逾時,例如 '5m' (5 分鐘) 或 '2h' (2 小時) [預設值: '5m'] 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'WindowsRestart' (必要)

ImageTemplateSharedImageDistributor

名字 描述 價值
excludeFromLatest 旗標,指出是否應該從最新版本中排除已建立的映像版本。 請省略以使用預設值 (false)。 bool
galleryImageId Azure 計算資源庫映像的資源標識碼 字串 (必要)
replicationRegions [已淘汰]將複寫映像的區域清單。 只有在未指定 targetRegions 時,才能指定此列表。 此欄位已被取代 - 請改用 targetRegions。 string[]
storageAccountType [已淘汰]用來儲存共用映像的記憶體帳戶類型。 請省略以使用預設值 (Standard_LRS)。 只有在指定 replicationRegions 時,才能指定此字段。 此欄位已被取代 - 請改用 targetRegions。 'Premium_LRS'
'Standard_LRS'
'Standard_ZRS'
targetRegions 要復寫分散式映像版本的目標區域。 這個物件會取代 replicationRegions,而且只有在未指定 replicationRegions 時才可指定。 TargetRegion[]
類型 分佈類型。 'SharedImage' (必要)
versioning 描述如何為散發產生新的 x.y.z 版本號碼。 DistributeVersioner

ImageTemplateSharedImageVersionSource

名字 描述 價值
imageVersionId 映像版本的 ARM 資源識別碼。 映射版本名稱為「最新」時,映射組建發生時會評估版本。 字串 (必要)
類型 指定您想要開頭的來源影像類型。 'SharedImageVersion' (必要)

ImageTemplateShellCustomizer

名字 描述 價值
內嵌 要執行的殼層命令陣列 string[]
scriptUri 要執行以進行自定義之殼層腳本的 URI。 它可以是 Github 連結、Azure 記憶體的 SAS URI 等等 字串
sha256Checksum scriptUri 字段中提供的Shell腳本 SHA256 總和檢查碼 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'Shell' (必要)

ImageTemplateShellValidator

名字 描述 價值
內嵌 要執行的殼層命令陣列 string[]
scriptUri 要執行以進行驗證的殼層腳本 URI。 它可以是 github 連結、Azure 記憶體 URI 等 字串
sha256Checksum scriptUri 字段中提供的Shell腳本 SHA256 總和檢查碼 字串
類型 您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證 'Shell' (必要)

ImageTemplateSource

名字 描述 價值
類型 針對 imageTemplateManagedImageSource 類型 設定為 'ManagedImage',。 針對 imageTemplatePlatformImageSource 類型 設定為 'PlatformImage',。 針對 imageTemplateSharedImageVersionSource 類型 設定為 'SharedImageVersion', 'ManagedImage'
'PlatformImage'
'SharedImageVersion' (必要)

ImageTemplateVhdDistributor

名字 描述 價值
類型 分佈類型。 'VHD' (必要)
uri 分散式 VHD Blob 的選擇性 Azure 記憶體 URI。 省略以使用預設的 (空字串),在此情況下,VHD 會發佈至預備資源群組中的記憶體帳戶。 字串

ImageTemplateVmProfile

名字 描述 價值
osDiskSizeGB 以 GB 為單位的 OS 磁碟大小。 省略或指定 0 以使用 Azure 的預設 OS 磁碟大小。 int

約束:
最小值 = 0
userAssignedIdentities 在組建 VM 和驗證 VM 上設定的使用者指派受控識別資源標識碼的選擇性數位。 這可能包括映像範本的身分識別。 string[]
vmSize 用來建置、自定義和擷取映像的虛擬機大小。 省略或指定空字串,以使用 Gen1 映像的預設值 (Standard_D1_v2,以及 Gen2 映射的Standard_D2ds_v4)。 字串
vnetConfig 用來部署組建 VM 和驗證 VM 的虛擬網路選擇性設定。 如果不需要使用任何特定的虛擬網路,請省略 。 VirtualNetworkConfig

ImageTemplateWindowsUpdateCustomizer

名字 描述 價值
過濾器 要選取要套用之更新的篩選陣列。 省略或指定空陣列以使用預設值 (沒有篩選條件)。 如需此欄位的範例和詳細描述,請參閱上述連結。 string[]
searchCriteria 搜尋更新的準則。 省略或指定空字串以使用預設值(全部搜尋)。 如需此欄位的範例和詳細描述,請參閱上述連結。 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'WindowsUpdate' (必要)
updateLimit 一次要套用的更新數目上限。 省略或指定 0 以使用預設值 (1000) int

約束:
最小值 = 0

Microsoft.VirtualMachineImages/imageTemplates

名字 描述 價值
apiVersion API 版本 '2024-02-01'
身份 如果已設定,則為映像範本的身分識別。 ImageTemplateIdentity (必要)
位置 資源所在的地理位置 字串 (必要)
名字 資源名稱 字串

約束:
模式 = ^[A-Za-z0-9-_.]{1,64}$ (必要)
性能 映像範本的屬性 ImageTemplateProperties
標籤 資源標籤 標記名稱和值的字典。 請參閱範本中的 標籤
類型 資源類型 'Microsoft.VirtualMachineImages/imageTemplates'

PlatformImagePurchasePlan

名字 描述 價值
planName 購買方案的名稱。 字串 (必要)
planProduct 購買方案的產品。 字串 (必要)
planPublisher 購買方案的發行者。 字串 (必要)

TargetRegion

名字 描述 價值
名字 區域的名稱。 字串 (必要)
replicaCount 要在此區域中建立之映像版本的複本數目。 省略以使用預設值 (1)。 int

約束:
最小值 = 1
storageAccountType 指定要用來在此區域中儲存映像的記憶體帳戶類型。 請省略以使用預設值 (Standard_LRS)。 'Premium_LRS'
'Standard_LRS'
'Standard_ZRS'

TrackedResourceTags

名字 描述 價值

UserAssignedIdentities

名字 描述 價值

UserAssignedIdentity

名字 描述 價值

VirtualNetworkConfig

名字 描述 價值
containerInstanceSubnetId 將針對隔離組建部署 Azure 容器實例之預先存在的子網資源標識碼。 只有在同時指定 subnetId 且必須與 subnetId中指定的子網位於相同的虛擬網路上時,才能指定此欄位。 字串
proxyVmSize 用來將流量傳遞至組建 VM 和驗證 VM 的 Proxy 虛擬機大小。 如果指定 containerInstanceSubnetId,則不得指定此項目,因為在此情況下不會部署 Proxy 虛擬機。 省略或指定空字串以使用預設值 (Standard_A1_v2)。 字串
subnetId 將部署組建 VM 和驗證 VM 之預先存在的子網資源識別碼 字串

使用範例

Azure 快速入門範本

下列 Azure 快速入門範本 部署此資源類型。

範本 描述
使用 Azure Windows 基準 Azure Image Builder

部署至 Azure
建立 Azure Image Builder 環境,並建置已套用最新 Windows Update 和 Azure Windows 基準的 Windows Server 映射。
設定開發箱服務

部署至 Azure
此範本會根據 Dev Box 快速入門指南 (/azure/dev-box/quickstart-create-dev-box) 建立所有 Dev Box 管理員資源。 您可以檢視所有建立的資源,或直接移至 DevPortal.microsoft.com 來建立您的第一個開發方塊。

Terraform (AzAPI 提供者) 資源定義

imageTemplates 資源類型可以使用目標作業來部署:

  • 資源群組

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔

資源格式

若要建立 Microsoft.VirtualMachineImages/imageTemplates 資源,請將下列 Terraform 新增至範本。

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.VirtualMachineImages/imageTemplates@2024-02-01"
  name = "string"
  identity = {
    type = "string"
    userAssignedIdentities = {
      {customized property} = {
      }
    }
  }
  location = "string"
  tags = {
    {customized property} = "string"
  }
  body = {
    properties = {
      autoRun = {
        state = "string"
      }
      buildTimeoutInMinutes = int
      customize = [
        {
          name = "string"
          type = "string"
          // For remaining properties, see ImageTemplateCustomizer objects
        }
      ]
      distribute = [
        {
          artifactTags = {
            {customized property} = "string"
          }
          runOutputName = "string"
          type = "string"
          // For remaining properties, see ImageTemplateDistributor objects
        }
      ]
      errorHandling = {
        onCustomizerError = "string"
        onValidationError = "string"
      }
      managedResourceTags = {
        {customized property} = "string"
      }
      optimize = {
        vmBoot = {
          state = "string"
        }
      }
      source = {
        type = "string"
        // For remaining properties, see ImageTemplateSource objects
      }
      stagingResourceGroup = "string"
      validate = {
        continueDistributeOnFailure = bool
        inVMValidations = [
          {
            name = "string"
            type = "string"
            // For remaining properties, see ImageTemplateInVMValidator objects
          }
        ]
        sourceValidationOnly = bool
      }
      vmProfile = {
        osDiskSizeGB = int
        userAssignedIdentities = [
          "string"
        ]
        vmSize = "string"
        vnetConfig = {
          containerInstanceSubnetId = "string"
          proxyVmSize = "string"
          subnetId = "string"
        }
      }
    }
  }
}

ImageTemplateCustomizer 物件

設定 類型 屬性,以指定物件的類型。

針對 檔案,請使用:

{
  destination = "string"
  sha256Checksum = "string"
  sourceUri = "string"
  type = "File"
}

針對 PowerShell,請使用:

{
  inline = [
    "string"
  ]
  runAsSystem = bool
  runElevated = bool
  scriptUri = "string"
  sha256Checksum = "string"
  type = "PowerShell"
  validExitCodes = [
    int
  ]
}

針對 Shell,請使用:

{
  inline = [
    "string"
  ]
  scriptUri = "string"
  sha256Checksum = "string"
  type = "Shell"
}

針對 windowsRestart,請使用:

{
  restartCheckCommand = "string"
  restartCommand = "string"
  restartTimeout = "string"
  type = "WindowsRestart"
}

若為 WindowsUpdate,請使用:

{
  filters = [
    "string"
  ]
  searchCriteria = "string"
  type = "WindowsUpdate"
  updateLimit = int
}

ImageTemplateInVMValidator 物件

設定 類型 屬性,以指定物件的類型。

針對 檔案,請使用:

{
  destination = "string"
  sha256Checksum = "string"
  sourceUri = "string"
  type = "File"
}

針對 PowerShell,請使用:

{
  inline = [
    "string"
  ]
  runAsSystem = bool
  runElevated = bool
  scriptUri = "string"
  sha256Checksum = "string"
  type = "PowerShell"
  validExitCodes = [
    int
  ]
}

針對 Shell,請使用:

{
  inline = [
    "string"
  ]
  scriptUri = "string"
  sha256Checksum = "string"
  type = "Shell"
}

ImageTemplateSource 物件

設定 類型 屬性,以指定物件的類型。

針對 ManagedImage,請使用:

{
  imageId = "string"
  type = "ManagedImage"
}

針對 PlatformImage,請使用:

{
  offer = "string"
  planInfo = {
    planName = "string"
    planProduct = "string"
    planPublisher = "string"
  }
  publisher = "string"
  sku = "string"
  type = "PlatformImage"
  version = "string"
}

針對 SharedImageVersion,請使用:

{
  imageVersionId = "string"
  type = "SharedImageVersion"
}

ImageTemplateDistributor 物件

設定 類型 屬性,以指定物件的類型。

針對 ManagedImage,請使用:

{
  imageId = "string"
  location = "string"
  type = "ManagedImage"
}

針對 SharedImage,請使用:

{
  excludeFromLatest = bool
  galleryImageId = "string"
  replicationRegions = [
    "string"
  ]
  storageAccountType = "string"
  targetRegions = [
    {
      name = "string"
      replicaCount = int
      storageAccountType = "string"
    }
  ]
  type = "SharedImage"
  versioning = {
    scheme = "string"
    // For remaining properties, see DistributeVersioner objects
  }
}

針對 VHD,請使用:

{
  type = "VHD"
  uri = "string"
}

DistributeVersioner 物件

設定 設定 屬性,以指定物件的類型。

針對 Latest,請使用:

{
  major = int
  scheme = "Latest"
}

針對 Source,請使用:

{
  scheme = "Source"
}

屬性值

DistributeVersioner

名字 描述 價值
方案 將 類型設為 'Latest',DistributeVersionerLatest。 將 類型設定為 'Source' DistributeVersionerSource 'Latest'
'Source' (必要)

DistributeVersionerLatest

名字 描述 價值
主要 所產生版本號碼的主要版本。 根據以此值作為主要版本的版本,判斷什麼是「最新」。 -1 相當於將它取消設定。 int

約束:
最小值 = -1
方案 要使用的版本編號配置。 'Latest' (必要)

DistributeVersionerSource

名字 描述 價值
方案 要使用的版本編號配置。 'Source' (必要)

ImageTemplateAutoRun

名字 描述 價值
啟用此欄位將會在映像範本建立或更新時觸發自動建置。 'Disabled'
'Enabled'

ImageTemplateCustomizer

名字 描述 價值
名字 易記名稱,提供此自定義步驟的內容 字串
類型 針對 imageTemplateFileCustomizer 類型 設定為 'File',。 針對 imageTemplatePowerShellCustomizer 類型 設定為 'PowerShell',。 針對 imageTemplateShellCustomizer 類型 設定為 'Shell',。 針對 imageTemplateRestartCustomizer類型 設定為 'WindowsRestart'。 針對 imageTemplateWindowsUpdateCustomizer 類型 設定為 'WindowsUpdate', 'File'
'PowerShell'
'Shell'
'WindowsRestart'
'WindowsUpdate' (必要)

ImageTemplateDistributor

名字 描述 價值
artifactTags 散發者建立/更新成品后,將會套用至成品的標記。 ImageTemplateDistributorArtifactTags
runOutputName 要用於相關聯 RunOutput 的名稱。 字串

約束:
模式 = ^[A-Za-z0-9-_.]{1,64}$ (必要)
類型 針對 imageTemplateManagedImageDistributor 類型 設定為 'ManagedImage',。 針對 imageTemplateSharedImageDistributor 類型 設定為 'SharedImage',。 針對 imageTemplateVhdDistributor 類型 設定為 'VHD', 'ManagedImage'
'SharedImage'
'VHD' (必要)

ImageTemplateDistributorArtifactTags

名字 描述 價值

ImageTemplateFileCustomizer

名字 描述 價值
目的地 檔案的絕對路徑(已建立巢狀目錄結構),其中檔案 (from sourceUri) 會在 VM 中上傳至 字串
sha256Checksum 上述 sourceUri 字段中提供的檔案 SHA256 總和檢查碼 字串
sourceUri 要上傳以自定義 VM 之檔案的 URI。 它可以是 Github 連結、Azure 記憶體的 SAS URI 等等 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'File' (必要)

ImageTemplateFileValidator

名字 描述 價值
目的地 檔案的絕對路徑(已建立巢狀目錄結構),其中檔案 (from sourceUri) 會在 VM 中上傳至 字串
sha256Checksum 上述 sourceUri 字段中提供的檔案 SHA256 總和檢查碼 字串
sourceUri 要上傳至 VM 以進行驗證之檔案的 URI。 它可以是 github 連結、Azure 記憶體 URI(已授權或 SAS),等等 字串
類型 您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證 'File' (必要)

ImageTemplateIdentity

名字 描述 價值
類型 用於映像範本的身分識別類型。 類型 『None』 會從映像範本中移除任何身分識別。 'None'
'UserAssigned'
userAssignedIdentities 與資源相關聯的使用者指派身分識別集。 userAssignedIdentities 字典索引鍵的格式為 ARM 資源標識符:'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}。 字典值可以是要求中的空白物件({})。 UserAssignedIdentities

ImageTemplateInVMValidator

名字 描述 價值
名字 易記名稱,提供此驗證步驟的內容 字串
類型 針對 imageTemplateFileValidator 類型設定為 'File'。 針對 imageTemplatePowerShellValidator 類型 設定為 'PowerShell',。 針對 imageTemplateShellValidator類型 設定為 'Shell'。 'File'
'PowerShell'
'Shell' (必要)

ImageTemplateManagedImageDistributor

名字 描述 價值
imageId 受控磁碟映像的資源標識碼 字串 (必要)
位置 映射的 Azure 位置,如果映射已經存在,則應該相符 字串 (必要)
類型 分佈類型。 'ManagedImage' (必要)

ImageTemplateManagedImageSource

名字 描述 價值
imageId 客戶訂用帳戶中受控映像的 ARM 資源識別碼 字串 (必要)
類型 指定您想要開頭的來源影像類型。 'ManagedImage' (必要)

ImageTemplatePlatformImageSource

名字 描述 價值
提供 azure 資源庫映像映像供應專案。 字串
planInfo 平臺映像的選擇性購買方案設定。 PlatformImagePurchasePlan
發行人 Azure 資源庫映像中的映像發行者 字串
sku 來自 Azure 資源庫映像的映像 sku 字串
類型 指定您想要開頭的來源影像類型。 'PlatformImage' (必要)
版本 Azure 資源庫映像中的映射版本。 如果在這裡指定了 'latest',則會在映射組建發生時評估版本,而不是在提交範本時評估。 字串

ImageTemplatePowerShellCustomizer

名字 描述 價值
內嵌 要執行的PowerShell命令陣列 string[]
runAsSystem 如果指定,PowerShell 腳本將會使用本機系統使用者提高的許可權來執行。 只有當上述 runElevated 字段設定為 true 時,才能為 true。 bool
runElevated 如果指定,PowerShell 腳本將會以更高的許可權執行 bool
scriptUri 要執行以進行自定義之 PowerShell 腳本的 URI。 它可以是 Github 連結、Azure 記憶體的 SAS URI 等等 字串
sha256Checksum 上述 scriptUri 字段中提供的 Power Shell 腳本 SHA256 總和檢查碼 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'PowerShell' (必要)
validExitCodes PowerShell 腳本的有效結束代碼。 [預設值: 0] int[]

ImageTemplatePowerShellValidator

名字 描述 價值
內嵌 要執行的PowerShell命令陣列 string[]
runAsSystem 如果指定,PowerShell 腳本將會使用本機系統使用者提高的許可權來執行。 只有當上述 runElevated 字段設定為 true 時,才能為 true。 bool
runElevated 如果指定,PowerShell 腳本將會以更高的許可權執行 bool
scriptUri 要執行以進行驗證的PowerShell腳本 URI。 它可以是 github 連結、Azure 記憶體 URI 等 字串
sha256Checksum 上述 scriptUri 字段中提供的 Power Shell 腳本 SHA256 總和檢查碼 字串
類型 您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證 'PowerShell' (必要)
validExitCodes PowerShell 腳本的有效結束代碼。 [預設值: 0] int[]

ImageTemplateProperties

名字 描述 價值
autoRun 指出是否要在範本建立或更新時自動執行映像範本組建。 ImageTemplateAutoRun
buildTimeoutInMinutes 建置映像範本時要等候的最大持續時間(包括所有自定義專案、優化、驗證和散發套件)。 省略或指定 0 以使用預設值 (4 小時)。 int

約束:
最小值 = 0
最大值 = 960
自訂 指定用來描述映像自定義步驟的屬性,例如影像來源等 ImageTemplateCustomizer[]
分發 影像輸出需要前往的散發目標。 ImageTemplateDistributor[] (必要)
errorHandling 建置失敗時的錯誤處理選項 ImageTemplatePropertiesErrorHandling
managedResourceTags 將套用至服務所建立之資源群組和/或資源的標記。 ImageTemplatePropertiesManagedResourceTags
優化 指定要在映像上執行的優化。 ImageTemplatePropertiesOptimize
指定用來描述來源影像的屬性。 ImageTemplateSource (必要)
stagingResourceGroup 與用來建置映像之映像範本相同訂用帳戶中的預備資源群組標識碼。 如果此欄位是空的,將會建立具有隨機名稱的資源群組。 如果此欄位中指定的資源群組不存在,則會以相同的名稱建立。 如果指定的資源群組存在,它必須是空的,且位於與映像範本相同的區域中。 如果此欄位是空的,或指定的資源群組不存在,則會在範本刪除期間刪除建立的資源群組,但如果指定的資源群組存在,則會在範本刪除期間刪除資源群組,而且資源群組本身將會保留。 字串
驗證 要對產生的映像執行的組態選項和驗證清單。 ImageTemplatePropertiesValidate
vmProfile 描述虛擬機如何設定以建置映像 ImageTemplateVmProfile

ImageTemplatePropertiesErrorHandling

名字 描述 價值
onCustomizerError 如果自定義工具發生錯誤,且此字段設定為 「清除」,則會清除組建 VM 和相關聯的網路資源。 這是預設行為。 如果自定義工具發生錯誤,且此字段設定為 「中止」,則會保留組建 VM。 'abort'
'cleanup'
onValidationError 如果發生驗證錯誤,且此字段設定為 「清除」,則會清除組建 VM 和相關聯的網路資源。 這是預設行為。 如果發生驗證錯誤,且此字段設定為 『abort』,則會保留組建 VM。 'abort'
'cleanup'

ImageTemplatePropertiesManagedResourceTags

名字 描述 價值

ImageTemplatePropertiesOptimize

名字 描述 價值
vmBoot 優化會在映像上套用,以加快 VM 開機速度。 ImageTemplatePropertiesOptimizeVmBoot

ImageTemplatePropertiesOptimizeVmBoot

名字 描述 價值
啟用此欄位可藉由優化最終自定義映像輸出來改善 VM 開機時間。 'Disabled'
'Enabled'

ImageTemplatePropertiesValidate

名字 描述 價值
continueDistributeOnFailure 如果驗證失敗,且此字段設定為 false,則不會散發輸出影像。 這是預設行為。 如果驗證失敗,且此字段設定為 true,輸出影像仍會散發。 請謹慎使用此選項,因為它可能會導致散發不正確的映像以供使用。 不論是哪一種情況(true 或 false),端對端映射執行都會回報為在驗證失敗時失敗。 [注意:如果驗證成功,此字段就沒有作用。] bool
inVMValidations 要執行的驗證清單。 ImageTemplateInVMValidator[]
sourceValidationOnly 如果此欄位設定為 true,則會直接驗證 'source' 區段中指定的影像。 不會執行個別的組建來產生,然後驗證自定義映像。 bool

ImageTemplateRestartCustomizer

名字 描述 價值
restartCheckCommand 檢查重新啟動是否成功的命令 [預設值: ''] 字串
restartCommand 執行重新啟動的命令 [預設值: 'shutdown /r /f /t 0 /c “packer restart”'] 字串
restartTimeout 指定為大小和單位字串的重新啟動逾時,例如 '5m' (5 分鐘) 或 '2h' (2 小時) [預設值: '5m'] 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'WindowsRestart' (必要)

ImageTemplateSharedImageDistributor

名字 描述 價值
excludeFromLatest 旗標,指出是否應該從最新版本中排除已建立的映像版本。 請省略以使用預設值 (false)。 bool
galleryImageId Azure 計算資源庫映像的資源標識碼 字串 (必要)
replicationRegions [已淘汰]將複寫映像的區域清單。 只有在未指定 targetRegions 時,才能指定此列表。 此欄位已被取代 - 請改用 targetRegions。 string[]
storageAccountType [已淘汰]用來儲存共用映像的記憶體帳戶類型。 請省略以使用預設值 (Standard_LRS)。 只有在指定 replicationRegions 時,才能指定此字段。 此欄位已被取代 - 請改用 targetRegions。 'Premium_LRS'
'Standard_LRS'
'Standard_ZRS'
targetRegions 要復寫分散式映像版本的目標區域。 這個物件會取代 replicationRegions,而且只有在未指定 replicationRegions 時才可指定。 TargetRegion[]
類型 分佈類型。 'SharedImage' (必要)
versioning 描述如何為散發產生新的 x.y.z 版本號碼。 DistributeVersioner

ImageTemplateSharedImageVersionSource

名字 描述 價值
imageVersionId 映像版本的 ARM 資源識別碼。 映射版本名稱為「最新」時,映射組建發生時會評估版本。 字串 (必要)
類型 指定您想要開頭的來源影像類型。 'SharedImageVersion' (必要)

ImageTemplateShellCustomizer

名字 描述 價值
內嵌 要執行的殼層命令陣列 string[]
scriptUri 要執行以進行自定義之殼層腳本的 URI。 它可以是 Github 連結、Azure 記憶體的 SAS URI 等等 字串
sha256Checksum scriptUri 字段中提供的Shell腳本 SHA256 總和檢查碼 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'Shell' (必要)

ImageTemplateShellValidator

名字 描述 價值
內嵌 要執行的殼層命令陣列 string[]
scriptUri 要執行以進行驗證的殼層腳本 URI。 它可以是 github 連結、Azure 記憶體 URI 等 字串
sha256Checksum scriptUri 字段中提供的Shell腳本 SHA256 總和檢查碼 字串
類型 您想要在 Image 上使用的驗證類型。 例如,“Shell” 可以是殼層驗證 'Shell' (必要)

ImageTemplateSource

名字 描述 價值
類型 針對 imageTemplateManagedImageSource 類型 設定為 'ManagedImage',。 針對 imageTemplatePlatformImageSource 類型 設定為 'PlatformImage',。 針對 imageTemplateSharedImageVersionSource 類型 設定為 'SharedImageVersion', 'ManagedImage'
'PlatformImage'
'SharedImageVersion' (必要)

ImageTemplateVhdDistributor

名字 描述 價值
類型 分佈類型。 'VHD' (必要)
uri 分散式 VHD Blob 的選擇性 Azure 記憶體 URI。 省略以使用預設的 (空字串),在此情況下,VHD 會發佈至預備資源群組中的記憶體帳戶。 字串

ImageTemplateVmProfile

名字 描述 價值
osDiskSizeGB 以 GB 為單位的 OS 磁碟大小。 省略或指定 0 以使用 Azure 的預設 OS 磁碟大小。 int

約束:
最小值 = 0
userAssignedIdentities 在組建 VM 和驗證 VM 上設定的使用者指派受控識別資源標識碼的選擇性數位。 這可能包括映像範本的身分識別。 string[]
vmSize 用來建置、自定義和擷取映像的虛擬機大小。 省略或指定空字串,以使用 Gen1 映像的預設值 (Standard_D1_v2,以及 Gen2 映射的Standard_D2ds_v4)。 字串
vnetConfig 用來部署組建 VM 和驗證 VM 的虛擬網路選擇性設定。 如果不需要使用任何特定的虛擬網路,請省略 。 VirtualNetworkConfig

ImageTemplateWindowsUpdateCustomizer

名字 描述 價值
過濾器 要選取要套用之更新的篩選陣列。 省略或指定空陣列以使用預設值 (沒有篩選條件)。 如需此欄位的範例和詳細描述,請參閱上述連結。 string[]
searchCriteria 搜尋更新的準則。 省略或指定空字串以使用預設值(全部搜尋)。 如需此欄位的範例和詳細描述,請參閱上述連結。 字串
類型 您想要在映像上使用的自訂工具類型。 例如,“Shell” 可以是殼層自定義工具 'WindowsUpdate' (必要)
updateLimit 一次要套用的更新數目上限。 省略或指定 0 以使用預設值 (1000) int

約束:
最小值 = 0

Microsoft.VirtualMachineImages/imageTemplates

名字 描述 價值
身份 如果已設定,則為映像範本的身分識別。 ImageTemplateIdentity (必要)
位置 資源所在的地理位置 字串 (必要)
名字 資源名稱 字串

約束:
模式 = ^[A-Za-z0-9-_.]{1,64}$ (必要)
性能 映像範本的屬性 ImageTemplateProperties
標籤 資源標籤 標記名稱和值的字典。
類型 資源類型 “Microsoft.VirtualMachineImages/imageTemplates@2024-02-01”

PlatformImagePurchasePlan

名字 描述 價值
planName 購買方案的名稱。 字串 (必要)
planProduct 購買方案的產品。 字串 (必要)
planPublisher 購買方案的發行者。 字串 (必要)

TargetRegion

名字 描述 價值
名字 區域的名稱。 字串 (必要)
replicaCount 要在此區域中建立之映像版本的複本數目。 省略以使用預設值 (1)。 int

約束:
最小值 = 1
storageAccountType 指定要用來在此區域中儲存映像的記憶體帳戶類型。 請省略以使用預設值 (Standard_LRS)。 'Premium_LRS'
'Standard_LRS'
'Standard_ZRS'

TrackedResourceTags

名字 描述 價值

UserAssignedIdentities

名字 描述 價值

UserAssignedIdentity

名字 描述 價值

VirtualNetworkConfig

名字 描述 價值
containerInstanceSubnetId 將針對隔離組建部署 Azure 容器實例之預先存在的子網資源標識碼。 只有在同時指定 subnetId 且必須與 subnetId中指定的子網位於相同的虛擬網路上時,才能指定此欄位。 字串
proxyVmSize 用來將流量傳遞至組建 VM 和驗證 VM 的 Proxy 虛擬機大小。 如果指定 containerInstanceSubnetId,則不得指定此項目,因為在此情況下不會部署 Proxy 虛擬機。 省略或指定空字串以使用預設值 (Standard_A1_v2)。 字串
subnetId 將部署組建 VM 和驗證 VM 之預先存在的子網資源識別碼 字串