You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure中通过Packer在Compute Gallery创建自定义镜像的配置疑问

Packer配置Azure Compute Gallery镜像的JSON模板示例

要在Packer中配置Azure Compute Gallery(计算库)的相关信息,源镜像、目标镜像的所有参数都需要放在模板的builders区块下的azure-arm构建器中。以下是针对你的需求(同一Compute Gallery内,基于1.0.0版本镜像生成1.0.2版本新镜像)的JSON模板示例:

{
  "builders": [
    {
      "type": "azure-arm",
      "client_id": "<你的服务主体ID>",
      "client_secret": "<你的服务主体密钥>",
      "tenant_id": "<你的租户ID>",
      "subscription_id": "<你的订阅ID>",
      "location": "eastus",
      "vm_size": "Standard_D2s_v3",
      // 源镜像配置:指定Compute Gallery中的1.0.0版本镜像
      "source_image_reference": {
        "gallery_name": "你的ComputeGallery名称",
        "image_name": "你的镜像定义名称",
        "version": "1.0.0"
      },
      // 目标镜像配置:发布到同一Compute Gallery的1.0.2版本
      "managed_image_gallery_destination": {
        "gallery_name": "你的ComputeGallery名称",
        "image_name": "你的镜像定义名称",
        "image_version": "1.0.2",
        "replication_regions": ["eastus"]
      }
    }
  ],
  "provisioners": [
    // 这里放你的自定义配置脚本,比如软件安装、环境配置等
    {
      "type": "powershell",
      "inline": [
        "Write-Host '开始自定义镜像配置'"
      ]
    }
  ]
}

关键参数说明

  • 源镜像参数:在source_image_reference区块中填写:
    • gallery_name:源镜像所在的Compute Gallery名称
    • image_name:源镜像对应的镜像定义名称
    • version:源镜像的版本号(示例中为1.0.0)
  • 目标镜像参数:在managed_image_gallery_destination区块中填写:
    • gallery_name:目标镜像要发布到的Compute Gallery名称(和源库一致)
    • image_name:目标镜像对应的镜像定义名称(和源镜像定义一致)
    • image_version:新生成镜像的版本号(示例中为1.0.2)
    • replication_regions:镜像要复制到的Azure区域

注意:模板中的<>占位符需要替换为你自己的Azure账号、服务主体及资源信息。

内容的提问来源于stack exchange,提问作者kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 20:20:17