Edit

Share via


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

NoResize

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

Resize

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.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Resize
Position:3
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

NoResize
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InformationAction

Specifies how this cmdlet responds to an information event.

The acceptable values for this parameter are:

  • Continue
  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend

Parameter properties

Type:ActionPreference
Default value:None
Supports wildcards:False
DontShow:False
Aliases:infa

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InformationVariable

Specifies an information variable.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:iv

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-LUN

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

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

NoResize
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:AzureSMProfile
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResizedSizeInGB

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

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Resize
Position:4
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:IPersistentVM
Default value:None
Supports wildcards:False
DontShow:False
Aliases:InputObject

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.