Reputation: 388
I am trying to follow this document in order to create OS Managed Disk (Ubuntu 18.04). However I cannot find suitable body example to create such disk. I tried to send this:
PUT https://management.azure.com/subscriptions/mysubscription/resourceGroups/myresourcegroup/providers/Microsoft.Compute/disks/mydisk?api-version=2018-09-30
{
"name": "mydisk",
"location": "westus2",
"properties": {
"osType": "Linux",
"diskSizeGB": 32,
"creationData": {
"createOption": "FromImage",
"imageReference": {
"id": "/subscriptions/mysubscription/Providers/Microsoft.Compute/Locations/westus2/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/UbuntuServer"
}
}
}
}
but I got response:
{
"error": {
"code": "InvalidParameter",
"message": "The value of parameter imageReference is invalid.",
"target": "imageReference"
}
}
Is there a way to create such disk? Subscription id and resource group name were edited in my examples.
I am trying to create such disk this way because if I specify it during VM creation it will generate some name for OS Managed Disk. And then when I need to delete VM it will be hard to determine which OS Managed Disk to delete. So I want this disk to have specified name, not random.
Upvotes: 0
Views: 847
Reputation: 31384
As the error shows, the value of parameter imageReference is invalid. There will be many versions of a special image. For example, the UbuntuServer have many SKUs in Azure image.
When you create the VM, you can take a look at the OS disk with the CLI command:
az disk show -g yourgroup -n yourdisk
And you will see the imageReference, for image UbuntuLTS, the id will like this:
/Subscriptions/yoursubscription/Providers/Microsoft.Compute/Locations/eastus/Publishers/Canonical/ArtifactTypes/VMImage/Offers/UbuntuServer/Skus/18.04-LTS/Versions/18.04.201903200
So you should provide a special image. Not the UbuntuServer.
Upvotes: 2