Editar

Compartilhar via


New-AzVMDataDisk

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

Syntax

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

Description

The New-AzVMDataDisk 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.

$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

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

New-AzVMDataDisk -Caching None -CreateOption Attach -DiskSizeInGB 1 -Lun 2 -Name 'AgentPool01'

Parameters

-Caching

The virtual machine data disk's caching.

Type:CachingTypes
Accepted values:None, ReadOnly, ReadWrite
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-CreateOption

The virtual machine data disk's create option.

Type:String
Position:1
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

The virtual machine managed disk encryption set's Id.

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

-DiskSizeInGB

The virtual machine data disk's size in GB.

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Lun

The virtual machine data disk's Lun.

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

-ManagedDiskId

The virtual machine managed disk's Id.

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

-Name

The virtual machine data disk's name.

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

-SourceImageUri

The virtual machine OS disk's source image Uri.

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

-StorageAccountType

The virtual machine managed disk's account type.

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

-VhdUri

The virtual machine data disk's Vhd Uri.

Type:String
Position:Named
Default value:None
Required:False
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

Int32

String

CachingTypes

Nullable<T>[[System.Int32, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]

Outputs

PSVirtualMachineDataDisk