With Windows 365 Enterprise, you can create a custom image to deploy a cloud PC. It requires an Azure Managed Image. This can be made from a virtual machine(VM) in Azure. However, the VM cannot be used after getting “Generalize.” In this article, I’ll go through how to ensure you can use the same VM repeatedly to update your custom image for Windows 365.
If you haven’t tried creating a custom image for Windows 365 before, you can check out my other blog post.
The issue when creating Azure Managed Image
To create an Azure Managed image, you have to “Generalize” the VM. once it’s Generalized, it will become unusable. You have to create a new VM and begin from scratch if any changes are needed. You can create a temporary VM to resolve this, but it doesn’t come without some flaws. Many steps need to be done when doing it this way. IT admins have to be comfortable managing Azure Compute resources and be aware of changes inside the portal.
To simplify things, I have created a simple PowerShell script running inside an Azure Automation account to execute the whole process of creating the temporary VM and the Azure Managed Image. We’ll come to that later on.
The manual process of creating the temporary VM
The steps below are needed to create the temporary VM and the Azure Managed Image. When you want to add something to your custom image, you’ll have to do the following:
- log in to the origional VM
- Make changes e.g. install program, language pack etc.
- Deallocate the VM
- Create snapshot of virtual OSDisk
- Create temporary OSDisk from snapshot
- Create a new temporary VM based on the new temporary OSDDisk
- login to the temporary VM
- Sysprep the temporary VM
- Create the Azure Managed Image from the temporary VM
- Delete temporary VM ressources
This can easily take around 30-45 minutes each time.
The solution with Azure Automation
So what I have done is I have created a PowerShell script and uses Azure Automation that takes care of everything from step 4 to 11, this way, you can use your time of what’s essential.
If you are not familiar with Azure Automation Account and how to use it to authenticate to the Azure Services, I recommend looking at Michael Mardahl’s Blogpost.
You still have to log in to the VM, make changes, and log out. After that, run the Runbook in Azure Automation, and the magic should happen. Let’s start from the top by logging in to the VM.
Find the Azure VM you use for your custom image and connect to it.
Customize Windows 365 image
When logged into the VM, go and make the changes you need. Remember to log out when you are done.
Create a new runbook in Automation Account
Go to your Azure Automation account, create a new runbook, and copy the PowerShell from my GitHub repo or the drop-down below. After the import, go and edit the parameter CustomImageVMName. This should be the VM name of your Custom image VM.
Running the runbook and check the result
When starting the Runbook, you’ll have to choose what the name of the Azure Managed Image should be. You cannot use the same name twice for a Managed Image. Don’t worry. The script will check if the name is available.
When the Runbook has been completed, you can see that an Azure Managed Image has been created inside the same resource group as your Custom Image VM. You can also see the creation process by checking the completed job in Azure Automation.
Upload custom image to Windows 365
The last thing you have to do is upload the new Image to Windows 365. head to https://endpoint.microsoft.com and go in and Add a device image.
Fill out the information about Image Name, Image Version and select your new Managed Image.
After you click Add the custom Image will upload, and you can assign it to a provisioning policy.
Automating a process like this makes everything much more manageable. This way, the process of creating the Custom Image will be documented, and you don’t have to remember detailed information about the setup. This method can also be used for other purposes, such as Azure Virtual Desktop image management.