The Azure SDK for Python support creates a virtual machine with a custom image.
" " Azure Portal, OS_DISK_NAME
& STORAGE_NAME
VHD Azure Python SDK.
API- Azure Python SDK API REST. REST API " " https://msdn.microsoft.com/en-us/library/azure/mt163591.aspx, osDisk
(. , ).
, ( image_reference
), :
result = compute_client.virtual_machines.create_or_update(
GROUP_NAME,
azure.mgmt.compute.VirtualMachine(
location=REGION,
name=VM_NAME,
os_profile=azure.mgmt.compute.OSProfile(
admin_username=ADMIN_USERNAME,
admin_password=ADMIN_PASSWORD,
computer_name=COMPUTER_NAME,
),
hardware_profile=azure.mgmt.compute.HardwareProfile(
virtual_machine_size=azure.mgmt.compute.VirtualMachineSizeTypes.standard_a0
),
network_profile=azure.mgmt.compute.NetworkProfile(
network_interfaces=[
azure.mgmt.compute.NetworkInterfaceReference(
reference_uri=nic_id,
),
],
),
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=OS_DISK_NAME, // Your VHD name
virtual_hard_disk=azure.mgmt.compute.VirtualHardDisk(
uri='https://{0}.blob.core.windows.net/vhds/{1}.vhd'.format(
STORAGE_NAME, // your storage account name
OS_DISK_NAME, // Your VHD name
),
),
)
),
),
)