Friday, May 4, 2018

Configure azure disk caching


The disk that are attached to a VM has a option to set cache preference to manage local cache that are used for read or write operations. This settings can used to improve performance.

There are three cache options:

  • None 
  • Read Only 
  • Read/Write

Following are the steps to set the caching preference using portal

Navigate to the azure portal and click Virtual Machines




x
Azure Virtual Machines

Select the VM and click Disk from the blade

Azure host caching

Click Edit from the menu and select the appropriate Host Caching from the drop down.

Azure host caching

Click Save to save the changes.

Following are the steps to set the preferences using powershell

Azure Disk Caching in PowerShell

Powershell commands to update the host caching preferences.

Following example sets the caching to None
$vm  = Get-AzureRmVM -ResourceGroupName cprg -VMName cpvm
$vm.storageprofile.osdisk.Caching="None"

Other options
$vm.storageprofile.osdisk.Caching="ReadWrite"
$vm.storageprofile.osdisk.Caching="ReadOnly"