Windows VM ARM deployment cannot use Shared Image Gallery and version 'latest'

JHStarner 6 Reputation points
2021-03-10T19:46:41.797+00:00

I have successfully used ARM to deploy Windows VMs in the past, but that was always with a hardcoded resource ID to the Image in question.

Because we are looking to revamp our Imaging process, we wanted to use versions to specify Image Version, instead of creating a brand new Image Definition every time. This in turn requires updating of the ARM Template to the new Image Definition ID.

Under the ImageReference Object, I am using the Resource ID of the image, and version set to 'latest'. Actual values removed of course.

"storageProfile": {
    "imageReference": {
        "id": "/subscriptions/{MySub}/resourceGroups/{MyRG}/providers/Microsoft.Compute/galleries/{SharedGalleryName}/images/{ImageName}",
        "version": "latest"
    }
 }

When I attempt to deploy the ARM template I get the following failure.

{
    "status": "Failed",
    "error": {
        "code": "InvalidTemplateDeployment",
        "message": "The template deployment 'compose-deployWVM-Test' is not valid according to the validation procedure. The tracking id is '---'. See inner errors for details.",
        "details": [
            {
                "code": "InvalidParameterConflictingProperties",
                "message": "Resource 'TESTVM' has invalid parameters. Details: The property 'imageReference.id' cannot be used together with property 'imageReference.version'."
            }
        ]
    }
}

Is version something only available for Marketplace image offerings? If so, how does this offer any usability to the Versions in the Shared Image Gallery Resource other than version tracking?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,130 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. JHStarner 6 Reputation points
    2021-03-11T14:56:01.613+00:00

    So after reading @HarshitaSingh-MSFT's recommendation I tried the following in the ARM Template.

    "/subscriptions/subID/resourceGroups/rgName/providers/Microsoft.Compute/galleries/galleryName/images/imageName/versions/latest"  
    

    This worked, so I will attempt to use this going forward.

    That said, could this please be updated in this document: https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines?tabs=json#imagereference-object

    It is not clear that I can use 'latest' as part of the Image Resource ID, which led me to ask the question in the first place.

    But good to go.

    Thanks!

    1 person found this answer helpful.

  2. singhh-msft 2,431 Reputation points
    2021-03-11T10:29:15.693+00:00

    @JHStarner , thank you for reaching out to us. Happy to help. As I see, that this is a known issue. It looks like it is not that you won't be able to specify Version for your SIG custom image, but you will have to specify it differently.

    When platform images are used, you specify the publisher, offer, sku and version under imageReference, whereas with custom images, you only specify the id. The version number is included in the id of the custom image. If a version number needs to be specified in ARM template for custom image from SIG, the ID format would change as follows:

    "/subscriptions/subID/resourceGroups/rgName/providers/Microsoft.Compute/galleries/galleryName/images/imageName/versions/versionNumber"  
    

    Check out this GitHub issue around same: #68213

    --------------------

    Please do not forget to "Accept the answer" wherever the information provided helps you. This will help others in the community as well.

    0 comments No comments