Restart Azure VMSS VM

Use the Restart-AzVmssVm cmdlet to restart a specific virtual machine scale set (VMSS) instance.

Restart-AzVmssVm -ResourceGroupName "" -VMScaleSetName "" -InstanceId "" [-Force] [-AsJob] [-NoWait] [-WhatIf] [-Confirm] []

Description

The Restart-AzVmssVm cmdlet restarts a virtual machine in a virtual machine scale set (VMSS).

This command allows you to reboot individual instances within your VMSS, which can be useful for applying updates, troubleshooting, or recovering from issues without affecting the entire scale set.

Parameters

-ResourceGroupName
Specifies the name of the resource group for the VMSS.
-VMScaleSetName
Specifies the name of the VMSS.
-InstanceId
Specifies the ID of the VMSS instance to restart. You can get the instance ID using Get-AzVmssVm.
-Force
Forces the restart operation without prompting for confirmation.
-AsJob
Runs the cmdlet as a background job.
-NoWait
Returns control to the command line immediately without waiting for the operation to complete.

Examples

Example 1: Restart a specific VMSS instance

This example restarts the VMSS instance with Instance ID '3' in the 'MyResourceGroup' resource group and 'MyVmss' scale set.

Restart-AzVmssVm -ResourceGroupName "MyResourceGroup" -VMScaleSetName "MyVmss" -InstanceId "3"

Example 2: Force restart a VMSS instance without confirmation

This example forcefully restarts the VMSS instance '1' in 'ProductionResourceGroup' without user confirmation.

Restart-AzVmssVm -ResourceGroupName "ProductionResourceGroup" -VMScaleSetName "WebAppScaleSet" -InstanceId "1" -Force

Example 3: Restart a VMSS instance and run as a background job

This example restarts the VMSS instance '0' and allows you to continue working in PowerShell.

Restart-AzVmssVm -ResourceGroupName "DevResourceGroup" -VMScaleSetName "TestScaleSet" -InstanceId "0" -AsJob

How to Use

To restart a VMSS VM, you need to provide the resource group name, the VMSS name, and the specific instance ID of the VM you wish to restart.

You can obtain the instance ID using the Get-AzVmssVm cmdlet. For example:

Get-AzVmssVm -ResourceGroupName "MyResourceGroup" -VMScaleSetName "MyVmss" | Select-Object -ExpandProperty InstanceId

Once you have the instance ID, you can pipe it or pass it directly to Restart-AzVmssVm.

Important: Restarting a VMSS instance will briefly interrupt the service provided by that specific instance. Ensure you understand the impact on your application before proceeding. Use the -Force parameter with caution.

Interactive Form (Simulation)

Fill out the form below to simulate running the Restart-AzVmssVm command.