Standardizing VM Configurations: Leveraging Custom Image Templates in Azure Virtual Desktop

Hello Guys,



Azure Virtual Desktop is a service that allows you to run Windows desktops and applications in the cloud. One of the benefits of Azure Virtual Desktop is that you can customize your session host virtual machines (VMs) with the applications and settings that you need for your organization.

However, creating and maintaining custom images can be a tedious and time-consuming process. You have to install and configure the software, run sysprep, capture the image, and distribute it to different regions or galleries. What if there was a simpler way to do this?

That’s where custom image templates come in. Custom image templates are a new feature in Azure Virtual Desktop that lets you easily create a custom image from a JSON file that defines what should be in the resulting image. You can use custom image templates to:

– Choose a source image from the Azure Marketplace, an existing gallery image, a managed image, or another custom image template.
– Add Azure Virtual Desktop built-in customizations, such as language packs, FSLogix, Teams optimizations, Windows Updates, and more.
– Add your own customization scripts to install other applications or set of configurations.
– Specify the distribution targets for your custom image, such as Azure Compute Gallery or managed image.

Custom image templates are built on Azure Image Builder, a service that automates the creation of customized images. Azure Image Builder uses a user-assigned managed identity to create and distribute the custom image in your subscription.

To create a custom image template, you need to write a JSON file that contains the following sections:

– Source: The source image that you want to use as the base for your custom image.
– Customize: The list of customizations that you want to apply to your source image. You can use built-in scripts from Azure Virtual Desktop or your own scripts hosted at a publicly available location.
– Distribute: The list of distribution targets for your custom image. You can choose between Azure Compute Gallery or managed image, or both.
– Properties: The properties of your custom image template, such as build timeout, vm size, os type, etc.

Here is an example of a custom image template JSON file:

json
{
  "source": {
    "type": "PlatformImage",
    "publisher": "MicrosoftWindowsDesktop",
    "offer": "Windows-10",
    "sku": "20h2-pro",
    "version": "latest"
  },
  "customize": [
    {
      "type": "PowerShell",
      "name": "Install FSLogix",
      "runElevated": true,
      "scriptUri": "https://raw.githubusercontent.com/Azure/RDS-Templates/master/ARM-wvd-templates/CreateAndProvisionHostPool/CreateHostpoolTemplate.ps1"
    },
    {
      "type": "PowerShell",
      "name": "Configure Profile Container",
      "runElevated": true,
      "scriptUri": "https://raw.githubusercontent.com/Azure/RDS-Templates/master/ARM-wvd-templates/CreateAndProvisionHostPool/ConfigureProfileContainer.ps1"
    },
    {
      "type": "PowerShell",
      "name": "Install Teams Optimizations",
      "runElevated": true,
      "scriptUri": "https://raw.githubusercontent.com/Azure/RDS-Templates/master/ARM-wvd-templates/CreateAndProvisionHostPool/InstallTeams.ps1"
    },
    {
      "type": "PowerShell",
      "name": "Apply Windows Updates",
      "runElevated": true,
      "scriptUri": "https://raw.githubusercontent.com/Azure/RDS-Templates/master/ARM-wvd-templates/CreateAndProvisionHostPool/ApplyWindowsUpdates.ps1"
    }
  ],
  "distribute": [
    {
      "type": "ManagedImage",
      "imageId": "/subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.Compute/images/<imageName>",
      "location": "<location>",
      "runOutputName": "<runOutputName>"
    }
  ],
  "properties": {
    "buildTimeoutInMinutes": 60,
    "vmSize": "<vmSize>",
    "osType": "<osType>"
  }
}

To build the custom image from the template, you need to submit it to Azure Image Builder using PowerShell or Azure CLI. You can also use the Azure portal to create and submit the template using a graphical interface.

For more information on how to use custom image templates for Azure Virtual Desktop, you can read the blog post announcement, the documentation, or the Microsoft Learn module.

Custom image templates are a great way to simplify and automate the creation of customized images for your Azure Virtual Desktop session hosts. With custom image templates, you can easily standardize the configuration of your session host VMs and ensure that they have the latest features and updates.

Try it out today and let me know what you think!

Leave a Reply

Your email address will not be published. Required fields are marked *