Configuring Automation for Azure Virtual Desktop
Configuring Automation for Azure Virtual Desktop

An important aspect of any Azure Virtual Desktop (AVD) environment is ensuring you automate management of the environment where you can. To get the most out of this cloud-hosted service, it is important to ensure you are utilizing automation to limit the amount of time spent doing manual tasks. This will give a much better experience for your users and administrators. From an automation perspective, you can utilize Azure native services to facilitate automating daily management tasks which will minimize manual intervention by admins.

This course will help you plan and automate management tasks for your Azure Virtual Desktop and help you understand how it integrates with other Azure native automation services.

Learning Objectives

  • Configure automation for Azure Virtual Desktop
  • Automate management of host pools, session hosts, and user sessions by using PowerShell and Azure Command Line Interface (CLI)
  • Implement autoscaling in host pools

Intended Audience

This course is intended for anyone who wants to become an Azure Virtual Desktop Specialist and/or those preparing to take the AZ-140 exam. 


If you wish to get the most out of this course, it is recommended that you have a good understanding of Azure administration, although it's not essential.


Welcome to this module on configuring automation for Azure Virtual Desktop.  In this module, we will cover the following:

  • We will look at how scaling works
  • Prerequisites for Automation with Azure Virtual Desktop
  • Finally, we will look at the high-level steps you need to complete when configuring Azure Automation for AVD 

Let’s start this module off by discussing how scaling works.  There are different ways in which you can utilize scaling within Azure Virtual Desktop.  You can start and stop virtual machines during peak and off-peak usage hours.  You can Scale out virtual machines based on the number of sessions per CPU core.  Finally, you can scale in virtual machines during off-peak hours so only a few VMs are running.

We are now going to move on to looking at the prerequisites you need to complete before you can integrate automation with Azure Virtual Desktop.

You need to have a functioning Azure Virtual Desktop host pool within your environment.  Your session hosts need to be registered with the Azure Virtual Desktop Service.  You then need to ensure the account you are using to configure automation has at least contributor access to the entire subscription.

Finally, you need to ensure the management machine you are using to complete this deployment has the relevant tools on.  Ensure PowerShell 5.1 or later is installed on this management machine, and you will need to install the Azure Az PowerShell module to be able to complete the configuration.

In the final lecture of this module, we will look at the high-level steps you need to complete in order to configure Azure Automation for Azure Virtual Desktop.

The first step is to create an Azure Automation account which can be completed via PowerShell. If you have an existing automation account you can also utilize this, however, you will need to follow a specific process to update this account if required.

The next step is to create an Azure Automation run as account. This provides authentication for managing resources in Azure with Azure cmdlets.  Once you have created the relevant automation accounts you then need to create an Azure Logic App.  You will need to download and import the Desktop Virtualization PowerShell module to use within your PowerShell session for this step.

Finally, you will need to create the execution schedule for the new scaling tool.  The PowerShell script will need to be run for each host pool you want to autoscale, but you only need on Azure Automation account.

About the Author

Shabaz Darr is a Senior Infrastructure Specialist at Netcompany based in the UK. He has 15 years plus experience working in the IT industry, 7 of those he has spent working with Microsoft Cloud Technologies in general, with a focus on MEM and IaaS. Shabaz is a Microsoft MVP in Enterprise Mobility with certifications in Azure Administration and Azure Virtual Desktop. During his time working with Microsoft Cloud, Shabaz has helped multiple public and private sector clients in the UK with designing and implementing secure Azure Virtual Desktop environments.