Azure-Samples / virtual-machines-python-manage

An example illustrating how to use Python to manage your Azure Virtual Machines
MIT License
104 stars 84 forks source link

VM start/stop action too slow #26

Closed indumathymk closed 5 years ago

indumathymk commented 5 years ago

Am using following code to start and stop virtual machine,it will take more than 20 minutes to activate. Have to know any issue with my code or some other reasons. My code as follows, **$requestazure = $client->request('GET', "vm?group=$group&name=$name&req=Start");

compute_client = ComputeManagementClient(credentials, subscription_id)
                try:
                        if vmReq == 'Start':
                                async_vm_start = compute_client.virtual_machines.start(group,vmName)
                                async_vm_start.wait()
                        if vmReq == 'Stop':
                                async_vm_stop = compute_client.virtual_machines.deallocate(group,vmName)
                                async_vm_stop.wait()
                        vm_state=compute_client.virtual_machines.get(group,vmName, expand='instanceView',region = '')
                        state=vm_state.instance_view.statuses[1].display_status
                except Exception as e:
                        print(e)**

Thanks.

lmazuel commented 5 years ago

Hi @indumathymk There is no problem with your code, at worst you can lose 30 seconds too much (which is the default waiting time of the SDK), but 20 minutes it means Azure needed 20 minutes to start/stop the VM and told the SDK explicitly. If you believe this is not normal, please open a support ticket using the Azure portal. thanks!