1
微軟爲azure創建了一個反人類api。我如何通過azure python sdk重新啓動虛擬機?一些演示代碼會很棒。通過azure python sdk重啓虛擬機
微軟爲azure創建了一個反人類api。我如何通過azure python sdk重新啓動虛擬機?一些演示代碼會很棒。通過azure python sdk重啓虛擬機
雖然這是舊的,這裏有一個示例代碼:
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient
credentials = ServicePrincipalCredentials(client_id=clientid, secret=secret,
tenant=tenantid)
compute_client = ComputeManagementClient(credentials, subscriptionid)
vm_restart = compute_client.virtual_machines.restart(resource_group_name, vm_name)
vm_restart.wait()
vm_instance = compute_client.virtual_machines.get(resource_group_name, vm_name)
其中vm_instance是一個包含其所有CONFG信息VM對象。
非常感謝,即使我沒有機會嘗試。 – xdays 2017-04-06 13:47:58
看看這裏:https://github.com/Azure/azure-sdk-for-python/blob/master/tests/test_servicemanagementservice.py#L1852。不知道它是否適用於虛擬機,但我認爲它適用於雲服務。 – 2014-12-03 06:15:56