Automation Azure CLI/PowerShell
Start course

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.


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.


Because the possibilities are nearly limitless with scripting and automation, we'll just go through a few examples. Just know that for the exam, you'll need to be very familiar with all of the commandlets in both Azure CLI and  PowerShell. I've opened another web page here,, which is the Azure Cloud Shell, but lets me view it as a full screen. If I click here, we can open the editor and you see that I've created a file called Cloud Academy and I've put in the commands that we're going to use, and this will just make it easy to talk through everything before we execute. The first command is going to be using the Azure CLI and it's going to create a new host pool. Now if you think back to when we did the portal build, we've got to answer all of those same questions using the code. 

Just a quick word on the Azure CLI. It's structured by using the command AZ and then using a resource provider, in this case, desktopvirtualization, and then you have your resource, which is a HostPool and the command is to Create. Our location will be in the East US and I've added a description and friendly name of Personal. The HostPool type will also be Personal. The Personal-desktop-assignment-type is automatic. The preferred-app-group-type is desktop, because personal HostPools only support desktop app groups. The registration info has to do with the expiration of your registration token, and that's going to use this date and time, and then have a operation of update. Start-vm-connect will be set to true and we do have a vm-template section here, but it just says json because we're not actually building VMs at this time, but if you wanted to you could add that information here. 

And we've got our standard tags like we've used in the rest of this course. The name for this Pool will be Personal-HP and the resource group will also go into the FirstPool-RG. So, we'll just copy all of that code and then paste it into the  Cloud  Shell and click 'Enter'. That Pool will be built in just a moment. When we go back to the resource group, we can now see that we have a personal HostPool. Now let's look back at our first Host Pool at the RDP properties advanced section, and this is the default configuration of every HostPool and you can see that there's a lot here. Back in the  Cloud  Shell, the next command we want to run will change those RDP properties and it will only allow microphone, and camera redirection and set the multimonitor to support to no. We'll copy that and execute, and then back in our RDP properties, we can see that our settings have changed accordingly. 

The next demo, we'll create an empty remote application group. This requires a name and a resource group and an app group type, which in this case is RemoteApp. Then we need the resource ID of our HostPool that the app group will belong to. I found this in the Azure portal by going to the Host Pool properties blade. Just copy the resource ID here and then paste that in your code, and we'll put all of that in the  Cloud  Shell and click 'Enter'. Back in the Azure portal, we'll look at our resource group and see we have a new remote application group. And if you look at the FirstPool-HostPool in the application group blade, you can see that new remoteApp group there as well. 

Now let's click on that app group. Notice that there are no applications listed yet. So, let's go back to the Cloud Shell. Our next command is going to use  PowerShell and it's going to create a new application inside that group. PowerShell and Azure CLI commands are constructed differently. PowerShell is based on a Verb-Noun and the Azure CLI is AZ and then a resource provider. So, the verb, in this case, is New and the noun is AzWVDApplication. We'll need to reference our resource group and the app group name of Monet. The name of the app we'll create is called Paint. Then we need to give it a file path to the mspaint.exe. The IconIndex of zero tells the system to use the first icon embedded in that executable. Then we'll need a path to the icon file which is the same as our executable. The command line setting of allow lets you pass commands when the application runs and the show in portal will allow the app to be visible. 

Copy and paste the code into the  Cloud  Shell and click 'Enter' and you get a simplified return here. Back in the Azure portal, we have a new app in our app group, and if you click on that, you'll see the app name of Paint. And if you click on Paint, you'll see the details of that app that we supplied from the code. There's one more thing I want to do here and that's change the display name from Paint to Monet. So, back in the Cloud  Shell, we'll do this through  PowerShell as well, and the verb this time will be Update and the noun is AzWVDApplication. We'll reference our resource group and the group name of Monet, the name of Paint, and give it a friendly name of Monet. We'll copy and paste that code and then back in the portal, we see the display name changed to Monet.


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.