Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Add-AzureVMDataDisk

Add-AzureVMDataDisk

microsoft.azure.commands.compute.dll

Synopsis

Add Data Disk to VM

Syntax

Add-AzureVMDataDisk [-VM] [-Name] [-VhdUri] [-Caching] [-DiskSizeInGB] [-Lun] [-CreateOption] [-SourceImageUri] [-Profile] [-InformationAction] [-InformationVariable] [<CommonParameters>]

Detailed Description

This cmdlets allows you to add a Data Disk to the VM at creation time or to an existing VM

Parameters

-VM <PSVirtualMachine>

Local VM Object to add the Data Disk to. The local VM object can be created with New-AzureVMConfig cmdlet or gotten through the Get-AzureVM cmdlet.

Aliases

None

Required?

true

Position

0

Default value

None

Accept pipeline input?

true (ByValue, ByPropertyName)

Accept wildcard characters?

false

-Name <String>

Name of the Data Disk

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-VhdUri <String>

Specifies the VHD file that needs to be created when a platform image or user image is used. This is where the image blob will be copied to start the VM from.

Aliases

None

Required?

false

Position

2

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Caching <String>

Specifies the caching mode of the disk. This setting impacts the consistency and performance of the disk. Note: Changing this value causes the Virtual Machine to reboot. Possible values are: • ReadOnly • ReadWrite The default value is ReadWrite.

Aliases

None

Required?

false

Position

3

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-DiskSizeInGB <Nullable`1[Int32]>

Specifies the size, in GB, of an empty disk to be attached to the Virtual Machine.

Aliases

None

Required?

true

Position

4

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Lun <Nullable`1[Int32]>

Specifies the Logical Unit Number (LUN) for the data disk. If the disk is the first disk that is added, this element is optional and the default value of 0 is used. If more than one disk is being added, this element is required.

Aliases

None

Required?

false

Position

5

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-CreateOption <String>

Specifies whether to create a disk in the VM from a platform or user image, to create a new empty disk or to attach an existing disk. Valid values are

"FromImage”, “Attach” or “Empty”

Aliases

None

Required?

true

Position

6

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-SourceImageUri <String>

Uri of the existing VHD in case attaching the disk to the VM

Aliases

None

Required?

false

Position

7

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Profile <AzureProfile>

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-InformationAction <ActionPreference>

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-InformationVariable <String>

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type


Return Type


Notes

Examples

-------------------------- Add Data Disk to a new VM --------------------------

# Create the local VM Object
$vm =  New-AzureVMConfig –VMName “myVM” –VMSize “Standard_A1" -AvailabilitySetID $as1.Id

$stoname = 'teststo';
$stotype = 'Standard_GRS';

$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";

$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";

# Add Data Disks to this VM
$vm = Add-AzureVMDataDisk -VM $vm -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 0 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$vm = Add-AzureVMDataDisk -VM $vm -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 1 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
$vm = Add-AzureVMDataDisk -VM $vm -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 2 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;

-------------------------- Add a Data Disk to an existing VM --------------------------

# Get the VM
$vm = Get-AzureVM -ResourceGroupName "myRG" -Name "crpVM"

# Add Data Disk disk1 to VM
Add-AzureVMDataDisk –VM $vm –Name "disk1" –VhdUri "http://storageaccountname.blob.core.windows.net/vhds/test2.vhd" –LUN 0 –Caching ReadOnly –DiskSizeinGB 1 -CreateOption Empty;

# Update VM state
Update-AzureVM -ResourceGroupName "myRG" -Name "crpVM" –VM $vm