In order to set up an Azure VMSS with a custom metric like "Total Sessions," you will need to perform the following steps:
- Create a custom metric: To use "Total Sessions" as a scaling trigger, you will first need to create a custom metric in Azure Monitor. You can use Azure Monitor's custom metrics API to ingest the metric from your RDP farm.
- Create a Log Analytics workspace: Create a Log Analytics workspace in Azure Monitor if you haven't already. This workspace will be used to collect and store the custom metric data.
- Install and configure the Log Analytics agent: Install the Log Analytics agent on your RDP servers and configure it to send the "Total Sessions" metric to your Log Analytics workspace.
- Create an Azure Function to query the custom metric: You will need an Azure Function to query the Log Analytics workspace for the "Total Sessions" metric and calculate the average number of sessions per server. The Azure Function should be triggered periodically (e.g., every 5 minutes) to check the current average session count and determine if it's necessary to scale the VMSS up or down.
- Create an Event Grid trigger for the Azure Function: Configure an Event Grid trigger to call the Azure Function whenever the "Total Sessions" metric is updated.
- Update the VMSS scaling settings: Update the VMSS scaling settings to use the output of the Azure Function to scale the number of instances up or down based on the average session count.
- Configure the Load Balancer: Configure the Azure Load Balancer to distribute incoming RDP connections to the VMSS instances.
By following these steps, you can create a custom scaling solution for your RDP farm using Azure VMSS and Load Balancer, and scale based on the "Total Sessions" metric. Note that this is a custom solution and might require some trial and error to get the scaling behavior exactly as desired. There might not be a fully native Azure solution for this specific use case without incorporating some custom components.