from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.compute import ComputeManagementClient
client = get_client_from_cli_profile(ComputeManagementClient)
result = [vmss.name for vmss in client.virtual_machine_scale_sets.list('xyzrg', 'xyz')]
为了严格回答您的问题,CLI可以返回JSON,您可以解析它。我想根据您的问题,您将从Python子处理CLI,因此获取子进程输出并将其重新解析为JSON。在
话虽如此,我不得不说,如果这是你唯一的需要,那就太复杂了,你最好使用SDK: https://docs.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2018_04_01.operations.virtualmachinescalesetsoperations?view=azure-python#list
如果您担心的是身份验证问题,您甚至可以加载CLI凭据: https://docs.microsoft.com/en-us/python/azure/python-sdk-azure-authenticate?view=azure-python#mgmt-auth-cli
这可以用几行来完成:
只是说说而已
相关问题 更多 >
编程相关推荐