AVD AutoScale for personal desktops
Tags: avd, autoscale, microsoft, azure
Published: 2023-07-22 07:54:51

Microsoft had released public preview for AVD auto scaling feature for Personal desktops. This is a real game changer as many customers leverage personal or dedicated desktops and need to control the cost of the deployments. 
Enabling auto scale provides the ability to admins to control cost and energy by shutting down instances which are in disconnected and logged off state. You need to ensure that you configure Idle and disconnect timers to make the auto scaling works as expected.

Let us see how can we configure auto scaling for personal desktop hostpools. As part of the auto scaling, we will be configuring Ramp up and Ramp down settings and also what to do during peak hours and off peak hours.
##Pre-requisites for creating auto scaling settings

1. You must grant Azure Virtual Desktop access to manage the power state of your session host VMs. In short, the Azure virtual desktop service principal' need to be given 'Desktop Virtualization Power On Off Contributor' permissions.
During the creation phase, the below error will occur if the permissions where not given.

![RBAC Permissions error](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j68vh6arv65kffpwowqn.png)
The permissions looks like below

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwt61jzozffczlfnkwxv.png)



1. You must create the scaling plan in the same Azure region as the host pool you assign it to. You can't assign a scaling plan in one Azure region to a host pool in another Azure region.

##Configuring the auto scaling settings.
To configure auto scale settings, navigate to Azure portal-->Azure virtual desktop-->Scaling plans as shown in the below picture.

![Auto scaling plans](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rpe416okvgo5sg8sezdb.png)
Click "+Create" and the auto scaling page will load.
In the basics settings, provide the basic details like RG, Name, Region etc.

![Basic Settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/akhqjo3y29y5pwkq125z.png)
Select the time zone in which the auto scaling need to trigger.
Also select the host pool type as "Personal".
Ensure to give exclusion tags if needed. This will prevent auto scaling to applied on the specific VDIs where the tags are applied.

![Basic settings Cont.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/poc61l9e50ftr8lc3jqe.png)
### Create auto scale schedules
In the schedules tab, select "+Add schedule". The Add schedule page will popup. In the general tab, provide the Time zone to be followed for the auto scale. This should match the time zone given in the auto scale configuration to avoid issues. Provide the schedule name and in the repeat on select the number of days where the auto scaling policy will be applied. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1eay73aj4w6js01j3d1.png)

In my example, I am creating two auto scaling policies, one for weekdays and the other for weekends. The weekend auto scaling schedule will be a more aggressive one.
Click on Next and in the Ramp up plan, select the below as per your requirement.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vhm0qut3c5mrlevnhni4.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfobp7j42uq3sdtlbrtb.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6vrwnnmt0qrb0rb73ghx.png)
Click Next, In the peak hour settings, provide the start of peak hours and what to do during the peak hours of business.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jyla9fe6pnxhk690d058.png)
Provide the ramp down settings, this allows the settings to enable the ramping down of the session hosts. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wcpov18sglaijnz7ag9w.png)

Lastly configure the off peak hour settings and click on Add. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5lh475qr9yzbv7o1xxc6.png)
Follow the same schedule creation steps to create the schedule for weekends.
Once done, click next. In the "host pool assignments" select the personal host pools where you need to apply this settings.You can select multiple host pools to get the auto scaling settings.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phm0yxl1z18qlgvr9skt.png)

Click Next to add the tags and Click next.
Click on Create to create the auto scaling plan for personal desktops.
The key difference between Ramp up and peak hour is, let us assume that your business starts by 7 AM, so you keep your VMs ready by turning them ON for users to connect starting from 7AM and when the peak hours starts at 8AM so that the VMs are fully up and running for the staffs to connect instantaneously.
Click on review and Create to initiate the creation of the auto scaling policy.

![Review and Create Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2n1g7j2c0x54e7lksiix.png)
The auto scaling policy will create successfully once the role is properly assigned. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upyaak7iterpagwmknlm.png)



Hope this is useful to you, please let me know if you have any questions or queries.