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
Hi Eva and Mahmoud,
As per the document "Currently, autoscale only supports the Central US and East US 2 regions." I want to know which resource should be place in these two region, scaling plan, VMs or Hostpool metadata?

@Robert Folkers You're logic is right. I had the same problem but now looking at the json (log) it is not the total hostpool capacity but it is the percentage of the current running hosts. So if 5 hosts are running with 10 sessions per host, in my opinion, it calculates the percentage of the current sessions and if that is above the percentage of in this case max 50 sessions, it will power up machines so the percentage will be below your percentage.

@robbie64 Thanks for verifying this!

This is great! Awaiting for the UK South location to be enabled.
Is any error alerting possible? i.e. when thresholds are reached and autoscaling supposed to power up or shutdown a machine but it failed for some reason?
I don't have an ETA for you for the rollout. In terms of alerting please review log analytics documentation. We will have tighter integration that will make it easier to set alerts. As well for this one no ETA. We will keep you updated in this forum.

What i do see in the logs is that sessionhosts that are turned in Drainmode plus the exclusion tag set still being counted with minimum host percentage. It sounds to me that is not right. VM's with the exlusion tag should not be calculated within the host percentage. I say this because when we do create a new release we will have double the amount of machines before we cleanup the old ones. Maybe I am not sure i get the way you have to put the Tag on the VM. My tag is called excludescaling and i put as value Y. In the schedule i called the exclusiontag excludescaling. Is this the way?

Hi @robbie64,

Thank you so much for your comment. Could you please provide a bit more details from your example so that we can look into what is happening. More specifically, it would be helpful if you could provide screenshots of where you have placed the tag on the VM and what you are seeing in the logs, plus your subscription ID, host pool, resource ID, and timestamps (when you observed this happening). (Feel free to send me a private message with this sensitive information.) Thank you so much!

@Seneca_Friend I have a total of 8 hosts in the hostpool. 4 hosts are a new release the other 4 hosts are in drain mode and have the exclusion tag and powered off, ready to be deleted. My scalingplan says a minimum of 50% hosts should be active. In my opinion that should then be 2 hosts minumum, but the plan powers them all on (the 4 newly created). The schedule should turn 2 off since my amount off sessions is below the threshold but the log says the it keeps them on otherwise it would go below the 50% of active hosts. In my believe the 50% should be calculated from 4 hosts and not 8.

Here is a screenshot with the tag. If u need more info let me know, can sent te log through private message if needed.

 

Tag on VM:

Screenshot 2021-11-06 114959.png

 

Setting on Scaling plan:

Screenshot 2021-11-06 115138.png

Hi @robbie64,
Thanks for the screenshots. Please send me the subscription ID and logs so I can look into this.
send u a private message

@Robert Folkers To my understanding the threshold of 60% means the actual user sessions / all user sessions on the currently running VMs.

Hi all,

Does any one know if or when will it be available for South Central US?

Thanks a lot for your help!

Any update to wider availability? I've been testing for a while with scaling plans in their limited regions, none of which are the same regions at my host pools. I'm just now getting alerted that any scaling plan assigned to a host pool in a different region will be disabled on March 21st. My entire infra is in regions not yet supported by scaling plans, and it looks like the plans are still limited to just these four regions:  northeurope, westeurope, eastus2, centralus

Hi Aaron, we are planning to start rolling out Autoscale to new regions in the coming weeks. This announcement was a preemptive warning that will be supplemented with Autoscale being supported in more regions very very soon. I will be sure to update here when there is wider availability. Are there particular region(s) that you need scaling plans in to assign to your host pool?
I was wondering if this was a precursor to GA. :) North Central US is the big one for us so I hope that one is on the list.
Yes it definitely is! We are planning to have Autoscale in every region that host pools are in today by the time Autoscale GAs.
Are you able to share a rough timescale as to when this new Auto scaling feature will be made available to more regions please (UK South etc...)?

We are currently in the process of rolling out AVD to a large customer, and making use of the scaling script (logic app/automation account) to achieve some basic scaling functionality. However the new AutoScaling functions that are in preview look to offer far more control and options that would be extremely useful.
My rough estimate is that Autoscale will be in more regions within the next month.

@Seneca_Friend 

 

We really need a timeline of this being available in UK South.

 

Is there any sort of date ?

Hi @BradleyGlover93,
No there is no timeline or ETA for scaling plans being available in UK South. Azure is facing capacity issues in UK South that are preventing us from being able to deploy there fully. We will be rolling out scaling plans to more regions in the next month, but UK South will not come for a while.