Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,874 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I would like to override a volume of a vm with a different volume on the vm at the time of bootup.
Right now first I delete the existing volume and then I try to attach the new volume. Is there any other way that azure recommends?
snapshot = a.compute_client.snapshots.get(resource_group_name=a.rg_name, snapshot_name='snap_db')
creation_data = CreationData(create_option=DiskCreateOption.copy, source_resource_id='/subscriptions/snap_db')
disk = Disk(location='eastus2', creation_data=creation_data, tags=set_tags ,zones=['1'], sku={"name": 'StandardSSD_LRS'})
created_disk = a.compute_client.disks.create_or_update(resource_group_name=a.rg_name,disk_name='snap_db_vol", disk=disk)
vm = a.compute_client.virtual_machines.get(a.rg_name, 'snap_host')
data_disk = {
'lun': 12,
'create_option': DiskCreateOption.attach,
'managed_disk': {
'id': disk.id
}
}
a.compute_client.virtual_machines.create_or_update(a.rg_name, 'snap_host', vm)