AVD Script-Based Integration to Manage Azure Virtual Desktop Host Pools

Subscribe to our blog

The script actions for Azure Virtual Desktop (AVD) in ControlUp, as introduced in a recent blog post, are mainly focused on the Host Pool and Session Host configurations. To keep you from switching back and forth between the ControlUp Console and Azure portal, we have integrated the Azure portal AVD actions via our script actions.

First things first

To use the script actions for AVD Host Pools, make sure you have followed the instructions from our knowledge base article Azure Virtual Desktop Setup Guide for ControlUp Integration to configure the script-based integration for AVD and to be ready to start managing your AVD Host Pool settings.

Show us the goodies

Once you have ControlUp configured for the script-based integration for AVD, you are all set to import our AVD Host Pool focused Script Actions from the Script Library:

NOTE: Make sure you import the AVD Store Azure Service Principal Credentials Script Action, as the AVD Stored credentials need to be configured in order to use the above Script Actions as they all re-use those stored credentials.

Figure 1 – AVD Store Azure Service Principal Credentials script action

All the Host Pool-focused script actions can be run from the Script Actions Context Menu of a AVD Session Host in the console, so you can immediately start mitigation actions for your AVD configuration, based on the monitoring feedback of those AVD Session Hosts. And the cool part is that the AVD script actions for the Hostpools can easily be run from a Session Host, as they will automatically retrieve the Hostpool information that the Session Host is a member of. You do not have to manually add that information when running a AVD Script Action.

Figure 2 – AVD Hostpool Script Actions available from the Script Actions context menu

Retrieve Hostpool information

We have created a number of Script Actions to retrieve the current configuration of your AVD Hostpool, based on the selected Session Host you run that action on. Let’s take a more detailed look at what each Script Action has to offer.

AVD Get Hostpool

This script gives you detailed information on the AVD Hostpool configuration. Based on the Session Host which you run the script, it will return the AVD Hostpool information for that Session Hose (similar to the information presented in the Azure portal). It will even check if the required PowerShell modules are installed and automatically install any missing module, as is shown in the example below.

Note: Keep in mind that the script action needs some additional time before showing the results when a missing PowerShell module is automatically installed.

Figure 3 – AVD Get Hostpool Script Based Action results

If you check the AVD Hostpool properties in the Azure portal, you’ll notice we made sure to provide you with the same detailed information.

Figure 4 – AVD Hostpool properties in the Azure portal

AVD Get Hostpool Session Hosts

Even though the AVD Session Hosts can already be sorted by Hostpool in the tree view in the left pane, we did want to provide a script action that will give you an overview of all Session Hosts in a particular Host Pool, by running the action on any Session Host within a Hostpool. This script will require no additional input information—such as a Hostpool name—as it will automatically retrieve that information from the AVD Session Host that is used to start the script action. So, even if you are not using the AVD-focused tree view in the left pane, you can still get a quick overview of all the Session Hosts that belong to a Hostpool.

Figure 5 – AVD Get Hostpool Session Hosts Script Based Action results

Where the tree view in the left pane gives you a quick overview of the Session Hosts in a Hostpool, it does not provide you with detailed status, drain mode, and active sessions information, like this does. And combined with the real-time monitoring information from the ControlUp Console, you’ll have all the information you need to keep track of your AVD Hostpool configuration and performance.

Figure 6 – AVD Session Host monitoring information

AVD Get Hostpool Application Groups

This script action will give you detailed information on the AVD Application groups that are configured and linked to the Hostpool. It will even show you Application Group Type, total number of applications, and the total number of Users (or Usergroups) assigned to that Application Group.

Figure 7 – AVD Get Hostpool Application Groups results

AVD Get Hostpool User Sessions

And even though the ControlUp Console allows you to zoom in on all the sessions that are running on a virtual machine, we still felt that this script action provides you with the added value to focus only on the AVD-specific User Sessions information for the entire Hostpool directly from the AVD infrastructure.

If you are looking for a particular user session, you can filter the output by specifying a user’s UserPrincipalName (UPN) or a part of the UPN to search for (wildcards are allowed).

Figure 8 – AVD Hostpool User Sessions input argument

If you leave the input Argument empty, the Script-Based action will return all User Sessions the AVD Hostpool, sorted by Session Host.

Get AVD Hostpool Image Information

To also provide you with some additional information that is not (yet) shown in the Azure portal, we added a script action that will show the AVD Hostpool image information, as selected during the deployment phase of the AVD Hostpool. The AVD Hostpool image information gives you a quick overview of the base image, used for the Session Hosts of the Hostpool and provides insights in whether or not a standard Gallery or Custom image was used for the Session Hosts. It also returns VM specific information, like the vmSize, name prefix and osDiskType.

Figure 10 – AVD Get Hostpool Image information results

As this information is not part of the detailed AVD Hostpool information in the Azure portal, we are hoping this script action offers a quick way to check which image is assigned to the AVD Hostpool and what VMsize was selected for the Session Hosts. This provides you with a quick overview to check how many resources are added to the Hostpool with each additional Session Host or resources are lost when removing a Session Host.

Update Hostpool information

In addition to the informational script actions, we also added script actions to change configuration settings of the AVD Hostpool, without having to leave the ControlUp console and switch to the Azure portal, like the load balancing algorithm and the max session limit settings.

This way you can even build custom triggers for automated mitigating actions, based on the real-time metrics of your Session Hosts.

AVD Set Hostpool Load Balancing Algorithm

This script action allows you to change the configured Load Balancing Algorithm of the Hostpool, as you might want to give users the best performance during peak office hours, using the BreadthFirst algorithm, but switch to the DepthFirst algorithm during off-peak hours from a Cost Management perspective.

NOTE: Read an explanation of the available load balancing algorithms.

Figure 11 – AVD Set Hostpool Load Balancing Algorithm input arguments
Figure 12 – AVD Set Hostpool Load Balancing Algorithm results

AVD Set Hostpool Max Session Limit

The last script action that we wanted to zoom in on allows you to chance the configured Max Session Limit of the Hostpool. We think this script supports a more dynamic configuration of the maximum number of users per Session Host, based on the real-time metrics shown in the ControlUp Console.

This way, we can create automated actions to tweak both the Max Session Limit and the Load Balancing Algorithm, based on the resource consumption off the Session Hosts. Finding that sweet spot of total number of users per Session Host for your AVD Hostpool and taking seasonal bursts of application and resource usage into account as well.

Keep in mind that both settings are configured at AVD Hostpool level, so they will be applied to all Session Hosts within the AVD Hostpool.

Figure 13 – AVD Set Hostpool Max Session Limit input arguments

As both Hostpool configuration script actions only return information on the performed action and changed values, feel free to run the AVD Get Hostpool script action to double check if the new values were set correctly and check the new values for the MaxSessionLimit and LoadBalancerType parameters of the AVD Hostpool.