1

VM create fails with is osDisk error: msrestazure.azure_exceptions.CloudError: Changing property 'osDisk.image.uri' is not allowed.

Code snippet is as follows:

 storage_profile=azure.mgmt.compute.models.StorageProfile(
            os_disk=azure.mgmt.compute.models.OSDisk(
                caching=azure.mgmt.compute.models.CachingTypes.none,
                create_option=azure.mgmt.compute.models.DiskCreateOptionTypes.from_image,
                name=OS_DISK_NAME,
                os_type='Linux',
                vhd=azure.mgmt.compute.models.VirtualHardDisk(
                    uri='https://{0}.blob.core.windows.net/vhds/{1}.vhd'.format(
                        STORAGE_NAME,
                        OS_DISK_NAME,
                    ),
                ),
                image=azure.mgmt.compute.models.VirtualHardDisk(
                    uri='https://xxxxxxxxx.blob.core.windows.net/vm-images/Centos67-Azure.vhd'
                ),
            )

image is defined in the python API and the URi defined works fine with the Azure CLI

API azure==2.0.0rc3

If it helps this is the transaction being sent to azure:

url: hps://management.azure.com/subscriptions/b97ddb69-f825-48b4-9e19-48eb3b4c8267/resourceGroups/dev-eu-vnet9-rg/providers/Microsoft.Compute/virtualMachines/centos67-api

header parameters: {'accept-language': 'en-US', 'Content-Type': 'application/json; charset=utf-8', 'x-ms-client-request-id': 'f65196f4-0e3b-11e6-a61b-b499baffc71a'}

body content: {'properties': {'storageProfile': {'osDisk': {'osType': 'Linux', 'createOption': 'fromImage', 'name': 'centos67-api', 'caching': 'None', 'vhd': {'uri': 'https://deveuvnet9rg9944.blob.core.windows.net/vhds/centos67-api.vhd'}, 'image': {'uri': 'https://deveuvnet9rg9944.blob.core.windows.net/vm-images/Centos67-Azure.vhd'}}}, 'hardwareProfile': {'vmSize': 'Standard_DS1'}, 'osProfile': {'adminUsername': 'cloud_user', 'computerName': 'centos67-api', 'adminPassword': 'xxxxxxxx'}, 'networkProfile': {'networkInterfaces': [{'id': '/subscriptions/b97ddb69-f825-48b4-9e19-48eb3b4c8267/resourceGroups/dev-eu-vnet9-rg/providers/Microsoft.Network/networkInterfaces/centos67-api'}]}}, 'location': 'eastus'}

Traceback (most recent call last): File "./azure_client.py", line 220, in result.wait() # async operation File "/usr/lib/python2.7/site-packages/msrestazure/azure_operation.py", line 639, in wait raise self._exception msrestazure.azure_exceptions.CloudError: Changing property 'osDisk.image.uri' is not allowed.

2
  • from the class definition for OSDisk: Commented Apr 28, 2016 at 14:57
  • According to the document for REST API Create or update a virtual machine, the request body content not includes the property image of the osDisk for the storageProfile. Commented May 4, 2016 at 9:25

2 Answers 2

1

The issue has been resolved. Turned out the error returned is somewhat misleading. The issue was that there was that the target disk already existed and therefore couldn't be modified (i.e. change property error).

Once the target had a unique name the process worked properly and I was able to create VMs from my custom image.

Sign up to request clarification or add additional context in comments.

Comments

0

According to the document, the class StorageProfile construction function has three parameters include image_reference, os_disk and data_disk. The parameter image in your code should be the class azure.mgmt.compute.models.ImageReference, not the class azure.mgmt.compute.models.VirtualHardDisk.

As reference, here is the sample code from the document.

storage_profile=azure.mgmt.compute.models.StorageProfile(
    os_disk=azure.mgmt.compute.models.OSDisk(
        caching=azure.mgmt.compute.models.CachingTypes.none,
        create_option=azure.mgmt.compute.models.DiskCreateOptionTypes.from_image,
        name=OS_DISK_NAME,
        vhd=azure.mgmt.compute.models.VirtualHardDisk(
            uri='https://{0}.blob.core.windows.net/vhds/{1}.vhd'.format(
                STORAGE_NAME,
                OS_DISK_NAME,
            ),
        ),
    ),
    image_reference = azure.mgmt.compute.models.ImageReference(
        publisher=IMAGE_PUBLISHER,
        offer=IMAGE_OFFER,
        sku=IMAGE_SKU,
        version=IMAGE_VERSION,
    ),
)

Hope it helps. Any concern, please feel free to let me know.

2 Comments

ImageReference is for using Published images from the Azure Store, not for custom images uploaded Azure. That works perfectly fine. Unfortunately I need to use customized images that we create and upload
This is part of the definition for OSDisk. Look at the definition for image class OSDisk(Model): """ Describes an Operating System disk. ... :param image: Gets or sets the Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine.If SourceImage is provided, the destination VirtualHardDisk should not exist. :type image: :class:VirtualHardDisk <azure.mgmt.compute.models.VirtualHardDisk> ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.