VMSS - powershell for describing the VMSS autoscale type

Itay Tal | CloudTeam.ai 21 Reputation points
2021-06-21T13:22:01.907+00:00

Hi
I trie to list all my VMSS with manual scale, for creating a list of VMSS and change them into auto-scale
I couldn't find the powershell command to retrieve this information

Get-AzVmss -ResourceGroupName "Group001" -VMScaleSetName "VMSS001"

is not describing the scale type

Any idea how to find all those resources?

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.
348 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
0 comments No comments
{count} votes

Accepted answer
  1. SRIJIT-BOSE-MSFT 4,326 Reputation points Microsoft Employee
    2021-06-22T09:53:39.037+00:00

    @Itay Tal | CloudTeam.ai Thank you for your question. AutoscaleSettings is not a property of the resource of type Microsoft.Compute/virtualMachineScaleSets. When you enable autoscaling on a Virtual Machine Scale Set a resource of type Microsoft.Insights/autoscaleSettings is deployed, which looks something like the following:

    {  
        "type": "Microsoft.Insights/autoscaleSettings",  
        "apiVersion": "2015-04-01",  
        "name": "[variables('autoScaleResourceName')]",  
        "location": "[parameters('location')]",  
        "dependsOn": [  
            "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('virtualMachineScaleSetName'))]"  
        ],  
        "properties": {  
            "name": "[variables('autoScaleResourceName')]",  
            "targetResourceUri": "[variables('vmssId')]",  
            "enabled": true,  
            "profiles": [  
                {  
                    "name": "Profile1",  
                    "capacity": {  
                        "minimum": "[parameters('autoScaleMin')]",  
                        "maximum": "[parameters('autoScaleMax')]",  
                        "default": "[parameters('autoScaleDefault')]"  
                    },  
                    "rules": [  
                        {  
                            "metricTrigger": {  
                                "metricName": "Percentage CPU",  
                                "metricNamespace": "",  
                                "metricResourceUri": "[variables('vmssId')]",  
                                "timeGrain": "PT1M",  
                                "statistic": "Average",  
                                "timeWindow": "[concat('PT', parameters('durationTimeWindow'), 'M')]",  
                                "timeAggregation": "Average",  
                                "operator": "GreaterThan",  
                                "threshold": "[parameters('scaleOutCPUPercentageThreshold')]"  
                            },  
                            "scaleAction": {  
                                "direction": "Increase",  
                                "type": "ChangeCount",  
                                "value": "[parameters('scaleOutInterval')]",  
                                "cooldown": "PT1M"  
                            }  
                        },  
                        {  
                            "metricTrigger": {  
                                "metricName": "Percentage CPU",  
                                "metricNamespace": "",  
                                "metricResourceUri": "[variables('vmssId')]",  
                                "timeGrain": "PT1M",  
                                "statistic": "Average",  
                                "timeWindow": "PT5M",  
                                "timeAggregation": "Average",  
                                "operator": "LessThan",  
                                "threshold": "[parameters('scaleInCPUPercentageThreshold')]"  
                            },  
                            "scaleAction": {  
                                "direction": "Decrease",  
                                "type": "ChangeCount",  
                                "value": "[parameters('scaleInInterval')]",  
                                "cooldown": "PT1M"  
                            }  
                        }  
                    ]  
                }  
            ]  
        }  
    }  
    

    By default the value of the autoScaleResourceName variable will be defined as "autoScaleResourceName": "[concat(parameters('virtualMachineScaleSetName'), 'autoscale')]"

    For example, if your Virtual Machine Scale Set name is test then the AutoscaleSettings name will be testautoscale.

    So to get autoscale settings information you can use Get-AzAutoscaleSetting command

    For example:

    Get-AzAutoscaleSetting -ResourceGroupName $RG -WarningAction Ignore | Format-list Enabled,Name,TargetResourceUri  
    

    Output:

    Enabled           : True  
    Name              : testautoscale  
    TargetResourceUri : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/$RG/providers/Microso  
                        ft.Compute/virtualMachineScaleSets/test  
    

    ----------

    Hope this helps!

    Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.


2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 45,091 Reputation points
    2021-06-21T14:59:29.13+00:00

    Are you saying that the "Type" property isn't found in the results? I'm not at all familiar with Azure, but does adding the -InstanceView parameter to the cmdlet help?


  2. Rich Matheisen 45,091 Reputation points
    2021-06-21T18:27:14.413+00:00

    Have a look at the cmdlets that match: Get-<asterisk>autoscal<asterisk>

    I had to spell out "asterisk" where you should use "*" because of this forum's editor interprets paired asterisks as meaning "italicize this text".