0
votes

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.

1
why do you need that though? you can specify that during vm creation4c74356b41
@4c74356b41 Thank you for your question. I included answer to your question in my question.Geslot
you can specify os disk name during vm creation4c74356b41
@4c74356b41Thank you! Your suggestion is even better than what I originally asked. I tried it and it worksGeslot

1 Answers

2
votes

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.