Setup VMSS to work with Total Sessions as a metric trigger

Camron Shelton 25 Reputation points
2023-04-10T19:20:56.3066667+00:00

We are needing to build out a VMSS for clients, however our sessions have a broad range and we do not need X servers running throughout the day. We would like to scale our VMSS using "Total Sessions" as a trigger.

For example: Start with 5 servers in morning, each server can only have up to 45 clients connected at a time, once they have ~30 Average, I need to add 5 more servers, and then once the average reaches ~30 again then another 5. Once it begins to drop the average below 30, then they need to decrease and block any more sign ins from the instances being shutdown. Of note: This is a RDP Farm, not a AppService. We realize that this could be done with Ansible, but that is not the path we have been directed to go, we need to use Azure resources available without adding any 3rd party services if at all possible. We have seen where we could potentially use a Azure Application Gateway, but the problem we ran into with that, is that we can not push users to another Farm via a load balancer. our question is, does anyone know of a way to natively use Azure VMSS and a Load Balancer and trigger off "Total Sessions" metric?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,035 questions
Azure Load Balancer
Azure Load Balancer
An Azure service that delivers high availability and network performance to applications.
506 questions
Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
450 questions
0 comments No comments
{count} vote

Accepted answer
  1. Sedat SALMAN 14,180 Reputation points MVP
    2023-04-11T12:05:57.83+00:00

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.