In the previous part, I introduced the Azure virtual machine scale set (VMSS) feature and discussed some of the deployment options. In this part, I will explain how to manage an existing VMSS implementation.
Follow me:
Latest posts by Anil Erduran (see all)

Getting the virtual machine ID

When it comes to managing virtual machines (VMs) in a VMSS, there are some important differences compared to traditional VM management. The first thing you need to be aware of is that there are separated PowerShell cmdlets that interact with VMs.

Secondly, in order to interact with VMs in a VMSS, you need to know the instance ID of the VM you want to manage.

To figure out the ID for the VMs, you can browse the portal and extract your Resource Group -> VMSS.

Finding the virtual machines ID in Azure resource explorer

Finding the virtual machines ID in Azure resource explorer

Here, you can easily retrieve the VM ID. You can also get the same information from the Azure Portal Instances section:

Identifying the VM instance ID

Identifying the VM instance ID

Once you have the correct instance ID for a particular VM inside the VMSS, you can start using VMSS-related PowerShell commands. The following cmdlet helps you list the basic VM information:

Get-AzureRmVmssVM -ResourceGroupName VMSS -VMScaleSetName vmss01 -InstanceId 2
Retrieving VMSS details with PowerShell

Retrieving VMSS details with PowerShell

As mentioned previously, commands and outputs are different than with traditional Azure PowerShell cmdlets.

Starting and stopping VMs

Start and stop operations are also a bit different than with traditional VM implementations. As you may recall, for every single VMSS setup, you need to define a minimum instance count. This setting is quite important because by configuring a minimum instance count, you are forcing Azure to have a minimum X number of VMs available at all times, unless you stop them manually.

This is why Azure starts the minimum number of VMs you configured when you logged in to the Azure portal and started your VMSS instance.

Starting the VMSS

Starting the VMSS

VMSS minimum instance count

VMSS minimum instance count

You can start/stop/restart individual VMs or all VMs in a scale set by using PowerShell cmdlets:

Start/Stop/Restart all VMs in a scale set:

Start-AzureRmVmss -ResourceGroupName VMSS -VMScaleSetName vmss01
Stop-AzureRmVmss -ResourceGroupName VMSS -VMScaleSetName vmss01
Restart-AzureRmVmss -ResourceGroupName VMSS -VMScaleSetName vmss01

To Start/Stop/Restart an individual VM in a scale set:

Start-AzureRmVmss -ResourceGroupName VMSS -VMScaleSetName vmss01 -InstanceId 2
Stop-AzureRmVmss -ResourceGroupName VMSS -VMScaleSetName vmss01 -InstanceId 2
Restart-AzureRmVmss -ResourceGroupName VMSS -VMScaleSetName vmss01 -InstanceId 2

Changing the current capacity

You can also change the current capacity of your scale set manually without using auto-scale metrics. The following command gives you the current capacity details:

(Get-AzureRmVmss -ResourceGroupName vmss -VMScaleSetName VMSS01).sku
VMSS SKU details

VMSS SKU details

Using the .sku property, you can change the current count to 4:

$vmssConfig = Get-AzureRmVmss -ResourceGroupName vmss -VMScaleSetName VMSS01
$vmssConfig.sku.capacity = 4
Update-AzureRmVmss -ResourceGroupName vmss -Name VMSS01 -VirtualMachineScaleSet $vmssConfig

This will change the “Current number of instances” property to 4 and will fire up two additional VMs for my VMSS configuration.

Subscribe to 4sysops newsletter!

Changing VMSS SKU settings

Changing VMSS SKU settings

In the next part, we will examine the availability and scalability options in Azure PaaS Services.

Articles in seriesAzure availability and scalability
1 Comment
  1. Avatar
    Mitalee Sarker 1 year ago

    How do I create a new instance without scaling? For example, I have 2 instances (which was my minimum number of instance) running in my scale set and I set up the scaling upto 100 instances. Can I create/start a new instance manually without triggering a scaling?

Leave a reply

Your email address will not be published. Required fields are marked *


© 4sysops 2006 - 2023


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account