Is it possible to stage a new image on Azure Shared Image Gallery before creating it there?

I am trying to build an Linux VM for my Azure Shared Image Gallery (now called the Azure Compute Gallery). Unfortunately, when I create a new image with Packer and set the shared_image_gallery_destination to my SIG, I get the error message:

→ azure-arm.trainers: the Shared Gallery Image ‘[name]’ to which to publish the managed image version to does not exist in the resource group ‘[name]’ or does not contain managed image ‘[id]’

I confirmed that the SIG exists in the resource group (which were created together in Terraform).

This comment explains that the image needs to be pre-staged to the gallery before an image can be created and sent there by Packer.

I cannot do this at the time I create the SIG, since I create that once but will create new images for it multiple times in the future. I also don’t want to have a separate Terraform script that I have to create and run every time I create new images with Packer.

The question: is it possible to configure Packer in my hcl file to run an AZ CLI command to pre-stage the image created in that script? I know the command I want to run this command, but I want to avoid doing that in a way that’s separate from the Packer image definition:

az sig image-definition create --resource-group --gallery-name <my_shared_image_gallery> --gallery-image-definition --publisher --offer UbuntuServer --sku 22.04-LTS --os-type linux

Hello !, I have a similar use case as well, please let me know if you’ve found any answers to this
:hugs: