Azure Pipelines with AIB and SIG to WVD

Mike Lister 21 Reputation points
2020-11-17T20:48:37.01+00:00

Hi,

I'm looking for some resources or information regarding Building an image using Azure Image Builder (AIB), storing the image in Azure's Shared Image Gallery (SIG) and then deploying the image to 800 or so VM's in Azure's Windows Virtual Desktop (WVD).

I've been following Daniel Sol from Github (https://github.com/danielsollondon/azvmimagebuilder/blob/master/solutions/1_Azure_DevOps/BuildaPipeline.md)

There is a video he's done on Youtube talking about it as well and mentions to deploy software have it in your Repo and it will get downloaded to the VM during the build process and then you can run installations. In his example he uses a Server, I'm trying Win10 Multi Session edition and using his powershell technique on Inline customization script suggests each line can trigger a different install.

Examples of software would be FSLogix, 7Zip for example

There is also a tickbox on the image builder task to install any updates required so this would be a great way to inject updates into the image using a CI\CD pipeline to keep our image up to date with the latest updates and applications.

I've read that AIB is actually using Packer and found this article from last year that does something similar (https://jrudlin.github.io/2019-09-02-windows-virtual-desktop-azure-devops-ci-cd-packer-build-and-release/) with a similar approach but mounting a drive and installing applications from Azure Storage instead.

I'm looking for more examples updated or guidance to get this working either in stages (Stage 1 create an image and deploy to the gallery, stage 2 deploy the image to WVD)

Thanks

Mike

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,276 questions
Azure Virtual Desktop
Azure Virtual Desktop
A Microsoft desktop and app virtualization service that runs on Azure. Previously known as Windows Virtual Desktop.
1,652 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 27,986 Reputation points
    2025-01-19T11:59:13.7+00:00

    You can break the process into two primary stages:

    **Stage 1: Build the image and store it in the Shared Image Gallery (SIG) :**Set up the AIB:

    1. Follow the guide provided by Daniel Sol's GitHub repository (it is detailed)
      • Create a JSON template to define your image-building steps. For example:
      - Specify the base image (Win10 Multi-Session).
      
      - Add customizations (install FSLogix, 7Zip...) using inline PowerShell or scripts stored in Azure Storage/Repo.
      
      - Include updates by enabling `installUpdates` in the template.
      
         "inline": [
         "powershell.exe -command Install-Module -Name FSLogix -Force",
         "powershell.exe -command Invoke-WebRequest -Uri 
         "powershell.exe -command Start-Process -FilePath C:
         ]
      

    1.Create an Azure DevOps pipeline:**

    • Use the Azure CLI task to submit the AIB template for building. yaml
      • task: AzureCLI@2

    inputs:

    azureSubscription: 'YourServiceConnection'
    
    scriptType: 'bash'
    
    scriptLocation: 'inlineScript'
    
    inlineScript: |
    
      az image builder create --resource-group YourResourceGroup \
    
      --image-template ./path/to/your-template.json
    
          
    
    1. Output to SIG: Configure the AIB template to publish the built image to the SIG and specify the target SIG resource group and image definition details.
    2. Trigger CI/CD Updates: Add a pipeline task to trigger builds on code changes or on a schedule ( for ecample monthly updates).

    Stage 2: Deploy the image to Windows Virtual Desktop (WVD)

    1. Define the WVD Environment: You need to have a WVD host pool configured so yoy can use Azure PowerShell or the Azure CLI to manage the host pool and VM deployment.
    2. Create a DevOps Release Pipeline:
      • Use the image version stored in the SIG to deploy VMs and add tasks to:
      • Provision VMs using the image from SIG.
      • Assign them to the WVD host pool.
      yaml
      • task: AzureCLI@2

    inputs:

    azureSubscription: 'YourServiceConnection'
    
    scriptType: 'bash'
    
    scriptLocation: 'inlineScript'
    
    inlineScript: |
    
      az vm create --resource-group YourResourceGroup \
    
      --name YourVMName \
    
      --image /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Compute/galleries/<gallery-name>/images/<image-name>/versions/<image-version> \
    
      --size Standard_D2_v3 \
    
      --admin-username azureuser \
    
      --generate-ssh-keys
    

    Then use inline PowerShell scripts or DSC extensions to automate FSLogix configuration on each VM during deployment.

    Links to help you :

    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/image-builder-overview

    https://learn.microsoft.com/en-us/azure/virtual-machines/shared-image-galleries

    https://learn.microsoft.com/en-us/azure/virtual-desktop/

    https://learn.microsoft.com/en-us/fslogix/overview

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.