Using the CLI, there is a simple command to create am image from a VM :
az image create \
--resource-group myResourceGroup \
--name myImage --source myVM
But I am having a hard time achieving the same thing with the Python client lib. The method begin_create_or_update
from azure.mgmt.compute.v2020_06_01.operations.imagesoperations
seems to be the right one but misses the source
parameter.
What is the correct approach?
So after a lot of experimentation I got it working like this.
vm = compute_client.virtual_machines.get(resource_group, instance_name)
compute_client.images.begin_create_or_update(resource_group, image_name,
Image(location=vm.location, source_virtual_machine=SubResource(id=vm.id))).wait(120)
The trick was to provide the Image
argument and within it the VM id as a SubResource
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.