Bug in computemanagement.py when creating vm's from storage vhd.
Problem: When trying to create a vm instance from a storage image an error is thrown because the storage image uri can not be derived. The problem is a reference to the wrong attribute (uri) on the source_image object. It should use the referenced_uri attribute.
Dev Environment: - azure sdk (1.0.2) azure compute 0.20.2 - error is also in master OS -RHEL 6.7 - python 2.75
Solution: On line 6309 in computemanagement.py if parameters.storage_profile.os_disk.source_image.uri is not None: image_value['uri'] = parameters.storage_profile.os_disk.source_image.uri
This should be: image_value['uri'] = parameters.storage_profile.os_disk.source_image.reference_uri
Example using SDK to create the storage profile: storage_profile=azure.mgmt.compute.StorageProfile( os_disk=azure.mgmt.compute.OSDisk( caching=azure.mgmt.compute.CachingTypes.none, create_option=azure.mgmt.compute.DiskCreateOptionTypes.from_image, name=self.OS_DISK_NAME, operating_system_type="Windows", virtual_hard_disk=azure.mgmt.compute.VirtualHardDisk( uri="https://some.blob.core.windows.net/vhds/bbxxxx.vhd" ), source_image=azure.mgmt.compute.SourceImageReference( reference_uri="https://some.blob.core.windows.net/system/Microsoft.Compute/Images/somevm4/somevm-osDisk.eaeec132-ebfe-4835-xxxxx.vhd", ), ),
Hi,
Unfortunately, the "reference_uri" is not officially supported by the ARM API currently, as you can see here (no mention of this parameter): https://msdn.microsoft.com/en-us/library/azure/mt163591.aspx#bk_storage
The parameter will disapear in the 2.0.0 version of the Python SDK. You have to use the others parameters to point to your image. Sorry about that....
Hi Laurent,
Thank you for your reply. In the link above I do not see any mention of a SourceImageReference. If you do not have the SourceImageReference how can you create vms from generalized (custom) images in a storage account? Note this is different from the ImageReference which would only be used to create VMS from a market place platform image.
In the Azure SDK for Python Documentation, Release 1.0.3 this is described as the source image:
class azure.mgmt.compute.computemanagement.StorageProfile(**kwargs) Bases: object Describes a storage profile. data_disks Gets or sets the data disks. image_reference Gets or sets the image reference. os_disk Gets or sets the OS disk. source_image Gets or sets the source image reference.
This support is currently in the 1.0.2/3/master python SDK and working with the attribute change. Is this not going to be supported in the future releases?
Thanks again for your help,
Brad Blancett
Hi @sametimesolutions
I will close this issue, I was unable to fix it in the correct time and 1.0.x is now deprecated (2.0 is released last week). Sorry if it caused problems on your side :(
If you have the opportunity to try your scenario with the latest azure package, it would be great and I will be glad to help you.
Thank you,