question

AdamsA-8016 avatar image
0 Votes"
AdamsA-8016 asked AdamsA-8016 commented

Disk not found error when updating vm with data disk in different location

Hello,

I'm actually training for AZ-104, and while working on adding data disk to virtual machine with command line, I had this error :
![136432-image.png][2]


Saying that the disk "newdisk02" was not found. But I checked and the disk exist, but in a different location than the vm.
VM location : West Europe
136434-image.png


Disk location : North Europe
136385-image.png


[2]: /answers/storage/attachments/136433-image.png


I changed the disk location to the same as the VM in the script and the disk was added successfully.
I don't understand why it is not possible for a disk to be in a different location than the vm. Maybe it is a silly question lol I don't know.
Can someone explain please ?

Here is the script :

$resourcegroup = 'test-grp'
$machinename = 'demolinux'
$location = 'North Europe'
$storageType = 'Standard_LRS'
$dataDiskName = 'newdisk02'
$dataDiskSize = 20

 $datadiskConfig = New-AzDiskConfig -SkuName $storageType -Location $location -CreateOption Empty -DiskSizeGB $dataDiskSize
     
 $dataDisk01 = New-AzDisk -DiskName $dataDiskName -Disk $datadiskConfig -ResourceGroupName $resourcegroup
     
 $vm = Get-AzVM -Name $machinename -ResourceGroupName $resourcegroup
     
 $vm = Add-AzVMDataDisk -VM $vm -Name $dataDiskName -CreateOption Attach -ManagedDiskId $dataDisk01.Id -Lun 1
     
 Update-AzVM -VM $vm -ResourceGroupName $resourcegroup
azure-virtual-machinesazure-disk-storage
image.png (14.0 KiB)
image.png (24.6 KiB)
image.png (16.8 KiB)
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

TravisCragg-MSFT avatar image
0 Votes"
TravisCragg-MSFT answered AdamsA-8016 commented

This is expected behavior. Disks you attach to a VM must be in the same region (datacenter) as the VM.

The reason for this requirement is that it would take too long / be too expensive to query data in a different datacenter on a regular basis, and would likely lead to issues with the VM due to the slow latency & throughput on the disk.

If you have a disk in a different region that you want to attach to your VM, you will need to move/copy your disk to the VM's region first .

· 1
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.

Ok I understand, thank you !

0 Votes 0 ·