New-AzureRmVMDataDisk
Creates a local data disk object for a virtual machine or a Vmss VM.
Warning
The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.
Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.
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 |
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: | AzureRmContext, AzureCredential |
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
Nullable<T>[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]