0
votes

I am creating my disk as follows:

az disk create -g ML-Resource-Group -n myDataDisk --size-gb 256 --location eastus --max-shares 2 --sku Premium_LRS

And I am creating my first VM as follows:

az vm create --resource-group ML-Resource-Group --name PVM --image microsoft-dsvm:ubuntu-1804:1804-gen2:20.11.04 --generate-ssh-keys --location eastus

And I am creating my second VM as follows:

az vm create \
    --resource-group ML-Resource-Group \
    --name VMTest \
    --image microsoft-dsvm:ubuntu-1804:1804-gen2:20.11.04  \
    --generate-ssh-keys \
    --priority Spot \
    --max-price -1 \
    --location eastus \
    --eviction-policy Deallocate \
    --output json \
    --verbose \
    --size "Standard_ND12s"

I attach myDataDisk to PVM as:

diskId=$(az disk show -g ML-Resource-Group -n myDataDisk --query 'id' -o tsv)
az vm disk attach -g ML-Resource-Group --vm-name PVM --name $diskId

This step is performed successfully. But when I try attaching the disk to VMTest in the same way as above, I get the following error:

Deployment failed. Correlation ID: 140afdfe-8b92-4c4d-a9a9-521d8bf3a497. Cannot change network spine of shared disk myDataDisk while it is attached to running VM(s) /subscriptions/39472272-11a1-4c87-9de5-92aaeac6f7cf/resourceGroups/ML-Resource-Group/providers/Microsoft.Compute/virtualMachines/PVM. Target: 'VM: '/subscriptions/39472272-11a1-4c87-9de5-92aaeac6f7cf/resourceGroups/ML-Resource-Group/providers/Microsoft.Compute/virtualMachines/VMTest', disk: '/subscriptions/39472272-11a1-4c87-9de5-92aaeac6f7cf/resourceGroups/ML-Resource-Group/providers/Microsoft.Compute/disks/myDataDisk''.

1

1 Answers

0
votes

Figured out the solution! A Proximity Placement Group is to be made as follows:

    az ppg create \
   -n myPPG \
   -g ML-Resource-Group \
   -l eastus \
   -t standard 

And then passed as a parameter in --ppg while creating VMs such as:

az vm create -n PVM -g ML-Resource-Group --image microsoft-dsvm:ubuntu-1804:1804-gen2:20.11.04 --generate-ssh-keys --ppg myPPG --location eastus --verbose