Packer: Feature Request: Return Azure image id

Created on 27 Sep 2018  ยท  5Comments  ยท  Source: hashicorp/packer

There appears to be no programmatic way of getting the ID of the resultant image when building managed images with the Azure Builder.

For example:

"managed_image_name": "jenkins-centos7-{{isotime \"2006-01-02T1504\"}}"
would produce an image with the given name, but there is no way for me to determine the final name short of parsing the console output.

I've tried the recommendation in #5117 (to use the manifest post-processor), but it outputs a blank artifact_id:

   {
      "name": "azure-arm",
      "builder_type": "azure-arm",
      "build_time": 1538052650,
      "files": null,
      "artifact_id": "",
      "packer_run_uuid": "2c711ee4-6548-7a81-6a98-2120c99d43cb"
    }

(with AWS, the artifact_id is indeed populated)

What I'd like, at the very least:

   {
      "name": "azure-arm",
      "builder_type": "azure-arm",
      "build_time": 1538052650,
      "files": null,
      "artifact_id": "jenkins-centos7-2006-01-02T1504",
      "packer_run_uuid": "2c711ee4-6548-7a81-6a98-2120c99d43cb"
    }

What I'd like, ideally:

   {
      "name": "azure-arm",
      "builder_type": "azure-arm",
      "build_time": 1538052650,
      "files": null,
      "artifact_id": "/subscriptions/xxxxxxxxxxxxxxxxxxxx/resourceGroups/XXXXXXXX/providers/Microsoft.Compute/images/jenkins-centos7-2006-01-02T1504",
      "packer_run_uuid": "2c711ee4-6548-7a81-6a98-2120c99d43cb"
    }

(Full image ID is returned)

My current workaround is to pass the name of the new image to packer as a user variable instead of letting the template generate it. This is not ideal because it's not consistent across builders (for example, AWS builder does not have any correlation between the "ami_name" and the resultant ami id) so I'd rather not make the assumption that this will always work even in Azure.

bug buildeazure post-processomanifest

Most helpful comment

@SwampDragons : works beatifully, thanks!

All 5 comments

I've made a PR that should fix this (linked above); if you let me know your host architecture (linux, windows, or osx), I can provide you with a build of Packer that has this patch so you can test it out.

@SwampDragons, many thanks, I'm on linux.

@SwampDragons : works beatifully, thanks!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mwhooker picture mwhooker  ยท  3Comments

frezbo picture frezbo  ยท  3Comments

s4mur4i picture s4mur4i  ยท  3Comments

wduncanfraser picture wduncanfraser  ยท  3Comments

sourav82 picture sourav82  ยท  3Comments