Packer azure-arm vhd build fails with resource group not found

1k Views Asked by At

I have a Problem with Packer and the Azure Stack, I am trying to build an Image in azure stack, but it looks like packer don't try to use my custom-url.

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

    "client_id": "client_id",
    "client_secret": "client_secret",
    "tenant_id": "tenant_id",
    "subscription_id": "subscription_id",

    "managed_image_resource_group_name": "resource_group_name",
    "managed_image_name": "random_name",

    "os_type": "Linux",
    "image_publisher": "Canonical",
    "image_offer": "UbuntuServer",
    "image_sku": "18.04-LTS",

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

    "location": "custom_location",
    "vm_size": "Standard_DS2_v2"
  }],
  "provisioners": [{
    "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
    "inline": [
      "apt-get update",
      "apt-get upgrade -y",
      "apt-get -y install nginx",

      "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
    ],
    "inline_shebang": "/bin/sh -x",
    "type": "shell"
  }]
}

Error

azure-arm: output will be in this color.

==> azure-arm: Running builder ...
==> azure-arm: Getting tokens using client secret
==> azure-arm: Getting tokens using client secret
    azure-arm: Creating Azure Resource Manager (ARM) client ...
Build 'azure-arm' errored: Cannot locate the managed image resource group resource_group_name.

==> Some builds didn't complete successfully and had errors:
--> azure-arm: Cannot locate the managed image resource group olaf.

==> Builds finished but no artifacts were created.

But the creds are right, I can login with the ServiceAccount/App credentials and list all resource groups. Seems everything is working.

Do someone have an idea how to get Packer working with azure stack? Is there a way to give the stack domain instead of the original azure domain or something like that?

Thank you! =)

1

There are 1 best solutions below

0
On

I know this question is old and you likely figured it out, but I encountered the same issue today and thought it might be helpful to add my solution for anyone else that comes across this:

Make sure your service principal is added as a contributor to the resource group.

  • In Azure Portal, navigate to the target resource group

  • Click "Access (IAM)" on the left hand side.

  • Click "Add" at the top and search for the service principal