Set-AzureDataDisk

Modifies the host caching of an existing data disk on an Azure virtual machine.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

Set-AzureDataDisk
   [-HostCaching] <String>
   [-LUN] <Int32>
   -VM <IPersistentVM>
   [-Profile <AzureSMProfile>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]
Set-AzureDataDisk
   [-DiskName] <String>
   [-ResizedSizeInGB] <Int32>
   -VM <IPersistentVM>
   [-Profile <AzureSMProfile>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]

Description

The Set-AzureDataDisk cmdlet modifies the cache attributes of an existing data disk on an Azure virtual machine. Specify which data disk to update by its logical unit number (LUN).

Examples

Example 1: Modify the host caching for a data disk

PS C:\> Get-AzureVM "ContosoService" | Set-AzureDataDisk -VM "VirtualMachine07" -LUN 2 -HostCaching ReadOnly | Update-AzureVM

This command gets the virtual machines that run on the service named ContosoService by using the Get-AzureVM cmdlet. The command passes them to the current cmdlet by using the pipeline operator. That cmdlet sets the data disk at LUN 2 of the virtual machine named VirtualMachine07 to use ReadOnly host caching. The command updates the virtual machine to reflect your changes by using the Update-AzureVM cmdlet.

Example 2: Modify the host caching for all data disks on a virtual machine

PS C:\> Get-AzureVM "ContosoService" -Name "VirtualMachine07" | Get-AzureDataDisk | Set-AzureDataDisk -HostCaching ReadWrite | Update-AzureVM

This command gets an object for the virtual machine named VirtualMachine07 on the ContosoService cloud service. The command passes it to the Get-AzureDataDisk cmdlet, which gets the data disks for that virtual machine. The current cmdlet then sets the host caching mode of each data disks to ReadWrite. The command updates the virtual machine to reflect your changes.

Parameters

-DiskName

Specifies the name of the data disk configuration that this cmdlet modifies.

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

-HostCaching

Warning

Disk Caching is not supported for disks 4 TiB and larger. If multiple disks are attached to your VM, each disk that is smaller than 4 TiB will support caching.

Changing the cache setting of an Azure disk detaches and re-attaches the target disk. If it is the operating system disk, the VM is restarted. Stop all applications/services that might be affected by this disruption before changing the disk cache setting. Not following those recommendations could lead to data corruption.

Specifies the host level caching settings of the disk. Valid values are:

  • None
  • ReadOnly
  • ReadWrite
Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-InformationAction

Specifies how this cmdlet responds to an information event.

The acceptable values for this parameter are:

  • Continue
  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InformationVariable

Specifies an information variable.

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

-LUN

Specifies the LUN for the data drive in the virtual machine. Valid values are: 0 through 15.

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

-Profile

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

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

-ResizedSizeInGB

Specifies the new size, in gigabytes, for the data disk. The new size must be larger than the current size.

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

-VM

Specifies the virtual machine object that is attached to the data disk. To obtain a virtual machine object, use the Get-AzureVM cmdlet.

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