Forum Discussion

MahmoudAtallah's avatar
MahmoudAtallah
Brass Contributor
Oct 19, 2021
Solved

Azure Virtual Desktop (AVD) | Scaling plans and Autoscaling

 

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

 

Click on JSON Tab

 

 

Click on Edit Tab

 

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

 

 

 

Save the template

 

Click Review + Create.

 

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)
 

 

Next, Click on Select members

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

 

Last, Click Review + Assign.

 

Create a scaling plan

 

 

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

 

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

 

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

 

 

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)

 

 

 

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

 

 

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

 

 

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. 

 

 

 

 

 

  • MiguelOmar's avatar
    MiguelOmar
    Copper Contributor
    How can I monitor?, and see logs of the escalation plan, I can not find a table in Log analytics for it, being that I am redirecting the diagnoses.
  • Hello Seneca_Friend,

    Thanks first and foremost -

    Read through the comments and undertand the UK South limitations. However, how does one stay notified about this being released in UK South?

    Should I just keep coming back to this post to find out?

    Thank you.

    • Seneca_Friend's avatar
      Seneca_Friend
      Icon for Microsoft rankMicrosoft
      Hi! Yes I will update this post when scaling plans are available in UK South. In the meantime, we have been asked to compile a list of customers that are blocked by not having UK South scaling plan availability to support our request for capacity in that region. If you or anyone else is blocked on this, please send me a private message with the following information:
      • What is the company/organization that you work for?
      • Are you currently blocked from using Autoscale due to scaling plans not being available in UK South?
      • Can you explain the business impact of not being able to use Autoscale in UK South?
      • How many AVD MAU (monthly active users) and MAV (monthly active VMs) does your company have?
  • Remo_G's avatar
    Remo_G
    Copper Contributor

     

    While I appreciate Microsoft finally having an integrated scaling solution, it is painfully basic. I am a Microsoft Certified Trainier giving AVD training and conducting workshops and have been struggling selling AVD for a year now. AVD is complex. AVD is just a platform, not a solution.

     

       Now, things starting to change, partners and myself are excited about AVD again since I started training and selling AVD using Nerdio MSP. 

    Their scaling allows me to even use Session Hosts with Ephemeral Disks, which are slightly more expensive (like 10$/month more for a D4ds vs a D4s), but do not need a managed disk and have *zero* disk cost while running and zero cost when not running (obviously, since they cannot be stopped/started, but are always created and destroyed) - and have 50% better Disk I/O throughput.

     

       Even for a partner starting with a customer with just 25 AVD-enabled employees, I save so much compute and storage cost, that the 12$/seat license I pay covers 75% of the Nerdio license (compared to a 3-year RI calculation). The remaining 25% are equivalent to an Swiss IT guys average 1h work rate, around 80$.

     

       And their solution is production ready. Now if you compare it with the scaling solution Microsoft is providing, the cost saving is less, but you cannot compare the scaling plan functionality with Nerdios'. It is so much more powerful, light years ahead. Check out the print screen and you will understand what I mean. You will end up with the 3-year RI solution that many customers opted for, because setting up and maintaining Scaling is either lacking functionality (like the new Scaling Plans) or too complex (Azure Automation).

     

       Do a FULL COST calculation and you will see that (at least in a place like Switzerland, where labor is expensive), a solution like Nerdio might be a better fit - and saves you A LOT of headaches. In my case, using Swiss labor rates and comparing how much MORE time you need to maintain AVD WITHOUT a proper tooling like Nerdio MSP, we save 39%, from a TCO perspective.

     

       Best of all, this Friday, May 6th, they roll out a release that allows me to use AADJ with FSLogix (using Blob storage), so bye bye to two DC's and two days of work for cloud native customers (our instruction manual ist over a hundred pages long for this seamless SSO setup with ADFS). If you are not experienced with Azure, you need a week to set this up, if you hire me, I will do it in two days. If you have Nerdio MSP, you have this up and running before lunch time. 😊

     

       Reach out to me if you are based in Switzerland and I will demo you the magic.

     

     

    Nerdio MSP Auto-Scaling Print Screen 

     

    • Patrick_Kunz's avatar
      Patrick_Kunz
      Copper Contributor
      Hi Remo_G, Thanks for your answers. At this time of the project, we're looking for a solution with microsoft basic features. Therfore we need help with avd scaling plans :-). In a further step, nerdio could be an option..., patrick
    • virtualmanc's avatar
      virtualmanc
      Iron Contributor
      Hey Remo_G, I am the UK Field CTO for Nerdio, thanks for your kind comments about the product!! I'll be in Switzerland next week for the IGEL Disrupt even showing the Nerdio magic to the rest of the world 🙂
  • Patrick_Kunz's avatar
    Patrick_Kunz
    Copper Contributor
    Hi,
    We're having a problem with the scaling plan feature.

    Facts: We test with 2 identical hostpools, the scaling plan prerequisite (RBAC) are set on subscription level. we use the same scaling plan object for both hostpools.

    Hostpool1:
    w10Multisession Image created with our cloud based imaging service.
    - W10Multisession from azure (21H2) Generation1
    - FSLogix und VCRedist uninstalled
    - Actual windows Updates installed
    - Sysprep sysprep.exe /oobe /generalize /shutdown /mode:vm

    Hostpool2:
    w10Multisession Image manual created in azure.
    - W10Multisession from azure (21H2) Generation1
    - Sysprep sysprep.exe /oobe /generalize /shutdown /mode:vm

    Testing Scenario: All VM's are down / deallocated
    Scaling plan for both hostpools disabled

    Problem scenario:
    -> Enable scaling plan for hostpool 1
    -> wait..... -> No host starts up !! -> checking scaling plan log -> Attached scalingplanlog1.json -> all 3 hosts are marked as
    ExcludedSessionHostCount !!

    Working scenario:
    -> Enable scaling plan for hostpool 2
    -> wait..... -> after 5 minutes host starts up !! -> checking scaling plan log -> Attached scalingplanlog2.json -> no hosts are marked as "ExcludedSessionHostCount" !!

    Does anybody has this effect od knows in which constellations the scaling plan feature is evaluating session hosts as "ExcludedSessionHost" ?

    thanks for your help,

    Patrick

    scalingplanlog1.json

    {
    "host_Ring": "R0",
    "Level": 4,
    "ActivityId": "00000000-0000-0000-0000-000000000000",
    "time": "2022-05-03T15:20:21.4366865Z",
    "resourceId": "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/P-RG-EDU-TEST-01/PROVIDERS/MICROSOFT.DESKTOPVIRTUALIZATION/SCALINGPLANS/P-SCP-EDU-TEST-02",
    "operationName": "ScalingEvaluationSummary",
    "category": "Autoscale",
    "resultType": "Succeeded",
    "level": "Informational",
    "correlationId": "8ae9e5b8-c6cb-47ce-943a-923b91c154df",
    "properties": {
    "Message": "0.00% of session hosts are active (0 of 3 session hosts). This is below the minimum hosts percentage of 20% (1 session hosts). Need to turn on 1 session hosts to meet minimum number of hosts.",
    "HostPoolArmPath": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/p-rg-edu-test-01/providers/microsoft.desktopvirtualization/hostpools/p-vhp-edu-test-01",
    "ScalingEvaluationStartTime": "5/3/2022 3:19:33 PM",
    "TotalSessionHostCount": "3",
    "ExcludedSessionHostCount": "3",
    "ActiveSessionHostCount": "0",
    "SessionCount": "0",
    "NonActiveSessionCount": "0",
    "CurrentSessionOccupancyPercent": "NaN",
    "CurrentActiveSessionHostsPercent": "0",
    "Config.ScheduleName": "weekdays_schedule",
    "Config.SchedulePhase": "Peak",
    "Config.MaxSessionLimitPerSessionHost": "1",
    "Config.CapacityThresholdPercent": "60",
    "Config.MinActiveSessionHostsPercent": "20",
    "DesiredToScaleSessionHostCount": "1",
    "EligibleToScaleSessionHostCount": "0",
    "ScalingReasonType": "StartVMs_BelowMinimumActiveSessionHosts",
    "BeganForceLogoffOnSessionHostCount": "0",
    "BeganDeallocateVmCount": "0",
    "BeganStartVmCount": "0",
    "TurnedOffDrainModeCount": "0",
    "TurnedOnDrainModeCount": "0"
    }
    }

    scalingplanlog2.json


    {
    "host_Ring": "R0",
    "Level": 4,
    "ActivityId": "00000000-0000-0000-0000-000000000000",
    "time": "2022-05-03T14:18:41.0012950Z",
    "resourceId": "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/P-RG-EDU-TEST-01/PROVIDERS/MICROSOFT.DESKTOPVIRTUALIZATION/SCALINGPLANS/P-SCP-EDU-TEST-02",
    "operationName": "ScalingEvaluationSummary",
    "category": "Autoscale",
    "resultType": "Succeeded",
    "level": "Informational",
    "correlationId": "24ef99f5-650c-4d44-a6ab-1a309f9a1c76",
    "properties": {
    "Message": "0.00% of session hosts are active (0 of 3 session hosts). This is below the minimum hosts percentage of 20% (1 session hosts). Need to turn on 1 session hosts to meet minimum number of hosts.",
    "HostPoolArmPath": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/p-rg-edu-test-01/providers/microsoft.desktopvirtualization/hostpools/p-vhp-edu-test-01",
    "ScalingEvaluationStartTime": "5/3/2022 2:17:52 PM",
    "TotalSessionHostCount": "3",
    "ExcludedSessionHostCount": "0",
    "ActiveSessionHostCount": "0",
    "SessionCount": "0",
    "NonActiveSessionCount": "0",
    "CurrentSessionOccupancyPercent": "NaN",
    "CurrentActiveSessionHostsPercent": "0",
    "Config.ScheduleName": "weekdays_schedule",
    "Config.SchedulePhase": "Peak",
    "Config.MaxSessionLimitPerSessionHost": "1",
    "Config.CapacityThresholdPercent": "60",
    "Config.MinActiveSessionHostsPercent": "20",
    "DesiredToScaleSessionHostCount": "1",
    "EligibleToScaleSessionHostCount": "1",
    "ScalingReasonType": "StartVMs_BelowMinimumActiveSessionHosts",
    "BeganForceLogoffOnSessionHostCount": "0",
    "BeganDeallocateVmCount": "0",
    "BeganStartVmCount": "1",
    "TurnedOffDrainModeCount": "0",
    "TurnedOnDrainModeCount": "0"
    }
    }
    • Seneca_Friend's avatar
      Seneca_Friend
      Icon for Microsoft rankMicrosoft
      Hi Patrick_Kunz, session hosts marked as ExcludedSessionHosts are those that have the exclusion tag applied to them. Do the session hosts in host pool 1 have any tags on them? Does the scaling plan (P-SCP-EDU-TEST-02) have exclusion tags specified?
      • Patrick_Kunz's avatar
        Patrick_Kunz
        Copper Contributor
        Hi Seneca_Friend, Thanks for your answer. The Session Hosts (Hostpool1 & 2) have one Tag: "Owner", but the scaling plan has no tag definied. We left that field empty. Also Drain mode on all Hosts is off. Any further ideas? thanks a lot, patrick
  • jfgarcia's avatar
    jfgarcia
    Copper Contributor
    Hi all,

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

    Thanks a lot for your help!
    • Aaron Ott's avatar
      Aaron Ott
      Copper Contributor

      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

      • Seneca_Friend's avatar
        Seneca_Friend
        Icon for Microsoft rankMicrosoft
        Scaling plans are now available in all of the following regions:
        Canada Central
        Canada East
        Central US
        East US
        East US 2
        North Central US
        North Europe
        South Central US
        West Central US
        West Europe
        West US
        West US 2
  • robbie64's avatar
    robbie64
    Copper Contributor

    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?

    • Seneca_Friend's avatar
      Seneca_Friend
      Icon for Microsoft rankMicrosoft

      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!

      • robbie64's avatar
        robbie64
        Copper Contributor

        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:

         

        Setting on Scaling plan:

  • Kristof_Kuderko's avatar
    Kristof_Kuderko
    Copper Contributor
    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?
    • evasse's avatar
      evasse
      Icon for Microsoft rankMicrosoft
      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.
  • Harsh1730's avatar
    Harsh1730
    Copper Contributor
    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
    • evasse's avatar
      evasse
      Icon for Microsoft rankMicrosoft
      We are working on the personal host pools but don't have an ETA yet.
      • Harsh1730's avatar
        Harsh1730
        Copper Contributor
        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.
  • Robert Folkers's avatar
    Robert Folkers
    Copper Contributor

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

     

    • evasse's avatar
      evasse
      Icon for Microsoft rankMicrosoft
      The calculation goes always from the total host pool capacity.
      • Robert Folkers's avatar
        Robert Folkers
        Copper Contributor

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

    • AmitJ2021's avatar
      AmitJ2021
      Copper Contributor
      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?
      • Seneca_Friend's avatar
        Seneca_Friend
        Icon for Microsoft rankMicrosoft
        The host pool and the scaling plan need to be in the same region. Scaling plans are now available in any of the following regions:
        Canada Central
        Canada East
        Central US
        East US
        East US 2
        North Central US
        North Europe
        South Central US
        West Central US
        West Europe
        West US
        West US 2
    • MahmoudAtallah's avatar
      MahmoudAtallah
      Brass Contributor

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

    • adam222's avatar
      adam222
      Copper Contributor
      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

Resources