image
Automation ARM Templates Demo
Start course
Difficulty
Advanced
Duration
47m
Students
272
Ratings
4.7/5
starstarstarstarstar-half
Description

In this course, you will learn about host pools and session hosts in Azure Virtual Desktop.

Learning Objectives

  • Deploy and configure host pools and session hosts
  • Set up autoscaling for Azure Virtual Desktop
  • Understand Azure Virtual Desktop limits
  • Set high availability options for Azure Virtual Desktop
  • Use Azure Virtual Desktop session host join options
  • Automate Azure Virtual Desktop

Intended Audience

This course is for anyone planning to take the Azure Virtual Desktop Specialty exam and anyone interested in learning how to deploy an AVD environment.

Prerequisites

To get the most out of this course, you should have an administrator-level understanding of Azure Virtual Machines, Azure high availability solutions, Windows management join options, ARM templates, PowerShell, and the Azure CLI.

Transcript

Let's shift our automation discussion now to ARM template deployments. This is my public GitHub repository, and this code has been used by hundreds of my customers to deploy their AVD solutions or as a starting point to customize their own deployments. If you scroll down to the bottom, you'll see that there are three different 'Deploy to Azure' buttons. Each one of these will pull from a different template in the repo to deploy Windows 11 solutions, Windows 10, or specialized deployment for stateless AVD solution using ephemeral disk. Let's click the 'Windows 11 Deployment' button. This opens the Azure portal's custom deployment screen and you could just fill out the form and start your build. 

But first, click here to edit the template. Now, remember I said earlier that a session host is a standard Azure virtual machine that has agents added to it. So, this template is a standard VM build that will leverage VM extensions to add the agent. And let's walk through it quickly. Along the left, we have the different sections of the template and those are also represented on the right. The parameters are the inputs that you saw on that form on the last screen. The variable section can take those parameters and also provide other values before passing them off to the resources section. And it's the resource section that contains the things that you're going to build. 

Let me point out just two parameters for you: the OperatingSystem and VMSize. Now, the OS parameter has a default value of Windows 11 and only one allowed value, because this is the Windows 11 template. The VMSize, however, has multiple allowed values. But notice, they're not normal VM sizes. We have just small, medium, and large. This is because I like to keep my template inputs very clean and simple. This way, anyone can deploy them without asking too many questions. If we look down at the variables section and we look at VM sizes, we can see those same items of small, medium, and large. And those correspond to specific VM skews. Down in the resource section, if we take a look at our VM properties in the hardware profile area, this is where the VM sizes are needed. And the way this reads is grab the variable called VM_SIZE using the input of the parameter for VMSize and put the value here. 

So, if you selected small as your parameter, the value would be Standard_B2ms. Let's move on to the last section where the magic really happens. This is a VM's custom script extension. It allows you to run PowerShell on Windows VMs remotely. The PowerShell code we're executing is pulled from a variable here called firstFileName, and it's also using some arguments. Those arguments are listed here on line 107, and they come from two input parameters: ProfilePath, which relates to the share you're using for FSLogix, and the RegistrationToken, which is going to be used to add our VMs to the host pool. The script we're executing is found here on line 102. This code is linked also in my public GitHub and if we open it, we have a parameters block here at the top for ProfilePath and RegistrationToken, and this code is going to do many different things. It will create a temp Directory to store the agents we're going to download, and then it's going to extract those agents from their zip. 

It's going to discover which Operating System you have, so it installs things properly. Then it will install the agents with the registration key, then perform the FSLogix agent installation, and it's going to configure the standard FSLogix best practices. Once all of that is complete, it's going to reboot the VM. And now that you know how all this process works, let's build some hosts. Back in the form, I've filled out everything already, starting with the subscription and resource group at the top and the East US region, just like we've done throughout this course. The prefix this time will be Personal. This will be leveraging Active Directory join and the admin username is also going to be leveraged for the domain join process. 

So, I've added the appropriate credentials. Scroll down. You need to enter your Active Directory Domain's FQDN, then specify how many session hosts you want to build. I did also set a template hard limit for 100 VMs, but you could adjust that to suit your needs. The only Operating System that's available in this template is Windows 11. The size will be small, which you know from looking at the code is a B2ms skew. Then you specify your virtual network's resource group, the name of the VNET, and the subnet you want to build on. And now we have those custom script extension input parameters. For the ProfilePath, I'll use the SMB share for my FSLogix profiles and the RegistrationToken that I grabbed from the host pool earlier. Click the 'Review and Create,' and you can read through all of the details, and then click the 'Create' button. Once complete, you can have a look at your host pool and we see that we have a single personal VM registered.

 

About the Author

Dean Cefola is a Principal Azure Engineer at Microsoft and has worked in the IT industry for over 20 years. Dean has been supporting Azure Virtual Desktop from the beginning and is the Microsoft FastTrack Global Leader for AVD.