YannickRe / azuredevops-buildagents

Generate self-hosted build agents for Azure DevOps, just like Microsoft does.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why is update_vmss_imagevm stage governed by a conditon

RobBowman opened this issue · comments

I have a bicep template the provisions required resources such as image gallery.

I have run now run the pipeline from this repo. It created the image and added to the gallery. I'm a little confused as to why the main buildagent-generation-template pipeline runs 'Create Gallery Image Version VM' OR 'Update VM Scale Set to new Image'. I would have thought it would need to create the gallery image then assign that to the scale set?

Good question, and luckily the answer is fairly easy 🙂. The Build Script allows for two different modes:

  1. The older mode where the Scale Set would be directly linked to a managed image. That's the 'Update VM Scale Set to new Image'.
  2. The newer mode where the managed image is added as a new version in the Gallery. In that mode, the Scale Set is configured to use the images in the Gallery and will use the latest image to start a new VM. That's the 'Create Gallery Image Version VM' task.

So essentially, it's up to you what approach you want to take (but the Gallery option is easier and cleaner).

Thanks for replying Yannick. I went with the option to create the gallery image. My problem was I then needed to update the VMSS to set the image reference to point at the gallery. I found the PowerShell to do this in your "update-vmss.ps1".

It's not a big problem, just a minor 2nd step that perhaps wouldn't be required if the buildagent-deneration-template.yml ran create_gallery_imagevm AND update_vmss_imagevm stages?

I assume this is a lack of proper documentation from my side, because if you use a Virtual Machine Scale Set and a VM Gallery, you have to configure the VMSS one time to point to the Gallery, like this:
image

In that scenario you should never be needing the update_vmss_imagevm stage nor the update-vmss.ps1 PowerShell script. The VMSS already knows to fetch the image from the Gallery, and the only thing you need to run is create_gallery_imagevm stage. it will create a new version of the image in your Gallery and the VMSS will pick it up automatically.

Yes, I think you're right - it's just a one-off action to point the vmss at the gallery. I just wanted to be sure I wan't missing something. Thanks for your help and for this excellent repo.

@RobBowman You are most welcome (and the latest amazing addition came from the community). Feel free to reach out if you need any more help!