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

Microsoft.VirtualMachineImages imageTemplates 2020-02-14

Bicep 资源定义

imageTemplates 资源类型可以部署到:

有关每个 API 版本中更改的属性的列表,请参阅 更改日志

资源格式

若要创建 Microsoft.VirtualMachineImages/imageTemplates 资源,请将以下 Bicep 添加到模板。

resource symbolicname 'Microsoft.VirtualMachineImages/imageTemplates@2020-02-14' = {
  name: 'string'
  location: 'string'
  tags: {
    tagName1: 'tagValue1'
    tagName2: 'tagValue2'
  }
  identity: {
    type: 'string'
    userAssignedIdentities: {}
  }
  properties: {
    buildTimeoutInMinutes: int
    customize: [
      {
        name: 'string'
        type: 'string'
        // For remaining properties, see ImageTemplateCustomizer objects
      }
    ]
    distribute: [
      {
        artifactTags: {}
        runOutputName: 'string'
        type: 'string'
        // For remaining properties, see ImageTemplateDistributor objects
      }
    ]
    source: {
      type: 'string'
      // For remaining properties, see ImageTemplateSource objects
    }
    vmProfile: {
      osDiskSizeGB: int
      vmSize: 'string'
      vnetConfig: {
        subnetId: 'string'
      }
    }
  }
}

ImageTemplateCustomizer 对象

设置 type 属性以指定对象的类型。

对于 “文件”,请使用:

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

对于 PowerShell,请使用:

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

对于 Shell,请使用:

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

对于 WindowsRestart,请使用:

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

对于 WindowsUpdate,请使用:

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

ImageTemplateDistributor 对象

设置 type 属性以指定对象的类型。

对于 ManagedImage,请使用:

  type: 'ManagedImage'
  imageId: 'string'
  location: 'string'

对于 SharedImage,请使用:

  type: 'SharedImage'
  excludeFromLatest: bool
  galleryImageId: 'string'
  replicationRegions: [
    'string'
  ]
  storageAccountType: 'string'

对于 VHD,请使用:

  type: 'VHD'

ImageTemplateSource 对象

设置 type 属性以指定对象的类型。

对于 ManagedImage,请使用:

  type: 'ManagedImage'
  imageId: 'string'

对于 PlatformImage,请使用:

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

对于 SharedImageVersion,请使用:

  type: 'SharedImageVersion'
  imageVersionId: 'string'

属性值

imageTemplates

名称 说明
name 资源名称 字符串 (必需)
location 资源位置 字符串 (必需)
标记 资源标记 标记名称和值的字典。 请参阅 模板中的标记
标识 映像模板的标识(如果已配置)。 ImageTemplateIdentity (必需)
properties 映像模板的属性 ImageTemplateProperties

ImageTemplateIdentity

名称 说明 Value
type 用于映像模板的标识类型。 类型“None”将从映像模板中删除任何标识。 “None”
“UserAssigned”
userAssignedIdentities 与映像模板关联的用户标识列表。 用户标识字典密钥引用将是 ARM 资源 ID,格式为:“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}”。 对象 (object)

ImageTemplateProperties

名称 说明
buildTimeoutInMinutes 生成映像模板时要等待的最长持续时间。 省略或指定 0 以使用默认 (4 小时) 。 int
自定义 指定用于描述图像的自定义步骤的属性,如图像源等 ImageTemplateCustomizer[]
分发 (distribute) 映像输出需要转到的分发目标。 ImageTemplateDistributor[] (必需的)
source 指定用于描述源图像的属性。 ImageTemplateSource (必需)
vmProfile 介绍如何设置虚拟机以生成映像 ImageTemplateVmProfile

ImageTemplateCustomizer

名称 说明
name 友好名称,用于提供有关此自定义步骤的上下文 字符串
type 设置对象类型 File
PowerShell
Shell
WindowsRestart
WindowsUpdate (必需)

ImageTemplateFileCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “File” (必需)
destination 文件 (的绝对路径,其中包含已创建的嵌套目录结构) , (sourceUri) 的文件将上传到 VM 中 字符串
sha256Checksum 上述 sourceUri 字段中提供的文件的 SHA256 校验和 字符串
sourceUri 要上传用于自定义 VM 的文件的 URI。 它可以是 github 链接、Azure 存储的 SAS URI 等 string

ImageTemplatePowerShellCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 需要“PowerShell” ()
inline 要执行的 PowerShell 命令数组 string[]
runAsSystem 如果指定,将使用本地系统用户以提升的权限运行 PowerShell 脚本。 仅当上面的 runElevated 字段设置为 true 时,才能为 true。 bool
runElevated 如果指定,将使用提升的权限运行 PowerShell 脚本 bool
scriptUri 要运行用于自定义的 PowerShell 脚本的 URI。 它可以是 github 链接、Azure 存储的 SAS URI 等 string
sha256Checksum 上述 scriptUri 字段中提供的 power shell 脚本的 SHA256 校验和 字符串
validExitCodes PowerShell 脚本的有效退出代码。 [默认值:0] int[]

ImageTemplateShellCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 需要“Shell” ()
inline 要执行的 shell 命令数组 string[]
scriptUri 要运行用于自定义的 shell 脚本的 URI。 它可以是 github 链接、Azure 存储的 SAS URI 等 string
sha256Checksum scriptUri 字段中提供的 shell 脚本的 SHA256 校验和 string

ImageTemplateRestartCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “WindowsRestart” (必需)
restartCheckCommand 重启成功时检查命令 [默认值:''] 字符串
restartCommand 用于执行重启的命令 [默认值:'shutdown /r /f /t 0 /c “packer restart”'] 字符串
restartTimeout 指定为数量级和单位字符串的重启超时,例如“5m” (5 分钟) 或“2h” (2 小时) [默认值:'5m'] 字符串

ImageTemplateWindowsUpdateCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “WindowsUpdate” (必需)
筛选器 要选择要应用的更新的筛选器数组。 省略或指定空数组以使用默认 (无筛选器) 。 有关此字段的示例和详细说明,请参阅上面的链接。 string[]
searchCriteria 搜索更新的条件。 省略或指定空字符串以使用默认 (搜索所有) 。 有关此字段的示例和详细说明,请参阅上述链接。 字符串
updateLimit 一次应用的最大更新数。 省略或指定 0 以使用默认 (1000) int

ImageTemplateDistributor

名称 说明
artifactTags 分发服务器创建/更新项目后将应用于项目的标记。 对象 (object)
runOutputName 要用于关联的 RunOutput 的名称。 字符串 (必需)
类型 设置对象类型 ManagedImage
SharedImage
所需的 VHD ()

ImageTemplateManagedImageDistributor

名称 说明 Value
type 分发类型。 “ManagedImage” (必需)
imageId 托管磁盘映像的资源 ID 字符串 (必需)
location 映像的 Azure 位置(如果映像已存在)应匹配 字符串 (必需)

ImageTemplateSharedImageDistributor

名称 说明 Value
type 分发类型。 “SharedImage” (必需)
excludeFromLatest 指示是否应从最新版本中排除创建的映像版本的标志。 省略以使用默认 (false) 。 bool
galleryImageId 共享映像库映像的资源 ID 字符串 (必需)
replicationRegions 映像将复制到的区域列表 string[] (必需的)
storageAccountType 用于存储共享映像的存储帐户类型。 省略 以使用默认 (Standard_LRS) 。 “Standard_LRS”
“Standard_ZRS”

ImageTemplateVhdDistributor

名称 说明 Value
type 分发类型。 “VHD” (必需)

ImageTemplateSource

名称 说明 Value
type 设置对象类型 ManagedImage
PlatformImage
需要 SharedImageVersion ()

