question

JHStarner avatar image
0 Votes"
JHStarner asked ·

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

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
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JHStarner avatar image
0 Votes"
JHStarner answered ·

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://docs.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!

· 3 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JHStarner , Glad that it worked for you! I will communicate this to the PG to update in the doc.

0 Votes 0 ·

@JHStarner , just checking in to see if you got a chance to look at my comments. Request you to mark my response as answer instead.

0 Votes 0 ·

@JHStarner , just checking in to see if you got a chance to look at my comments.

0 Votes 0 ·
HarshitaSingh-MSFT avatar image
0 Votes"
HarshitaSingh-MSFT answered ·

@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.





·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.