i new using azure sdk , working it. read quite few example on how create virtual machine none of them worked me.
i getting error in sms.add_os_image method prior creating virtual machine. can vm created without method? should used media link , image name in case?
a part of current erroneous code looks 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() 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 please me resolve error?
thanks!
generally, if image has in images gallery , encounter error "conflict" when add repeatedly. suggest check image whether has registered in image gallery. if image gallery has image, can use image name , url directly. also, created project testing method:
os_image_url='https://**.blob.core.windows.net/communityimages/**-**-**-1.vhd' image_name = 'ub-13-4-test' sms.add_os_image(label=image_name, media_link=os_image_url, name=image_name, os='linux') before create vm, need create cloud service container vm. can see code:
name = 'myvmpython' location = 'east asia' sms.create_hosted_service(service_name=name, label=name, location=location) linux_config = linuxconfigurationset(host_name=name, user_name='*', user_password='*', 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') by way, used python 2.7. also, share error message further helps.
Comments
Post a Comment