ImageTemplateManagedImageSource

名称 说明 Value
type 指定要从头开始使用的源图像的类型。 “ManagedImage” (必需)
imageId 客户订阅中托管映像的 ARM 资源 ID 字符串 (必需)

ImageTemplatePlatformImageSource

名称 说明 Value
type 指定要从头开始使用的源图像的类型。 “PlatformImage” (必需)
offer Azure 库映像中的映像套餐。 字符串
planInfo 平台映像的购买计划的可选配置。 PlatformImagePurchasePlan
发布者 Azure 库映像中的映像发布服务器。 字符串
sku Azure 库映像中的映像 SKU。 string
版本 Azure 库映像中的映像版本。 如果在此处指定了“latest”,则会在生成映像时评估版本,而不是在提交模板时评估版本。 指定“latest”可能会导致ROUNDTRIP_INCONSISTENT_PROPERTY问题,此问题将得到修复。 字符串

PlatformImagePurchasePlan

名称 说明
planName 购买计划的名称。 字符串 (必需)
planProduct 购买计划的产品。 字符串 (必需)
planPublisher 购买计划的发布者。 字符串 (必需)

ImageTemplateSharedImageVersionSource

名称 说明 Value
type 指定要开始使用的源映像的类型。 需要“SharedImageVersion” ()
imageVersionId 共享映像库中映像版本的 ARM 资源 ID 字符串 (必需)

ImageTemplateVmProfile

名称 说明
osDiskSizeGB OS 磁盘的大小(以 GB 为单位)。 省略或指定 0 以使用 Azure 的默认 OS 磁盘大小。 int
vmSize 用于生成、自定义和捕获映像的虚拟机的大小。 省略或指定空字符串以对 Gen1 映像使用默认 (Standard_D1_v2,) 使用第 2 代映像的默认Standard_D2ds_v4。 字符串
vnetConfig 用于部署生成虚拟机的虚拟网络的可选配置。 如果不需要使用任何特定虚拟网络,则可将其省略。 VirtualNetworkConfig

VirtualNetworkConfig

名称 说明
subnetId 预先存在的子网的资源 ID。 string

快速入门模板

以下快速入门模板部署此资源类型。

模板 说明
使用 Azure Windows 基线的 Azure 映像生成器

部署到 Azure
创建 Azure 映像生成器环境,并生成应用了最新 Windows 汇报和 Azure Windows 基线的 Windows Server 映像。
配置 Dev Box 服务

部署到 Azure
此模板将按照 Dev Box 快速入门指南创建所有 Dev Box 管理员资源。 可以查看创建的所有资源,也可以直接转到 DevPortal.microsoft.com 创建第一个 Dev Box。

ARM 模板资源定义

imageTemplates 资源类型可以部署到:

有关每个 API 版本中已更改属性的列表,请参阅 更改日志

资源格式

若要创建 Microsoft.VirtualMachineImages/imageTemplates 资源,请将以下 JSON 添加到模板。

{
  "type": "Microsoft.VirtualMachineImages/imageTemplates",
  "apiVersion": "2020-02-14",
  "name": "string",
  "location": "string",
  "tags": {
    "tagName1": "tagValue1",
    "tagName2": "tagValue2"
  },
  "identity": {
    "type": "string",
    "userAssignedIdentities": {}
  },
  "properties": {
    "buildTimeoutInMinutes": "int",
    "customize": [
      {
        "name": "string",
        "type": "string"
        // For remaining properties, see ImageTemplateCustomizer objects
      }
    ],
    "distribute": [
      {
        "artifactTags": {},
        "runOutputName": "string",
        "type": "string"
        // For remaining properties, see ImageTemplateDistributor objects
      }
    ],
    "source": {
      "type": "string"
      // For remaining properties, see ImageTemplateSource objects
    },
    "vmProfile": {
      "osDiskSizeGB": "int",
      "vmSize": "string",
      "vnetConfig": {
        "subnetId": "string"
      }
    }
  }
}

ImageTemplateCustomizer 对象

设置 type 属性以指定对象的类型。

对于 “文件”,请使用:

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

对于 PowerShell,请使用:

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

对于 Shell,请使用:

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

对于 WindowsRestart,请使用:

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

对于 WindowsUpdate,请使用:

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

ImageTemplateDistributor 对象

设置 type 属性以指定对象的类型。

对于 ManagedImage,请使用:

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

对于 SharedImage,请使用:

  "type": "SharedImage",
  "excludeFromLatest": "bool",
  "galleryImageId": "string",
  "replicationRegions": [ "string" ],
  "storageAccountType": "string"

对于 VHD,请使用:

  "type": "VHD"

ImageTemplateSource 对象

设置 type 属性以指定对象的类型。

对于 ManagedImage,请使用:

  "type": "ManagedImage",
  "imageId": "string"

对于 PlatformImage,请使用:

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

对于 SharedImageVersion,请使用:

  "type": "SharedImageVersion",
  "imageVersionId": "string"

属性值

imageTemplates

名称 说明 Value
type 资源类型 'Microsoft.VirtualMachineImages/imageTemplates'
apiVersion 资源 API 版本 '2020-02-14'
name 资源名称 字符串 (必需)
location 资源位置 字符串 (必需)
标记 资源标记 标记名称和值的字典。 请参阅 模板中的标记
标识 映像模板的标识(如果已配置)。 需要 ImageTemplateIdentity ()
properties 映像模板的属性 ImageTemplateProperties

ImageTemplateIdentity

名称 说明 Value
type 用于映像模板的标识类型。 类型“None”将从映像模板中删除任何标识。 “None”
“UserAssigned”
userAssignedIdentities 与映像模板关联的用户标识列表。 用户标识字典键引用将是 ARM 资源 ID,格式为:“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}”。 对象 (object)

ImageTemplateProperties

名称 说明
buildTimeoutInMinutes 生成映像模板时要等待的最大持续时间。 省略或指定 0 以使用默认 (4 小时) 。 int
自定义 指定用于描述映像的自定义步骤的属性,如图像源等 ImageTemplateCustomizer[]
分发 (distribute) 映像输出需要转到的分发目标。 ImageTemplateDistributor[] (必需)
source 指定用于描述源图像的属性。 ImageTemplateSource (必需)
vmProfile 介绍如何设置虚拟机以生成映像 ImageTemplateVmProfile

ImageTemplateCustomizer

名称 说明
name 友好名称,提供有关此自定义步骤的用途的上下文 string
type 设置对象类型 File
PowerShell
Shell
WindowsRestart
WindowsUpdate (必需)

ImageTemplateFileCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “File” (必需)
destination 文件 (的绝对路径,其中包含已创建的嵌套目录结构) , (sourceUri) 的文件将上传到 VM 中 字符串
sha256Checksum 上述 sourceUri 字段中提供的文件的 SHA256 校验和 字符串
sourceUri 要上传用于自定义 VM 的文件的 URI。 它可以是 github 链接、Azure 存储的 SAS URI 等 字符串

ImageTemplatePowerShellCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 需要“PowerShell” ()
inline 要执行的 PowerShell 命令数组 string[]
runAsSystem 如果指定,将使用本地系统用户以提升的权限运行 PowerShell 脚本。 仅当上面的 runElevated 字段设置为 true 时,才能为 true。 bool
runElevated 如果指定,将使用提升的权限运行 PowerShell 脚本 bool
scriptUri 要运行用于自定义的 PowerShell 脚本的 URI。 它可以是 github 链接、Azure 存储的 SAS URI 等 string
sha256Checksum 上面的 scriptUri 字段中提供的 power shell 脚本的 SHA256 校验和 字符串
validExitCodes PowerShell 脚本的有效退出代码。 [默认值:0] int[]

ImageTemplateShellCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “Shell” (必需)
inline 要执行的 shell 命令数组 string[]
scriptUri 要运行用于自定义的 shell 脚本的 URI。 它可以是 github 链接、Azure 存储的 SAS URI 等 string
sha256Checksum scriptUri 字段中提供的 shell 脚本的 SHA256 校验和 字符串

ImageTemplateRestartCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “WindowsRestart” (必需)
restartCheckCommand 重启成功时检查的命令 [默认值: ''] 字符串
restartCommand 用于执行重启的命令 [默认值:'shutdown /r /f /t 0 /c “packer restart”'] 字符串
restartTimeout 重启超时指定为数量级和单位字符串,例如“5m” (5 分钟) 或“2h” (2 小时) [默认值:'5m'] 字符串

ImageTemplateWindowsUpdateCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “WindowsUpdate” (必需)
筛选器 用于选择要应用的更新的筛选器数组。 省略或指定空数组以使用默认 (无筛选器) 。 有关此字段的示例和详细说明,请参阅上述链接。 string[]
searchCriteria 搜索更新的条件。 省略或指定空字符串以使用默认 (搜索所有) 。 有关此字段的示例和详细说明,请参阅上述链接。 string
updateLimit 一次应用的最大更新数。 省略或指定 0 以使用默认 (1000) int

ImageTemplateDistributor

名称 说明
artifactTags 分发服务器创建/更新项目后将应用于项目的标记。 对象 (object)
runOutputName 要用于关联的 RunOutput 的名称。 字符串 (必需)
类型 设置对象类型 ManagedImage
SharedImage
所需的 VHD ()

ImageTemplateManagedImageDistributor

名称 说明 Value
type 分发类型。 “ManagedImage” (必需)
imageId 托管磁盘映像的资源 ID 字符串 (必需)
location 映像的 Azure 位置(如果映像已存在)应匹配 字符串 (必需)

ImageTemplateSharedImageDistributor

名称 说明 Value
type 分发类型。 “SharedImage” (必需)
excludeFromLatest 指示是否应从最新版本中排除创建的映像版本的标志。 省略以使用默认 (false) 。 bool
galleryImageId 共享映像库映像的资源 ID 字符串 (必需)
replicationRegions 映像将复制到的区域列表 string[] (必需的)
storageAccountType 用于存储共享映像的存储帐户类型。 省略 以使用默认 (Standard_LRS) 。 “Standard_LRS”
“Standard_ZRS”

ImageTemplateVhdDistributor

名称 说明 Value
type 分发类型。 “VHD” (必需)

ImageTemplateSource

名称 说明 Value
type 设置对象类型 ManagedImage
PlatformImage
需要 SharedImageVersion ()

ImageTemplateManagedImageSource

名称 说明 Value
type 指定要从头开始使用的源图像的类型。 “ManagedImage” (必需)
imageId 客户订阅中托管映像的 ARM 资源 ID 字符串 (必需)

ImageTemplatePlatformImageSource

名称 说明 Value
type 指定要从头开始使用的源图像的类型。 “PlatformImage” (必需)
offer Azure 库映像中的映像套餐。 string
planInfo 平台映像的购买计划的可选配置。 PlatformImagePurchasePlan
发布者 Azure 库映像中的映像发布服务器。 string
sku Azure 库映像中的映像 SKU。 string
版本 Azure 库映像中的映像版本。 如果此处指定了“latest”,则会在生成映像时评估版本,而不是在提交模板时评估版本。 指定“latest”可能会导致ROUNDTRIP_INCONSISTENT_PROPERTY问题,该问题将被修复。 string

PlatformImagePurchasePlan

名称 说明
planName 购买计划的名称。 字符串 (必需)
planProduct 购买计划的产品。 字符串 (必需)
planPublisher 购买计划的发布者。 字符串 (必需)

