1

I'm trying to create a new VM using existing Managed disks and I keep running into problems because the parameters are not very well documented.

One problem that I haven't figured out is the format of --attach-data-disks

From the name and description of the parameter this seems to be the way you can attach data disks to the VM that you are creating and I am assuming because it is --attach-data-disks and not --attach-data-disk that you can attach multiple disks using this parameter.

What I don't know is what format to use when passing multiple disks. I have tried separating them using commas but the error that I got seemed to indicate that it viewed the comma delimited list of drives as one long name for a drive.

Here is an example of what I am trying to do:

az vm create -g test-group -n testvm2 --os-type windows --attach-os-disk testvm1-osdisk-20181213-033052 --attach-data-disks "testvm1-datadisk-000-20181213-033052,testvm1-datadisk-001-20181213-033052,testvm1-datadisk-002-20181213-033052"

Error I'm getting:

Deployment failed. Correlation ID: 9999. {
  "error": {
    "code": "InvalidParameter",
    "message": "Id /subscriptions/99999999/resourceGroups/lbacompensafe/providers/Microsoft.Compute/disks/testvm1-datadisk-000-20181213-033052,testvm1-datadisk-001-20181213-033052,testvm1-datadisk-002-20181213-033052 is not a valid resource reference.",
    "target": "dataDisk.managedDisk.id"
  }
}

I'm running the commands from Powershell, not Bash, if that makes a difference.

Zack
  • 2,291
  • 2
  • 23
  • 38

1 Answers1

2

Figured it out. It is in fact a space delimited list. I didn't try this sooner because I incorrectly assumeed it would need some sort of grouping or it would look like different parameters, but just listing them out like

--attach-data-disks disk1 disk2 disk3

Will add them in that order. Wish the docs would have just said so. Would have saved me a bunch of time.

Zack
  • 2,291
  • 2
  • 23
  • 38