Update-AzVmssVM

Updates the state of a Vmss VM.

Syntax

Update-AzVmssVM
      [-ResourceGroupName] <String>
      [-VMScaleSetName] <String>
      [-InstanceId] <String>
      [-DataDisk <PSVirtualMachineDataDisk[]>]
      [-ProtectFromScaleIn <Boolean>]
      [-ProtectFromScaleSetAction <Boolean>]
      [-AsJob]
      [-UserData <String>]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Update-AzVmssVM
      [-DataDisk <PSVirtualMachineDataDisk[]>]
      [-ProtectFromScaleIn <Boolean>]
      [-ProtectFromScaleSetAction <Boolean>]
      [-ResourceId] <String>
      [-AsJob]
      [-UserData <String>]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Update-AzVmssVM
      [-DataDisk <PSVirtualMachineDataDisk[]>]
      [-ProtectFromScaleIn <Boolean>]
      [-ProtectFromScaleSetAction <Boolean>]
      [-VirtualMachineScaleSetVM] <PSVirtualMachineScaleSetVM>
      [-AsJob]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

Updates the state of a Vmss VM. For now, the only allowed update is adding a managed data disk.

Examples

Example 1: Add a managed data disk to a Vmss VM using New-AzVMDataDisk

$disk = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskname0
$datadisk = New-AzVMDataDisk -Caching 'ReadOnly' -Lun 2 -CreateOption Attach -StorageAccountType Standard_LRS -ManagedDiskId $disk.Id
$VmssVM = Get-AzVmssVM -ResourceGroupName "myrg" -VMScaleSetName "myvmss" -InstanceId 0
Update-AzVmssVM -ResourceGroupName "myrg" -VMScaleSetName "myvmss" -InstanceId 0 -DataDisk $datadisk

The first command gets an existing managed disk. The next command creates a data disk object with the managed disk. The next command gets an existing Vmss VM given by the resource group name, the vmss name and the instance ID. The final command updates the Vmss VM by adding a new data disk.

Example 2: Add a managed data disk to a Vmss VM using Add-AzVMDataDisk

$disk = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskname0
$VmssVM = Get-AzVmssVM -ResourceGroupName "myrg" -VMScaleSetName "myvmss" -InstanceId 0
$VmssVM = Add-AzVMDataDisk -VM $VmssVM -Lun 0 -DiskSizeInGB 10 -CreateOption Attach -StorageAccountType Standard_LRS -ManagedDiskId $disk.Id
Update-AzVmssVM -VirtualMachineScaleSetVM $VmssVM

The first command gets an existing managed disk. The next command gets an existing Vmss VM given by the resource group name, the vmss name and the instance ID. The next command adds the managed disk to the Vmss VM stored locally in $VmssVM. The final command updates the Vmss VM with added data disk.

Example 3

Updates the state of a Vmss VM. (autogenerated)

Update-AzVmssVM -InstanceId 0 -ProtectFromScaleIn $false -ProtectFromScaleSetAction $false -ResourceGroupName 'myrg' -VMScaleSetName 'myvmss'

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DataDisk

Type:PSVirtualMachineDataDisk[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InstanceId

Specifies the instance ID of a VMSS VM.

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ProtectFromScaleIn

Indicates that the virtual machine scale set VM shouldn't be considered for deletion during a scale-in operation.

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ProtectFromScaleSetAction

Indicates that model updates or actions (including scale-in) initiated on the VMSS should not be applied to the VMSS VM.

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Specifies the name of the Resource Group of the VMSS.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ResourceId

The resource id for the virtual machine scale set VM

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-UserData

UserData for the Vmss Vm, which will be base-64 encoded. Customer should not pass any secrets in here.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-VirtualMachineScaleSetVM

Local virtual machine scale set VM object

Type:PSVirtualMachineScaleSetVM
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-VMScaleSetName

The name of the virtual machine scale set

Type:String
Aliases:Name
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

PSVirtualMachineDataDisk[]

PSVirtualMachineScaleSetVM

Outputs

PSVirtualMachineScaleSetVM