0

我正在尝试使用 python SDK 获取功能应用程序的详细信息并找到合适的客户端和方法。我可以使用 ResourceManagementClient 并获取有关它们的基本信息,但无法获取运行时和其他详细信息。我可以运行 CLIaz functionapp list并获取所有详细信息。我正在寻找使用 python SDK 做一些等效的事情

4

1 回答 1

1

下面的代码将为我们提供包含所有详细信息的功能应用程序列表:

将您的订阅 ID 和资源组输入到它们各自的变量中。

# Import the needed credential and management objects from the libraries.
from types import FunctionType
from azure.identity import AzureCliCredential
from azure.mgmt.resource import ResourceManagementClient
import os

credential = AzureCliCredential()
subscription_id = "SUBSCRIPTION_ID" #Add your subscription ID
resource_group = "RESOURCE_GROUP_ID" #Add your resource group
resource_client = ResourceManagementClient(credential, subscription_id)
resource_list = resource_client.resources.list()

print(resource_list)
column_width =36
print("Resource".ljust(column_width) + "Type".ljust(column_width)+ "Id".ljust(column_width))
print("-" * (column_width * 2))
for resource in list (resource_list) :
    if (resource.type == "Microsoft.Web/sites" ) and ((resource.kind == "functionapp" ) or (resource.kind == "functionapp,linux" )) :
        print(f"{resource.name:<{column_width}}{resource.type:<{column_width}}{resource.id:<{column_width}}")

检查文档以添加额外的参数。

我的测试输出信息:

输出图片

于 2021-08-18T09:35:29.067 回答