A lot of questions I receive about Windows Virtual Desktop (WVD) are about Image Management. Questions like; How can I create a custom image and apply updates on it? What about versioning and the possibility to rollback an image version? All these functions are available with Windows Virtual Desktop, together with the Azure Shared Image Gallery (SIG). In this blog I will show you step-by-step how to create an image, deploy a Windows Virtual Desktop Host pool with it, and update it with a new image version afterwards.
A great benefit of the Azure Image Gallery is that you can deploy your image to different Regions within Azure at the same time. This makes a Windows Virtual Desktop deployment over more then one region even easier. In this blog I will deploy an image to two Regions to show you how that works.
This blog is divided into the following steps:
The first step is to deploy a VM for creating a custom image with, for example, all the required Line Of Business (LOB) applications and updates. For the next steps, login to the Microsoft Azure Portal.
On the home screen of the Azure portal click + Create a resource
Search for Microsoft Windows 10 + Office 365 ProPlus (if you want to use a Windows 10 Multi-Session OS with Microsoft Office 365 ProPlus pre-installed on it) and click Create
Select your Subscription and create a new Resource group. Give the VM a name, select Region and a VM Size. Fill in the information for the local admin account and click Next : Disks
Select Premium SSD and click Next : Networking
Select the correct Virtual network and Subnet and click Next : Management
Turn off the Boot diagnostics. Click Review + create
Connect to the Virtual Machine and install the required LOB applications. Also think about Windows and Store updates. When your finished with the installation and configurations, shut down the Virtual Machine.
Windows 10 allows us to run Sysprep 1001 times. Therefor it is not required to make a snapshot before running Sysprep, but its recommended to have the option to go back to an older version of your image. You can do this with a disk Snapshot where you can create a new VM of (see next steps in this blog). Therefor it is a good moment to make a disk Snapshot after every update like in this case.
Make sure the Virtual Machine have the Stopped (or deallocated) status,
Open the Virtual Machine and go to the Disk blade. Next, click on the OS Disk.
Click + Create snapshot
Select the in step 1 created Resource group and give the Snapshot name. If you are plan to create multiple versions like I do, it’s good to think about a good name convention. Also we make a Snapshot before Sysprep and a Capture after Sysprep (in the next step). Therefor I apply the following name convention:
BS = Before Sysprep in this case so I know this version is before I have run Sysprep and can be used for the next update.
Click Review + create
After creating the Disk Snapshot, start the Virtual Machine back up again.
Connect to the Virtual Machine and run Sysprep. (C:\Windows\System32\Sysprep\sysprep.exe). Make sure to select Generalize and to set the Shutdown Option to Shutdown
After the Virtual Machine has been turned off. De-allocated the Virtual Machine (select it in the Azure Portal and click Stop). After the Virtual Machine has the de-allocated status, go the Overview blade, and click Capture
Give this Capture / Image a name. In this case I will give it a name with the following name convention:
AS = After Sysprep in this case. This so I know this version is after I have run Sysprep and I can use it for image deployment.
Select Automatically delete this virtual machine after creating the image. Type the virtual machine name and click Create
Before we can upload the custom image, we need to create a Shared Image Gallery (SIG) first. In the Azure search bar, search for Shared Image Gallery and open it.
Click Create shared image gallery
Select your Subscription and the Resource group you want to use. Give the Shared Image Gallery a name (in this case I will name it WindowsVirtualDesktop) and select a Region.
Click Review + create
Open the just created Shared image Gallery (in my case WindowsVirtualDesktop)
Click + Add new image definition
Select your Region. Give this Image definition a name, this name will be visible when deploying a Windows Virtual Desktop host pool.
Configure the following:
Operating system : Windows
VM generation : Gen1
Operating system state : Generalized
Fill in a Publisher, Offer and a SKU name of choice.
Click Next : Version
Fill in a Version name, this must be in the x.x.x format. Of course, you can start with 1.0.0, but you can also use a date like I do. In this case my version is: 2020.05.30 (next version needs to be higher of course).
Set Exclude from latest to No. Fill in an Image version end of life date and the regions you want to make this image available. I will deploy VMs with this image to the West Europe and East US so I select both locations.
Click Review + create
Within the Azure portal, go the Windows Virtual Desktop
Click Create a host pool
Select your Subscription and Resource group. Give the Host pool a name and select the Location. Select the Host pool type, the Max session limit and the Load balancing algorithm. Click Next : Virtual Machines
Select the Resource group for the Session Host servers and the Virtual machine location. Fill in the Number of VMs you want to create in this Host pool and enter a Name prefix name.
For the Image type, select Gallery, and click Browse all images and disks
Click My Items, select Shared Images and click the image created in the previous step.
Select the OS disk type and configure the network settings. Click Next: Workspace
Select a Workspace or create a new one. Click Review + create
I repeated these steps for the East US region, so I have two servers in West Europe, and two in East US with the same image as source.
Before we can update the custom image, we need to create a Disk with the Snapshot (before Sysprep) as sources. Next, we can create a new VM from that disk. I will show you step-by-step below.
Within the Microsoft Azure portal, go to Disks and click + Add
Select the Subscription and the Resource group. Give the Disk a name. I give it the name of the snapshot with “-Restored” at the end. So in my case “WVD-Win10MS-2020-05-30-BS-Restored”.
Select Snapshot as source, and select the snapshot created in previous steps. Make sure the Disk Size is correct. Click Review + create
After the deployment is complete, click Go to resource
Click + Create VM
Select the Resource group of choice and give the Virtual machine a name. Make sure the correct Image is selected and click Next : Disks
Click Next: Networking
Configure your network settings and click Next: Management
Set Boot diagnostics to off and click Review + create
After the deployment is complete, login to the VM and make the required changes.
When your finished with the changes in the VM, repeat Step 2 (Make a disk Snapshot) and Step 3 (Creating a Virtual Machine Capture) of this blog (with new dates in the snapshot and image name).
Now that we have a new image version (VM Capture) we need to add this to the current custom image in the Shared Image Gallery.
Go to the Shared Image Gallery and click the WindowsVirtualDekstop Shared image gallery.
Click the custom image created in previous steps.
Click + Add Version
Fill in the Version (date of image in my case) and the Source image. Make sure Exclude from latest is set to No. Select the Target regions and click Review + create
In this final step we are going to update the Windows Virtual Desktop Host pool with the new version of the custom image. We do this by creating new Session Host VMs and enabling Drain mode on the old (current) VMs. If for some reason the new version of the image is not working you have a fall back to these (old) servers.
But first we need to add the new servers.
Within the Windows Virtual Desktop portal, navigate to Host pools > <your host pool> > Session hosts and click the + Add button.
Click Next: Virtual Machines
Select the Resource group and the Virtual machine location. Fill in the Number of VMs you want to add to this Host pool. Note that all other options are grayed out. Scroll down
Configure your network settings and click Review + create
After the deployment is finished, the new servers are added to the Windows Virtual Desktop Host pool, created with the latest version of the custom image.
Now you can enable the Drain mode on the old VMs (VMs created with an old version of the custom image) and test the new version of the custom image. If all tests are successful you can delete the old servers.
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.