在使用现有资源组在azure中构建Windows映像时,如何指定packer创建的网络接口的位置

问题描述 投票:0回答:1

我用过的打包机

`{
    "builders": [
      {
        "name": "image",
        "type": "azure-arm",

        "os_disk_size_gb": "256",
        "vm_size": "Standard_F8s_v2",
        "managed_image_storage_account_type": "Standard_LRS",
        
        "client_id": "xxxxxxxxxxxxxxxxxxx",
        "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "tenant_id": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
        "subscription_id": "xxxxxxxxxxxxxxxxxxxxxxxx",
        "object_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",

        "managed_image_name": "mypackerimage",
        "managed_image_resource_group_name": "resource_group_name",
        "build_resource_group_name": "rg",

        "virtual_network_name": "VizDev-AzureDevOps-vnet",
        "virtual_network_resource_group_name": "VizDev-AzureDevOps",
        "virtual_network_subnet_name": "default",

        "os_type": "Windows",
        "image_publisher": "MicrosoftWindowsServer",
        "image_offer": "WindowsServer",
        "image_sku": "2022-Datacenter",
        "communicator": "winrm",
        "winrm_use_ssl": "true",
        "winrm_insecure": "true",
        "winrm_username": "packer"

      }
    ],
    "provisioners": [
      {
        "type": "shell",
        "script": "./provisioning-script.sh"
      },
      {
        "type": "powershell",
        "inline": [
          "Write-Output 'Hello, Packer!'"
        ]
      }
    ]
  }`

请查找以下错误代码:

` 某些构建未成功完成并出现错误:

--> azure-arm.image: polling after CreateOrUpdate: Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details." Targ
et="/subscriptions//resourceGroups/VizDev-AzureDevOps/providers/Microsoft.Resources/deployments/pkrdpgt4raapkqo" Details=[{"code":"InvalidResourceReference","details":[],"message":"Resource /subscriptions/resourceGroups/VizDev-AzureDevOps/providers/Microsoft.Network/virtualNetworks/VizDev-AzureDevOps-vnet/subnets/default referenced by resource /subscriptions//resourceGroups/VizDev-AzureDevOps/providers/M
icrosoft.Network/networkInterfaces/pkrnigt4raapkqo was not found. Please make sure that the referenced resource exists, and that both resources are in the same region."}]

==> 构建已完成,但未创建任何工件。`

windows azure image packer nic
1个回答
0
投票

默认情况下,packer 应使用资源组位置,因此请检查

"virtual_network_resource_group_name": "VizDev-AzureDevOps"
"build_resource_group_name": "rg"
是否存在于同一位置。两个 RG 应存在于同一订阅中 (
"subscription_id": "xxxxxxxxxxxxxxxxxxxxxxxx"
)。当
location
未定义时,可以使用
build_resource_group_name

不允许将 temp_resource_group_name 或 location 与 build_resource_group_name 结合提供。

作为起点,您可以使用文档中提供的基本示例: https://developer.hashicorp.com/packer/integrations/hashicorp/azure/latest/components/builder/arm#basic-example

© www.soinside.com 2019 - 2024. All rights reserved.