Azure Virtual Desktop (AVD) | Scaling plans
Azure Virtual Desktop | Scaling plans

Azure Virtual Desktop (AVD) | Scaling plans

Just notice that I have a new tab under my AVD Portal for Scaling Plan.

Before I just explore it, I checked Microsoft DOCs to understand the new feature and see how I can enable it, but I didn't find any relevant info even when I google it I end up with the same result... did I stop here.. Absolutely not, created a temp host pool and followed the wizard to enable and configure the new feature and here is my test result

AVD Scaling plans

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

No alt text provided for this image


 Click on JSON Tab

No alt text provided for this image

Click on Edit Tab

No alt text provided for this image


 Past the following JSON template

 "properties": {
 "roleName": "Autoscale",
 "description": "Friendly description.",
 "assignableScopes": [
 "/subscriptions/<SubscriptionID>"
 ],
  "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 <SubscriptionID> with your SubscriptionID

No alt text provided for this image

Save the template

No alt text provided for this image

Click Review + Create.

No alt text provided for this image

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)

No alt text provided for this image

 Next, Click on Select members

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

No alt text provided for this image

Last, Click Review + Assign.


Create a scaling plan

No alt text provided for this image

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.

No alt text provided for this image


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

No alt text provided for this image

  • 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.

No alt text provided for this image

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)

No alt text provided for this image

  • 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.

No alt text provided for this image

  • 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..

No alt text provided for this image

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..

Mahmoud A. ATALLAH can this be used for session host created using shared gallery and being generalized one!! If not, I am wondering how can this be useful for large deployments..

Like
Reply
Steve Miles

CTO |Chief Geek |Security,Data,AI |Azure MVP |MCT |Author |PetrolHead

3y
Matthew Zaman

Cloud Solution Architect

3y

Great article. Thanks again Mahmoud

I wonder where you can specify the pool's session capacity without enforcing a hard limit? Did I miss it somewhere?

Diogo Fernandes

Cloud Infrastructure | Cloud Engeneer | Cloud Architect

3y

To view or add a comment, sign in

More articles by Mahmoud A. ATALLAH

Insights from the community

Others also viewed

Explore topics