Work with Azure Image Builder
This blog is about using Azure Image Builder (AIB) to create custom images based on Azure marketplace images. By default, all Azure marketplace images are in English US with other region and format settings than we use in Europe. Therefore, it’s necessary to customize the marketplace image.
Changing the language or region is one of the things you can customize with AIB. I choose this example because it’s hard to find info from A to Z about customizing languages on Azure marketplace images with AIB.
In my demo scenario I divided all the steps into separate actions to make it more easy to read, but you can combine it easily in GitHub Actions or Azure DevOps. Also, you can use the variables from Azure DevOps variable groups or retrieve info from Azure key vault to fill the variables.
All scripts can be found on my GitHub and can be used in other environments when changing variables. The variables can be found in the vars folder. Always check first before running scripts! |
Scenario:
- You want to use a different language and regional settings for Windows 10 Enterprise or Windows 10 Enterprise multi-session images from the Azure marketplace.
- The image will be created by using the Azure Image Builder service.
Prerequisites:
- An admin account with global administrator rights and full permissions on the subscription.
- Integrate your Azure tenant with GitHub (Actions) or Azure DevOps (Pipelines) to run the code using yml files.
Prepare for Azure Image Builder (AIB)
What we need to have before we can start using the Azure Image Builder service:
- Register the resource providers needed for AIB in your subscription and create a resource group. Deploy all resources in the same resource group!
- User-Assigned Managed Identity that will be used for creating resources and add the image to the image definition in Azure Compute Galleries.
- Create and add custom role(s) on the resource group and add the User-Assigned Managed Identity as a member.
- Create the Azure compute gallery with the image definition you want to use. The image definition must match the marketplace image Publisher, Offer and SKU.
- Register the resource providers needed for AIB in your subscription and create a resource group. Deploy all resources in the same resource group!
The GitHub actions are generic and can be used directly in other environments. Every action starts with a GitHub workflow that will address all necessary files and variables to implement resources. Please adjust those related files and variables before using it in your own environment! |
Check the action deploy-wvd-aib-identity. It will do the following:
- Get the PowerShell modules and install those (only necessary via yml).
- Create a resource group for storing Azure Virtual Desktop related objects.
- Register Resource Providers for your subscription needed for AIB.
- Check if user identity exists otherwise create it.
- Fill the json template for the custom AIB role with variables.
- Assign the custom AIB role to the user identity created in step 4.
- Create an Azure compute gallery so we can store images build by AIB.
To check if the script ran successful, go to your resource group you mentioned in the script. Open Access Control (IAM) and look for the custom role Azure Image Builder with the managed identity assigned to it.
Download necessary language files (not needed anymore see build-wvd-aib-multi-image.json)
Now we need to gather all the necessary files that we can use as customization input in AIB. Most of the files can be downloaded here: https://docs.microsoft.com/en-us/azure/virtual-desktop/language-packs
The version numbers can be changed overtime so check what version you need.
Language (LangPack) – Windows 10, version 2004 or later Language Pack ISO
LXP (LanguageExperiencePack) – Windows 10, version 2004 or later 02c 2022 LXP ISO
Apps (APP) – Windows 10, version 21H1 or 21H2 Inbox Apps ISO (files in amd64fre folder)
After you downloaded all those files but them together in a folder. APP folder with files like:
Beware contains all apps in the APP folder you want to use with your custom image. You will need the specific language for the app as well. Otherwise, sticky notes will not be “plaknotities” in dutch, and the app will not work properly.
When you have a virtual machine based on the custom image it’s necessary to update the Appx packages per user. You can use this script Schedule-Appx-Update.ps1. |
LangPack folder containing the dutch language pack:
LXP folder with a folder called NL-NL and the files below:
Create custom registry files
Those files are needed for the “Welcome screen and new user accounts settings”. We need to do this step manually so we can export the registry and use it during the AIB process.
Steps you need to do:
- Create a VM based on the marketplace image you want to use in Azure.
- Login with the admin account on the new created VM.
- Install an additional language and select your region.
- Change the regional and Welcome screen and new user accounts settings like you want to use it.
- Export the HKU\.DEFAULT hive, and created a duplicate
- changing the hive to HKU\DEFAULT_USER for the default user account and keeping the original for the Welcome Screen account.
If you want an example, check the reg files here and use change the NLRegion.xml to the region you want to use.
Create package from Language files
Now that we have all the necessary files, create a zip file to bundle all necessary Language files.
Your directory will contain the following files:
Beware that your Language-Files.zip file must be reachable for Azure Image Builder to used it during building process. |
Azure Image Builder
We are ready to start the actual building process with Azure Image Builder. Check the files in the resource folder. It contains baseline files that you can use to apply configuration on the Windows 10 Enterprise multi-session image for Azure Virtual Desktop.
The action build-wvd-aib-multi-image will do the following:
- Generate a unique version number major.minor.revision needed for Azure Compute Galleries.
- Upload the baseline configuration file(s) needed to Azure storage blob container and generate a SAS URL that can be used during deployment.
- Use the version number generated earlier to submit the Azure Image Builder template with a unique name to the Azure Image Builder service.
After the process is completed successfully, you will see an image version in your image definitions within Azure compute galleries.
After the process is done you will find all the resources in the resource group you used for the whole Azure Image Builder process.
Remove image template
There will be a resource group called something like IT_\DestinationResourceGroup_\TemplateName_\(GUID) that was used for the AIB process. Within this resource group you will find a storage account with the packer logs. Check the customization.log for errors. If the process failed you will not see an image version in Azure compute galleries.
The resource group will be deleted automatically when you remove the Image template.
AIB AVD Azure Compute Galleries Azure Image Builder Azure Virtual Desktop