2024-09-28 03:17:48 发布
网友
我想使用azuresdkforpython从资源组释放VM。 我已经用sdk(compute)创建了一个虚拟机_客户端虚拟机。create\u or \u update),但我找不到任何特定方法来停止或取消分配VM。在
谢谢你
你可以参考azuresdkforpython的文档,找到VirtualMachinesOperations的方法deallocate,请参见{a1}。在
VirtualMachinesOperations
deallocate
这是代码作为参考。在
from azure.common.credentials import ServicePrincipalCredentials from azure.mgmt.compute import ComputeManagementClient, ComputeManagementClientConfiguration credentials = ServicePrincipalCredentials( client_id = '<client-id>', secret = '<key>', tenant = '<tenant-id>' ) subscription_id = '<subscription-id>' compute_config = ComputeManagementClientConfiguration(credentials, subscription_id, api_version='2015-05-01-preview') compute_client = ComputeManagementClient(compute_config) resource_group_name = '<resource-group>' vm_name = '<vm-name>' result = compute_client.virtual_machines.deallocate(resource_group_name, vm_name)
你可以参考azuresdkforpython的文档,找到
VirtualMachinesOperations
的方法deallocate
,请参见{a1}。在这是代码作为参考。在
相关问题 更多 >
编程相关推荐