Bearbeiten

Freigeben über


Add-AzVmssVMDataDisk

Adds a data disk to a Vmss VM.

Syntax

Add-AzVmssVMDataDisk
   [-VirtualMachineScaleSetVM] <PSVirtualMachineScaleSetVM>
   [-Lun] <Int32>
   [-CreateOption] <String>
   [-ManagedDiskId] <String>
   [-StorageAccountType <String>]
   [-DiskEncryptionSetId <String>]
   [-Caching <CachingTypes>]
   [-DiskSizeInGB <Int32>]
   [-WriteAccelerator]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Add-AzVmssVMDataDisk cmdlet adds a data disk to a Vmss VM.

Examples

Example 1: Add a managed data disk to a Vmss VM.

$disk = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskname0
$VmssVM = Get-AzVmssVM -ResourceGroupName "myrg" -VMScaleSetName "myvmss" -InstanceId 0
$VmssVM = Add-AzVmssVMDataDisk -VirtualMachineScaleSetVM $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.

Parameters

-Caching

Specifies the caching mode of the disk. The acceptable values for this parameter are:

  • ReadOnly
  • ReadWrite
  • None The default value is ReadWrite. Changing this value causes the virtual machine to restart. This setting affects the consistency and performance of the disk.
Type:CachingTypes
Accepted values:None, ReadOnly, ReadWrite
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-CreateOption

Specifies whether this cmdlet creates a disk in the virtual machine from a platform or user image, creates an empty disk, or attaches an existing disk. The acceptable values for this parameter are:

  • Attach. Specify this option to create a virtual machine from a specialized disk. When you specify this option, do not specify the SourceImageUri parameter. The VhdUri is all that is needed in order to tell the Azure platform the location of the virtual hard disk (VHD) to attach as a data disk to the virtual machine.
  • Empty. Specify this to create an empty data disk.
  • FromImage. Specify this option to create a virtual machine from a generalized image or disk. When you specify this option, you must specify the SourceImageUri parameter also in order to tell the Azure platform the location of the VHD to attach as a data disk. The VhdUri parameter is used as the location identifying where the data disk VHD will be stored when it is used by the virtual machine.
Type:String
Position:2
Default value:None
Required:True
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

-DiskEncryptionSetId

Specifies the resource Id of customer managed disk encryption set. This can only be specified for managed disk.

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

-DiskSizeInGB

Specifies the size, in gigabytes, of an empty disk to attach to a virtual machine.

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

-Lun

Specifies the logical unit number (LUN) for a data disk.

Type:Int32
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ManagedDiskId

Specifies the ID of a managed disk.

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

-StorageAccountType

Specifies the storage account type of managed disk.

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

-VirtualMachineScaleSetVM

Specifies the local virtual machine scale set VM object to which to add a data disk. You can use the Get-AzVmssVM cmdlet to obtain a virtual machine scale set VM object.

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

-WriteAccelerator

Specifies whether WriteAccelerator should be enabled or disabled on a managed data disk.

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

Inputs

PSVirtualMachineScaleSetVM

Int32

String

CachingTypes

Outputs

PSVirtualMachineScaleSetVM