New-AzureRmVMDataDisk

Creates a local data disk object for a virtual machine or a Vmss VM.

Syntax

New-AzureRmVMDataDisk
   [-Lun] <Int32>
   [-CreateOption] <String>
   [-Name <String>]
   [-Caching <CachingTypes>]
   [-DiskSizeInGB <Int32>]
   [-VhdUri <String>]
   [-SourceImageUri <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzureRmVMDataDisk
   [-Lun] <Int32>
   [-CreateOption] <String>
   [-Name <String>]
   [-Caching <CachingTypes>]
   [-DiskSizeInGB <Int32>]
   [-ManagedDiskId <String>]
   [-StorageAccountType <String>]
   [-WriteAccelerator]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The New-AzureRmVMDataDisk cmdlet creates a local data disk object for a virtual machine or a Vmss VM.

Examples

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

PS C:\> $disk = Get-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname0
PS C:\> $datadisk = New-AzureRmVMDataDisk -Caching 'ReadOnly' -Lun 2 -CreateOption Attach -StorageAccountType Standard_LRS -ManagedDiskId $disk.Id
PS C:\> $VmssVM = Get-AzureRmVmssVM -ResourceGroupName "myrg" -VMScaleSetName "myvmss" -InstanceId 0
PS C:\> Update-AzureRmVmssVM -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.

Parameters

-Caching

The virtual machine data disk's caching.

Type:CachingTypes
Accepted values:None, ReadOnly, ReadWrite
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-CreateOption

The virtual machine data disk's create option.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-DefaultProfile

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

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DiskSizeInGB

The virtual machine data disk's size in GB.

Type:System.Nullable`1[System.Int32]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Lun

The virtual machine data disk's Lun.

Type:Int32
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ManagedDiskId

The virtual machine managed disk's Id.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Name

The virtual machine data disk's name.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-SourceImageUri

The virtual machine OS disk's source image Uri.

Type:String
Aliases:SourceImage
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-StorageAccountType

The virtual machine managed disk's account type.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-VhdUri

The virtual machine data disk's Vhd Uri.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Int32

String

CachingTypes

System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

Outputs

Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineDataDisk