Table of Contents

AVD Scaling plans Overview

Autoscaling is a demanded feature and has been waiting for so long, we used to automatically scale host sessions using PowerShell scripts and Azure Automation, but it was long and complicated procedures involving a lot of components, Now with AVD Scaling plans you can define ramp-up hours, peak hours, ramp-down hours, and off-peak hours for weekdays and specify autoscaling triggers. but you can only add one schedule per day and a Scaling plan must include an associated schedule for at least one day of the week.

Requirements

  1. Create a Custom RBAC role
  2. Assign the custom role to Windows Virtual Desktop App

Create a Custom RBAC role

  1. Open a subscription or resource group
  2. Click on Access control (IAM)
  3. Click on Add Custom role

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Click on JSON Tab

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Click on Edit Tab

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Past the following JSON template

{
 "properties": {
 "roleName": "Autoscale",
 "description": "Friendly description.",
 "assignableScopes": [
 "/subscriptions/"
 ],
  "permissions": [
   {
   "actions": [
                      "Microsoft.Insights/eventtypes/values/read",
           "Microsoft.Compute/virtualMachines/deallocate/action",
                      "Microsoft.Compute/virtualMachines/restart/action",
                      "Microsoft.Compute/virtualMachines/powerOff/action",
                      "Microsoft.Compute/virtualMachines/start/action",
                      "Microsoft.Compute/virtualMachines/read",
                      "Microsoft.DesktopVirtualization/hostpools/read",
                      "Microsoft.DesktopVirtualization/hostpools/write",
                      "Microsoft.DesktopVirtualization/hostpools/sessionhosts/read",
                      "Microsoft.DesktopVirtualization/hostpools/sessionhosts/write",
                      "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/delete",
"Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read",                   "Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/sendMessage/action",
"Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions/read"
],
  "notActions": [],
  "dataActions": [],
  "notDataActions": []
  }
 ]
}
}

Change  with your SubscriptionID

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Save the template

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Click Review + Create.

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Last, Click Create.

Assign the custom role to Windows Virtual Desktop App:

  1. Open a subscription or resource group
  2. Click on Access control (IAM)
  3. Select Add role assignments.
  4. Select the role you just created (AutoScale)
 

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Next, Click on Select members

In the search bar, enter and select Windows Virtual Desktop, as shown in the following screenshot.

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Last, Click Review + Assign.

Create a scaling plan

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

  • As usual, we have to select Subscription, Resource Group, Name, and Location for the new resource.
  • Time Zone is important as the whole Autoscaling activity will be triggered and executed to Start/Stop host sessions based on the time zone you select here.

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

  • Next, you have to add a new Schedule and specify the Repeats on

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

  • Start time: you have to Enter a start time for the scaling plan, the specified time will be also the end time for off-peak hours.
  • Load-balancing algorithm: as you are going to use Autoscaling so the Depth-first load balancing option would be more relevant to your needs as its distributing the new user sessions to the available session host with the highest number of connections but has not reached its maximum session limit threshold which leads to minimizing the number of powered host sessions.
  • Minimum percentage of session hosts: Specify the minimum percentage of session hosts to start for ramp-up and peak hours, the percentage is based on the total number of session hosts in your host pool, so if the host pool includes 10 VMs and the percentage is 20% as in the above image, autoscale will ensure a minimum of 2 session host is available to take user connections.
  • Capacity threshold (%): This percentage evaluates whether to turn on/off VMs during the ramp-up and peak hours. So if your total host pool capacity is 100 sessions, and you specify a 60% Capacity threshold, once you exceed it, then autoscale will turn on additional session hosts.

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

As you can see the below step is almost the same as the previous one, so just to clarify the difference:

Peak hours and Ramp-up:

Usually, every application has its own peak hours where concurrent users tend to increase slowly before the start of peak time. same for AVD users start getting in slowing to the host sessions and at a specific time most of the users will start hitting the services (this is the peak hour)

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

  • Start time: Enter a start time for the scaling plan to reduce the number of virtual machines prior to the off-peak or non-business hours. This is also the end time for peak hours.
  • Load-balancing algorithm: as you are going to use Autoscaling so the Depth-first load balancing option would be more relevant to your needs as its distributing the new user sessions to the available session host with the highest number of connections but has not reached its maximum session limit threshold which leads to minimizing the number of powered host sessions.
  • Minimum percentage of session hosts: Specify the minimum percentage of session hosts to start for ramp-down and off-peak hours, the percentage is based on the total number of session hosts in your host pool, so if the host pool includes 10 VMs and the percentage is 10% as in the below image, autoscale will ensure a minimum of 1 session host is available to take user connections.
  • Capacity threshold (%): This percentage evaluates whether to turn on/off VMs during the ramp-down and off-peak hours. So if your total host pool capacity is 100 sessions, and you specify a 90% Capacity threshold, once you exceed it, then autoscale will turn on additional session hosts.
  • Delay time before logging out users and shutting down VMs (min): This option will set the session host VMs to drain mode, notify any currently signed-in users to save their work, and wait the configured amount of time before forcing the users to log off. Once all user sessions on the session host VM have been logged off, Autoscale will shut down the VM.
  • Notification message: As shown in the above image you can set your message to be pushed for your end-users to log off.

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

 
  • Start time (24-hour system): This is the start time for off-peak or non-business hours. This is also the end time for ramp-down.

Then Create..

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

In the next step, we have to assign the host pool that we will apply this schedule on, scaling plan can be assigned to any number of host pools.

Review and Create..

Testing And Validation

After a few minutes of creating the scaling plan..

Jump to the running AVD virtual machine and check the activity log, you should get an activity stating that the VM was started and this event initiated by WindowsVirtal Desktop App. 

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Check out my Udemy course for AZ-140 Azure Virtual Desktop
Use This link for 80% OFF ❤: https://bit.ly/AVDCourseYT

Share:

administrator

Microsoft MVP & MCT | Azure Service Delivery Lead with over 12 years of experience in Microsoft solutions and Professional services, Leading the Azure team to help our customers to build successful Azure practices, Blogger, Speaker, and Community leader. Focus on Azure, Cloud Security, Modern Workspace, AVD, Infrastructure as Code, Endpoint Management, Office 365, EMS.