I am new to using the azure sdk and working with it. I read quite a few example on how to create a virtual machine but none of them worked for me.
I am getting an error in the sms.add_os_image method prior to creating a virtual machine. Can a VM be created without that method? what should be used as the media link and image name in that case?
A part of my current erroneous code looks like this:
#storage account:
result = sms.create_storage_account(name, desc, label, affinity_group=name)
operation_result = sms.get_operation_status(result.request_id)
print('Operation status: ' + operation_result.status)
result = sms.list_storage_accounts()
for account in result:
print('Service name: ' + account.service_name)
print('Affinity group: ' + account.storage_service_properties.affinity_group)
print('Location: ' + account.storage_service_properties.location)
print('')
#blob service:
storage_response=sms.get_storage_account_keys(name)
print "finished getting primary key " + storage_response.storage_service_keys.primary
account_key = storage_response.storage_service_keys.primary
blob_service = BlobService(account_name=name, account_key=account_key)
#container:
blob_service.create_container('containermaryland13')
target_blob_name = name+'.vhd'
os_image_url='https://{}.blob.core.windows.net/containermaryland13/{}'.format(name, target_blob_name)
image_name = '03f55de797f546a1b29d1b8d66be687a__CoreCLR-x64-Beta5-Linux-PartsUnlimited-Demo-App-201504.29'
sms.add_os_image(label=image_name, media_link=os_image_url, name=image_name, os='Linux')
linux_config = LinuxConfigurationSet(host_name='hostname', user_name='username', user_password='mypassword', disable_ssh_password_authentication=True)
os_hd = OSVirtualHardDisk(source_image_name=image_name, media_link=os_image_url)
sms.create_virtual_machine_deployment(service_name=name,
deployment_name=name,
deployment_slot='production',
label=name,
role_name=name,
system_config=linux_config,
os_virtual_hard_disk=os_hd,
role_size='Small')
"""
Can someone please help me resolve this error?
Thanks!
Also, you can add image into Image Gallery:

