There appears to be no programmatic way of getting the ID of the resultant image when building managed images with the Azure Builder.
"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)
{
"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"
}
{
"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.
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.
Most helpful comment
@SwampDragons : works beatifully, thanks!