ImageTemplateSharedImageVersionSource

名称 说明 Value
type 指定要从头开始使用的源图像的类型。 需要“SharedImageVersion” ()
imageVersionId 共享映像库中映像版本的 ARM 资源 ID 字符串 (必需)

ImageTemplateVmProfile

名称 说明
osDiskSizeGB OS 磁盘的大小(以 GB 为单位)。 省略或指定 0 以使用 Azure 的默认 OS 磁盘大小。 int
vmSize 用于生成、自定义和捕获映像的虚拟机的大小。 省略或指定空字符串,以使用 Gen1 映像的默认 (Standard_D1_v2,Standard_D2ds_v4第 2 代映像) 。 string
vnetConfig 用于部署生成虚拟机的虚拟网络的可选配置。 如果不需要使用任何特定虚拟网络,则可将其省略。 VirtualNetworkConfig

VirtualNetworkConfig

名称 说明
subnetId 预先存在的子网的资源 ID。 string

快速入门模板

以下快速入门模板部署此资源类型。

模板 说明
使用 Azure Windows 基线的 Azure 映像生成器

部署到 Azure
创建 Azure 映像生成器环境,并生成应用了最新 Windows 汇报和 Azure Windows 基线的 Windows Server 映像。
配置 Dev Box 服务

部署到 Azure
此模板将按照 Dev Box 快速入门指南创建所有 Dev Box 管理员资源。 可以查看创建的所有资源,也可以直接转到 DevPortal.microsoft.com 创建第一个 Dev Box。

Terraform (AzAPI 提供程序) 资源定义

imageTemplates 资源类型可以部署到:

  • 资源组

有关每个 API 版本中已更改属性的列表,请参阅 更改日志

资源格式

若要创建 Microsoft.VirtualMachineImages/imageTemplates 资源,请将以下 Terraform 添加到模板。

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.VirtualMachineImages/imageTemplates@2020-02-14"
  name = "string"
  location = "string"
  parent_id = "string"
  tags = {
    tagName1 = "tagValue1"
    tagName2 = "tagValue2"
  }
  identity {
    type =  "UserAssigned"
    identity_ids = []
  }
  body = jsonencode({
    properties = {
      buildTimeoutInMinutes = int
      customize = [
        {
          name = "string"
          type = "string"
          // For remaining properties, see ImageTemplateCustomizer objects
        }
      ]
      distribute = [
        {
          artifactTags = {}
          runOutputName = "string"
          type = "string"
          // For remaining properties, see ImageTemplateDistributor objects
        }
      ]
      source = {
        type = "string"
        // For remaining properties, see ImageTemplateSource objects
      }
      vmProfile = {
        osDiskSizeGB = int
        vmSize = "string"
        vnetConfig = {
          subnetId = "string"
        }
      }
    }
  })
}

ImageTemplateCustomizer 对象

设置 type 属性以指定对象的类型。

对于 “文件”,请使用:

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

对于 PowerShell,请使用:

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

对于 Shell,请使用:

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

对于 WindowsRestart,请使用:

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

对于 WindowsUpdate,请使用:

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

ImageTemplateDistributor 对象

设置 type 属性以指定对象的类型。

对于 ManagedImage,请使用:

  type = "ManagedImage"
  imageId = "string"
  location = "string"

对于 SharedImage,请使用:

  type = "SharedImage"
  excludeFromLatest = bool
  galleryImageId = "string"
  replicationRegions = [
    "string"
  ]
  storageAccountType = "string"

对于 VHD,请使用:

  type = "VHD"

ImageTemplateSource 对象

设置 type 属性以指定对象的类型。

对于 ManagedImage,请使用:

  type = "ManagedImage"
  imageId = "string"

对于 PlatformImage,请使用:

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

对于 SharedImageVersion,请使用:

  type = "SharedImageVersion"
  imageVersionId = "string"

属性值

imageTemplates

