Set-​Azure​Data​Disk

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

Syntax

Set-AzureDataDisk
   [-DiskName] <String>
   [-ResizedSizeInGB] <Int32>
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-Profile <AzureSMProfile>]
   -VM <IPersistentVM>
   [<CommonParameters>]
Set-AzureDataDisk
   [-HostCaching] <String>
   [-LUN] <Int32>
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-Profile <AzureSMProfile>]
   -VM <IPersistentVM>
   [<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.

Required Parameters

-DiskName

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

Type:String
Position:3
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-HostCaching

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

  • ReadOnly
  • ReadWrite
Type:String
Position:0
Default value:None
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
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
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
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False

Optional Parameters

-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
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
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
Accept pipeline input:False
Accept wildcard characters:False