SOLVED

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

Brass Contributor

AVD Scaling plans.png

 

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

MahmoudAAtallah_6-1635081003235.png

 

Click on JSON Tab

 

MahmoudAAtallah_7-1635081037760.png

 

Click on Edit Tab

MahmoudAAtallah_8-1635081050566.png

 

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

 

MahmoudAAtallah_0-1635082258470.png

 

 

Save the template

MahmoudAAtallah_10-1635081095039.png

 

Click Review + Create.

MahmoudAAtallah_11-1635081108629.png

 

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)
 

MahmoudAAtallah_3-1635081600686.png

 

Next, Click on Select members

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

MahmoudAAtallah_2-1635081588805.png

 

Last, Click Review + Assign.

 

Create a scaling plan

 

2021-10-19 12_59_36-Create a scaling plan - Microsoft Azure and 10 more pages - Work - Microsoft​ Ed.png

 

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

 

2021-10-19 12_57_03-weekdays_schedule - Microsoft Azure and 10 more pages - Work - Microsoft​ Edge.png

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

2021-10-19 13_07_22-Add a schedule - Microsoft Azure and 10 more pages - Work - Microsoft​ Edge.png

 

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

 

2021-10-19 13_26_27-Add a schedule - Microsoft Azure and 10 more pages - Work - Microsoft​ Edge.png

 

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)

 

 

2021-10-19 13_42_10-Add a schedule - Microsoft Azure and 10 more pages - Work - Microsoft​ Edge.png

 

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

 

2021-10-19 14_01_08-Add a schedule - Microsoft Azure and 11 more pages - Work - Microsoft​ Edge.png

 

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

 

2021-10-19 14_03_17-Create a scaling plan - Microsoft Azure and 11 more pages - Work - Microsoft​ Ed.png

 

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. 

MahmoudAAtallah_6-1635081896561.png

 

 

 

 

 

56 Replies
best response confirmed by Eva Seydl (Microsoft)
Solution

Please verify documentation here: https://docs.microsoft.com/en-us/azure/virtual-desktop/autoscale-scaling-plan., which came with slight delay. When searching the table of contents for autoscale you will find additional articles how to use diagnostics and FAQ

 

Ensure your review limitations and ensure you have the custom RBAC role set-up :)!

 

 

When can we expect availability in Canada Central, any way to have access to that feature in our region earlier ?
We are working to get remaining regions up as soon as possible. For exploring please use the available regions. We are looking forward for feedback.
Hi,

This is a nice addition. I see this is based on maxsessionlimit in the host pool, which is a hard limit. With the logic app scaling tool we could specify a session threshold per cpu (soft limit, ie it would still allow more logons) - is there any way to do this in the new scaling plan for AVD?

Thanks,
Adam
Thanks for checking this out!
The Azure Function (Powershell) is not hard to configure, you must only specify some Parameters.
Its seems that scaling Plan is a nice new Feature, but why they make this with a max session limit at all?
The function do the max. Sessionlimit per Host, this is so much better.
Did i missunderstood this new feature?

Thanks, @Eva Seydl for the hint, I have updated the post with the pending configuration steps as well as testing and validation..

Great work. I do have a question regarding the Capacity treshold during ramp-up/ramp-down.

 

The docs state:

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

Is this treshold calculated based on the current capacity? So let's say I have 10VM's in total, 10 sessions per/VM, Total capacity is 100 sessions. 2 hosts are active, which means current capacity is 20. If we set capacity to 60%, will it ramp up when 60% of 20 is reached of 60% of 100. The first seems logical, but that's not what the docs are saying, since it refers to "total host pool capacity".

 

The load balancing doesn't take the GPO into account. It is the session limit on the host pool that counts.
The calculation goes always from the total host pool capacity.

@Eva Seydl That makes no sense, an example:

Host pool with 10 hosts x10 sessions = 100 sessions max.

Ramp up starts @ 8AM

Ramp up capacity treshold is 60%

Hosts at start ramp up is 40%

 

In this case @ 8AM, 4 hosts (40%) will be active and max 40 people can login. Based on the docs and what you're saying, no more hosts will be started, because we never hit 60% (=60 sessions) of total capacity.

If I'm mistaken, please elaborate where my logic is flawed.

The next VM will be started when the 61st session is requested. Based on the inputs when 40 sessions are on active in that host pool there is no need to start additional VMs.
Hello Eva Seydl, this feature is not applicable for personal host pool. when is such feature will be released for personal desktop pool ? i want to deallocate Personal AVD VM after hours when no user session is connected. any suggestion
We are working on the personal host pools but don't have an ETA yet.
Thanks Eva. Looks Personal host pools are not being prioritized, they are equally important. Can you please provide workaround while solution is being developed. currently, i am doing AVD VM auto shutdown option at VM level however this doesn't take in consideration active/disconnected user session so what happens is sometime VM will be shutdown while user is still working then user can't VM again using "Start on Connect" option as session was still connected when VM was shutdown. Please suggest some scripted or other solution which can help me.
You could configure a GPO scheduled task to shut down the VM after being idle for a certain amount of time. You will then need to have an Azure Runbook running regularly to check for machines that are powered off so you can de-allocate them to save consumption costs.
We understand the feature is important but we can't give an ETA at this time. You can follow guidance of adam222. :)

@Eva Seydl Is there anyway you can see logging when the schedule runs? I'd like to see the behaviour of the schedule

1 best response

Accepted Solutions
best response confirmed by Eva Seydl (Microsoft)
Solution

Please verify documentation here: https://docs.microsoft.com/en-us/azure/virtual-desktop/autoscale-scaling-plan., which came with slight delay. When searching the table of contents for autoscale you will find additional articles how to use diagnostics and FAQ

 

Ensure your review limitations and ensure you have the custom RBAC role set-up :)!

 

 

View solution in original post