How to get Auto scaling configuration for VMSSs

Anil Kumar 520 Reputation points
2024-07-31T11:44:08.1633333+00:00

Hello,

We have a requirement to fetch auto scaling configurations including auto scale status (enabled, disable or configured) auto scaling type (manual or custom), MIn and Max instance counts along with default instance count for 1000+ virtual machine scale sets. Insights is not enabled for all VMSSs.

I tried following KQL in Azure resource explorer and parsed its properties column but couldn't find what I was looking for.

resources
| where type == "microsoft.compute/virtualmachinescalesets"
		

Then I tried following table and parsed its data, it does have scaling info but only for few VM scale sets, not all.

resources
| where type == "microsoft.insights/autoscalesettings"

How can I fetch auto scaling details for all VM scale sets?

Appreciate your help.

Thank you!

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,320 questions
Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,697 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.
408 questions
{count} votes

Accepted answer
  1. Rahul Podila 195 Reputation points Microsoft Vendor
    2024-09-04T16:56:31.6333333+00:00

    Hi Anil Kumar,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    To fetch auto-scaling details for all your Virtual Machine Scale Sets (VMSS) in a straightforward way:

    To get a list of all Virtual Machine Scale Sets, use the following query:

    kql

    Copy code

    resources

    | where type == "microsoft.compute/virtualmachinescalesets"

    | project id, name, location

     To retrieve auto-scaling settings for your Virtual Machine Scale Sets, use this query:

    kql

    Copy code

    resources

    | where type == "microsoft.insights/autoscalesettings"

    | project id, name, properties

    To combine Virtual Machine Scale Sets with their auto-scaling settings, use this query:

    kql

    Copy code

    let vmss = resources

    | where type == "microsoft.compute/virtualmachinescalesets"

    | project vmssId = id, vmssName = name;

     

    let autoscale = resources

    | where type == "microsoft.insights/autoscalesettings"

    | project autoscaleId = id, autoscaleName = name, autoscaleProperties = properties;

     

    vmss

    | join kind=leftouter (autoscale) on $left.vmssId == $right.autoscaleId

    | project vmssId, vmssName, autoscaleName, autoscaleProperties

    Run the VMSS query to list all scale sets, the auto-scaling query to get scaling settings, and combine them to match each VMSS with its scaling configuration.

    If Insights is not enabled, Some VMSSs may not have auto-scaling data, and ensure you have the necessary permissions to access both VMSS and auto-scaling information.

    If you have any further queries, do let us know


    If the answer helpful, please click the "Accept Answer" And "upvote"

    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.