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

Adams A 21 Reputation points


I'm actually training for AZ-104, and while working on adding data disk to virtual machine with command line, I had this error :

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

Disk location : North Europe

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 Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
5,276 questions
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
417 questions
0 comments No comments
{count} votes

Accepted answer
  1. TravisCragg-MSFT 5,646 Reputation points Microsoft Employee

    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 .

0 additional answers

Sort by: Most helpful