Select Language:
If you’re looking for a way to automatically manage your Azure Virtual Desktop environment, Microsoft offers a helpful scaling automation tool. This tool makes it easier to add or remove virtual machines based on how many users are signed in at different times of the day.
The system works by connecting several components: an Azure Automation account, a PowerShell script known as a runbook, a webhook, and a Logic App. When the system runs, the Logic App activates the webhook, which then starts the runbook. The runbook creates jobs that manage the session hosts.
You should define peak and off-peak hours for your environment. Peak hours are when you expect the most users connected, and off-peak hours are when user activity is at its lowest.
During busy periods, the job checks how many users are currently signed in and how many virtual machines (VMs) are available to host those sessions. Based on this data and your settings—specifically the SessionThresholdPerCPU parameter—it determines whether more session hosts are needed. If existing hosts can’t handle the user load, the system will automatically spin up additional VMs.
In contrast, during low activity times, the job assesses whether some session hosts can be shut down to save resources. The MinimumNumberOfRDSH parameter helps decide the minimum number of session hosts to keep active. If you set the LimitSecondsToForceLogOffUser parameter to a positive number, the system will place the host VMs into a draining mode. This prevents new connections, prompts current users to save their work, waits for a set period, and then forces users to log off. Once all users are signed out, the system shuts down the VM and resets the host to accept new sessions normally.
You can find more details and step-by-step instructions on setting up this automation in Microsoft’s detailed guide here: Set up scaling script for Azure Virtual Desktop. Implementing this automation can help streamline your environment, reduce costs, and ensure smooth user experiences during peak and off-peak hours.