名称 说明 Value
type 资源类型 “Microsoft.VirtualMachineImages/imageTemplates@2020-02-14”
name 资源名称 字符串 (必需)
location 资源位置 字符串 (必需)
parent_id 若要部署到资源组,请使用该资源组的 ID。 字符串 (必需)
标记 资源标记 标记名称和值的字典。
标识 映像模板的标识(如果已配置)。 需要 ImageTemplateIdentity ()
properties 映像模板的属性 ImageTemplateProperties

ImageTemplateIdentity

名称 说明 Value
type 用于映像模板的标识类型。 类型“None”将从映像模板中删除任何标识。 “UserAssigned”
identity_ids 与映像模板关联的用户标识列表。 用户标识字典键引用将是 ARM 资源 ID,格式为:“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}”。 用户标识 ID 的数组。

ImageTemplateProperties

名称 说明
buildTimeoutInMinutes 生成映像模板时要等待的最大持续时间。 省略或指定 0 以使用默认 (4 小时) 。 int
自定义 指定用于描述映像的自定义步骤的属性,如图像源等 ImageTemplateCustomizer[]
分发 (distribute) 映像输出需要转到的分发目标。 ImageTemplateDistributor[] (必需)
source 指定用于描述源图像的属性。 ImageTemplateSource (必需)
vmProfile 介绍如何设置虚拟机以生成映像 ImageTemplateVmProfile

ImageTemplateCustomizer

名称 说明
name 友好名称,用于提供有关此自定义步骤的上下文 string
type 设置对象类型 File
PowerShell
Shell
WindowsRestart
WindowsUpdate (必需)

ImageTemplateFileCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “文件” (必需)
destination 文件 (的绝对路径,其中包含已创建的嵌套目录结构,) 将从 sourceUri) 中 (的文件上传到 VM 中 字符串
sha256Checksum 上述 sourceUri 字段中提供的文件的 SHA256 校验和 字符串
sourceUri 要上传用于自定义 VM 的文件的 URI。 它可以是 github 链接、Azure 存储的 SAS URI 等 string

ImageTemplatePowerShellCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “PowerShell” (必需)
inline 要执行的 PowerShell 命令数组 string[]
runAsSystem 如果指定,将使用本地系统用户以提升的权限运行 PowerShell 脚本。 仅当上面的 runElevated 字段设置为 true 时,才能为 true。 bool
runElevated 如果指定,则 PowerShell 脚本将使用提升的权限运行 bool
scriptUri 要运行用于自定义的 PowerShell 脚本的 URI。 它可以是 github 链接、Azure 存储的 SAS URI 等 字符串
sha256Checksum 上面的 scriptUri 字段中提供的 power shell 脚本的 SHA256 校验和 字符串
validExitCodes PowerShell 脚本的有效退出代码。 [默认值:0] int[]

ImageTemplateShellCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 需要“Shell” ()
inline 要执行的 shell 命令数组 string[]
scriptUri 要运行用于自定义的 shell 脚本的 URI。 它可以是 github 链接、Azure 存储的 SAS URI 等 string
sha256Checksum scriptUri 字段中提供的 shell 脚本的 SHA256 校验和 字符串

ImageTemplateRestartCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “WindowsRestart” (必需)
restartCheckCommand 重启成功时检查的命令 [默认值: ''] 字符串
restartCommand 用于执行重启的命令 [默认值:'shutdown /r /f /t 0 /c “packer restart”'] 字符串
restartTimeout 重启超时指定为数量级和单位字符串,例如“5m” (5 分钟) 或“2h” (2 小时) [默认值:'5m'] 字符串

ImageTemplateWindowsUpdateCustomizer

名称 说明 Value
type 要在映像上使用的自定义工具的类型。 例如,“Shell”可以是 shell 定制器 “WindowsUpdate” (必需)
筛选器 用于选择要应用的更新的筛选器数组。 省略或指定空数组以使用默认 (无筛选器) 。 有关此字段的示例和详细说明,请参阅上述链接。 string[]
searchCriteria 搜索更新的条件。 省略或指定空字符串以使用默认 (搜索所有) 。 有关此字段的示例和详细说明,请参阅上述链接。 string
updateLimit 一次应用的最大更新数。 省略或指定 0 以使用默认 (1000) int

ImageTemplateDistributor

名称 说明
artifactTags 分发服务器创建/更新项目后将应用于项目的标记。 对象 (object)
runOutputName 要用于关联的 RunOutput 的名称。 字符串 (必需)
类型 设置对象类型 ManagedImage
SharedImage
所需的 VHD ()

ImageTemplateManagedImageDistributor

名称 说明 Value
type 分发类型。 “ManagedImage” (必需)
imageId 托管磁盘映像的资源 ID 字符串 (必需)
location 映像的 Azure 位置(如果映像已存在)应匹配 字符串 (必需)

ImageTemplateSharedImageDistributor

名称 说明 Value
type 分发类型。 “SharedImage” (必需)
excludeFromLatest 指示是否应从最新版本中排除创建的映像版本的标志。 省略以使用默认 (false) 。 bool
galleryImageId 共享映像库映像的资源 ID 字符串 (必需)
replicationRegions 映像将复制到的区域列表 string[] (必需的)
storageAccountType 用于存储共享映像的存储帐户类型。 省略 以使用默认 (Standard_LRS) 。 “Standard_LRS”
“Standard_ZRS”

ImageTemplateVhdDistributor

名称 说明 Value
type 分发类型。 “VHD” (必需)

ImageTemplateSource

名称 说明 Value
type 设置对象类型 ManagedImage
PlatformImage
需要 SharedImageVersion ()

ImageTemplateManagedImageSource

名称 说明 Value
type 指定要从头开始使用的源图像的类型。 “ManagedImage” (必需)
imageId 客户订阅中托管映像的 ARM 资源 ID 字符串 (必需)

ImageTemplatePlatformImageSource

名称 说明 Value
type 指定要从头开始使用的源图像的类型。 “PlatformImage” (必需)
offer Azure 库映像中的映像套餐。 字符串
planInfo 平台映像的购买计划的可选配置。 PlatformImagePurchasePlan
发布者 Azure 库映像中的映像发布服务器。 string
sku Azure 库映像中的映像 SKU。 string
版本 Azure 库映像中的映像版本。 如果此处指定了“latest”,则会在生成映像时评估版本,而不是在提交模板时评估版本。 指定“latest”可能会导致ROUNDTRIP_INCONSISTENT_PROPERTY问题,该问题将被修复。 string

PlatformImagePurchasePlan

名称 说明
planName 购买计划的名称。 字符串 (必需)
planProduct 购买计划的产品。 字符串 (必需)
planPublisher 购买计划的发布者。 字符串 (必需)

ImageTemplateSharedImageVersionSource

名称 说明 Value
type 指定要从头开始使用的源图像的类型。 需要“SharedImageVersion” ()
imageVersionId 共享映像库中映像版本的 ARM 资源 ID 字符串 (必需)

ImageTemplateVmProfile

名称 说明
osDiskSizeGB OS 磁盘的大小(以 GB 为单位)。 省略或指定 0 以使用 Azure 的默认 OS 磁盘大小。 int
vmSize 用于生成、自定义和捕获映像的虚拟机的大小。 省略或指定空字符串,以使用 Gen1 映像的默认 (Standard_D1_v2,Standard_D2ds_v4第 2 代映像) 。 字符串
vnetConfig 用于部署生成虚拟机的虚拟网络的可选配置。 如果不需要使用任何特定虚拟网络,则可将其省略。 VirtualNetworkConfig

VirtualNetworkConfig

名称 说明
subnetId 预先存在的子网的资源 ID。 字符串