azure - 打包程序 azure-arm : Cannot locate the managed image resource group

标签 azure packer

我是 Packer 新手,我一直在尝试按照本指南在 Azure 镜像上构建我的第一个 Packer - https://learn.microsoft.com/en-us/azure/virtual-machines/windows/build-image-with-packer

我没有完全遵循该指南,因为我已经设置了 Azure 订阅和资源组。但现在当我尝试构建我的 Packer 镜像时,出现以下错误

Build 'azure-arm' errored: Cannot locate the managed image resource group myResourceGroup

通过阅读文档,它指出唯一的要求是资源组已经存在,正如我在 Azure 门户中看到的那样。

我的打包器 json 文件遵循如下所示的指南中的文件,如有任何帮助,感激不尽

    {
  "builders": [{
    "type": "azure-arm",

    "client_id": "0831b578-8ab6-40b9-a581-9a880a94aab1",
    "client_secret": "P@ssw0rd!",
    "tenant_id": "72f988bf-86f1-41af-91ab-2d7cd011db47",
    "subscription_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
    "object_id": "a7dfb070-0d5b-47ac-b9a5-cf214fff0ae2",

    "managed_image_resource_group_name": "myResourceGroup",
    "managed_image_name": "myPackerImage",

    "os_type": "Windows",
    "image_publisher": "MicrosoftWindowsServer",
    "image_offer": "WindowsServer",
    "image_sku": "2016-Datacenter",

    "communicator": "winrm",
    "winrm_use_ssl": "true",
    "winrm_insecure": "true",
    "winrm_timeout": "3m",
    "winrm_username": "packer",

    "azure_tags": {
        "dept": "Engineering",
        "task": "Image deployment"
    },

    "location": "East US",
    "vm_size": "Standard_DS2_v2"
  }],
  "provisioners": [{
    "type": "powershell",
    "inline": [
      "Add-WindowsFeature Web-Server",
      "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
      "& $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /shutdown /quiet"
    ]
  }]
}

最佳答案

这发生在我身上,因为我的服务主体没有足够的权限来读取资源组。

确保您拥有正确的权限,这应该创建正确的服务主体:

az ad sp create-for-rbac --role Contributor --name sp-packer-001

关于azure - 打包程序 azure-arm : Cannot locate the managed image resource group,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47871191/

相关文章:

Azure DevOps 和 Azure Active Directory

.net - Windows Azure REST Api 背后的技术是什么?

azure - 当我从 Azure 表存储检索时,有什么方法可以跳过行吗?

amazon-web-services - 等待 SSH : Packer experienced an authentication error when trying to connect via SSH 时出错

azure - 如何使用数据工厂在 HDInsights 群集中设置自定义 Spark 参数

powershell - 无法将凭据添加到 Azure AD 中的服务主体

linux - 如何使用 Packer 创建带有 Linux 自定义分区的 Azure VM

ansible - 使用 Extra-vars 在 Ansible 中传递多维数组的元素

policy - 将 Hashicorp Packer 与 Vault Secret Engine KV2 结合使用

vagrant - 加壳模板中的 {{ .Name }} 的值是多少?