Custom Image Template for Azure Virtual Desktop (AVD)

Creating custom image templates for Azure Virtual Desktop (AVD) streamlines and optimizes the deployment of virtual machines (VMs) by standardizing configurations across a workspace. This blog will walk through the process, advantages, and best practices for utilizing custom image templates, focusing on how this tool can benefit IT teams in configuring and maintaining efficient virtual environments.

Introduction to Azure Virtual Desktop Custom Image Templates

Azure Virtual Desktop (AVD) is a powerful platform that enables organizations to deploy and manage virtual machines (VMs) for a variety of use cases, from remote work to application development. One of the critical aspects of deploying these virtual desktops is ensuring that each machine is correctly configured and aligned with the organization’s needs. This is where custom image templates come into play.

A custom image template allows administrators to automate the creation of a standardized VM image that can be reused across multiple deployments. Instead of manually configuring each VM after deployment, IT teams can preconfigure an image with all the necessary settings, applications, and system customizations, significantly reducing the time and effort required to maintain the environment.

The Role of Azure Image Builder

The backbone of creating these custom images is the Azure Image Builder, a tool designed to simplify and automate the image creation process. Azure Image Builder allows you to define custom templates using JSON to describe the base image, any customizations required, and where the final image should be stored.

This tool leverages source images—either a Microsoft-provided image from the Azure Marketplace or a custom base image that you upload. The JSON templates you create specify the configuration steps, from installing applications to applying security updates and configuring environment settings.

Benefits of Custom Image Templates

Custom image templates provide several significant benefits for organizations:

1. Consistency Across VMs: With a custom image template, you can ensure that every VM deployed in your AVD environment is configured identically. This consistency improves the user experience by providing a familiar and reliable environment for end-users, regardless of which session host they connect to.

2. Automation of Repetitive Tasks: Manual configuration of VMs can be time-consuming and prone to errors. By automating the image creation process through a custom template, IT teams can focus on higher-level tasks while ensuring that each VM is correctly configured without human error.

3. Efficiency in Updates and Patching: When security updates or software patches are needed, IT administrators can update the custom image template and redeploy it across the environment. This allows for more efficient and streamlined patch management, reducing downtime and minimizing the risk of outdated or unpatched machines in the environment.

4. Cost-Effectiveness: Standardizing VM configurations with a custom image template allows for faster deployment and minimizes the need for post-deployment configuration. This translates to cost savings, particularly in large environments where time and resources are critical.

5. Flexibility: Custom image templates provide flexibility in terms of the operating systems, applications, and configurations included in the image. Organizations can tailor images to meet specific business needs, whether that means installing custom software, setting specific environment variables, or configuring security policies.

Steps to Create a Custom Image Template in Azure

1. Define Your Base Image

The first step in creating a custom image template is selecting the base image. This could be a stock image from the Azure Marketplace, such as a Windows 10 multi-session image, or it could be a custom base image that has already been preconfigured with some of the settings you need.

2. Create the Image Template JSON

Azure Image Builder utilizes a JSON-based template to define the process of building the custom image. The template includes details such as:

Source Image: Specifies the base image that will be used to build the custom image.

Customizations: Defines the steps required to configure the VM. This could include installing software, applying updates, running scripts, or making system changes such as configuring language settings or security policies.

Output Location: Specifies where the final image will be stored, whether in the Azure Compute Gallery or as a managed image in your Azure subscription.

3. Configure Customizations

One of the most powerful features of custom image templates is the ability to define customizations that are applied during the image creation process. These customizations can include:

Application Installation: You can configure the image to install necessary applications, such as Microsoft Office, custom business software, or security tools.

System Settings: System-wide settings like timezone, keyboard layouts, and language packs can be predefined to ensure all VMs have the same configurations.

Security Updates: Applying the latest security patches and updates ensures that each VM deployed is secure and compliant with organizational standards.

Custom Scripts: You can integrate custom PowerShell or Bash scripts to perform complex configuration tasks, making the image as customized and versatile as needed.

4. Build and Store the Image

Once the JSON template is finalized, you can use Azure Image Builder to generate the custom image. The image is created by applying the customizations to the base image and then storing the final result in Azure.

The image can be stored in one of two ways:

Azure Compute Gallery: This allows for easy reuse of the image across multiple regions and scales deployments.

Managed Image: This option stores the image as a managed resource within Azure, making it simple to reference during VM creation but limiting its availability to a single region.

5. Deploy VMs Using the Custom Image

After the custom image is built and stored, it can be used to deploy VMs in your Azure Virtual Desktop environment. When deploying a session host, you simply reference the custom image instead of a standard Marketplace image. This ensures that all VMs deployed from this image are preconfigured with the settings and applications defined in the image template.

Best Practices for Custom Image Templates

Regularly Update Images: Ensure your custom image template is regularly updated with the latest security patches and application updates. This helps minimize vulnerabilities in your environment.

Use Versioning: Maintain multiple versions of your custom image to accommodate different use cases or environments. For example, you might have one version of the image for development environments and another for production.

Test Before Deployment: Always test a new custom image in a staging environment before rolling it out to production. This ensures that all configurations are applied correctly and that the image behaves as expected.

Monitor and Audit: Keep an eye on the performance of VMs deployed using the custom image to ensure that they are running efficiently. Auditing tools within Azure can help track changes and identify potential issues with the image or its deployment.

A computer disk and a computer disk

Description automatically generated with medium confidence

To learn more, visit the official Microsoft documentation on Custom Image Templates for Azure Virtual Desktop

Here are some examples of the built-in scripts you can add to a custom image template:

  1. Install language packs.
  2. Set the default language of the operating system.
  3. Enable time zone redirection.
  4. Disable Storage Sense.
  5. Install FSLogix and configure Profile Container.
  6. Enable FSLogix with Kerberos.
  7. Enable RDP Shortpath for managed networks.
  8. Enable screen capture protection.
  9. Configure Teams optimizations. Optimizations include WebRTC redirector service and Visual C++ Redistributable.
  10. Configure session timeouts.
  11. Disable automatic updates for MSIX applications.
  12. Add or remove Microsoft Office applications.
  13. Apply Windows Updates.

The latest repository of these above scripts can be found in this Github Location.

Final Thoughts

Custom image templates for Azure Virtual Desktop are a powerful tool for streamlining the deployment and management of virtual machines. By leveraging Azure Image Builder and defining templates with custom configurations, IT teams can ensure consistency, improve security, and reduce the time spent on manual configuration tasks. This not only enhances the efficiency of the AVD environment but also ensures a better end-user experience, making it an essential component of any Azure-based virtual desktop deployment.

That’s all for today, you have a great day ahead.

0.00 avg. rating (0% score) - 0 votes