question

GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 asked GlennMaxwell-2309 edited

host caching

Hi All

I have a windows 2019 server hosted in Azure. I want to add additional drive to it. The server currently has operating system drive only.
I want to add additional drive using PowerShell. i am not sure what should be the default caching or recommended value to be set for additional drive. please guide me. if i dont mention caching what value will it take. in the below syntax i just put ReadOnly but i am not sure

 $vmName = "Server01"
 $disk_name = "_DataDrive"
 $size = 100
 $lun = 0
 $vm = Get-AzVM -Nam $vmName
 $rgName = $vm.ResourceGroupName
 $location = $vm.location 
 $storageType = 'Premium_LRS'
 $dataDiskName = $vmName + $disk_name
 $tags = $vm.Tags
 $diskConfig = New-AzDiskConfig -SkuName $storageType -Location $location -CreateOption Empty -DiskSizeGB $size -tag $Tags
 $dataDisk1 = New-AzDisk -DiskName $dataDiskName -Disk $diskConfig -ResourceGroupName $rgName
 $vm = Add-AzVMDataDisk -VM $vm -Name $dataDiskName -CreateOption Attach -ManagedDiskId $dataDisk1.Id -Lun $lun -Caching 'ReadOnly'
 Update-AzVM -VM $vm -ResourceGroupName $rgName
azure-virtual-machineswindows-server-2019windows-server-2016azure-virtual-machines-networkingazure-virtual-machines-images
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 answered GlennMaxwell-2309 edited

As per the below article ReadWrite is the default value.

https://docs.microsoft.com/en-us/powershell/module/az.compute/add-azvmdatadisk?view=azps-6.3.0&viewFallbackFrom=azps-6.0.0#parameters

i believe the below syntax should work for me.

  $vmName = "Server01"
  $disk_name = "_DataDrive"
  $size = 100
  $lun = 0
  $vm = Get-AzVM -Nam $vmName
  $rgName = $vm.ResourceGroupName
  $location = $vm.location 
  $storageType = 'Premium_LRS'
  $dataDiskName = $vmName + $disk_name
  $tags = $vm.Tags
  $diskConfig = New-AzDiskConfig -SkuName $storageType -Location $location -CreateOption Empty -DiskSizeGB $size -tag $Tags
  $dataDisk1 = New-AzDisk -DiskName $dataDiskName -Disk $diskConfig -ResourceGroupName $rgName
  $vm = Add-AzVMDataDisk -VM $vm -Name $dataDiskName -CreateOption Attach -ManagedDiskId $dataDisk1.Id -Lun $lun -Caching 'ReadWrite'
  Update-AzVM -VM $vm -ResourceGroupName $rgName
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.