# 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}}")
from azure.identity import AzureCliCredential
from azure.mgmt.web import WebSiteManagementClient
credential = AzureCliCredential()
subscription_id = "SUBSCRIPTION_ID" #Add your subscription ID
resource_group = "RESOURCE_GROUP_ID" #Add your resource group
function_app_name = "FUNCTION_APP_NAME" #Add your function app name
# Create the web management client
web_mgmt_client = WebSiteManagementClient(credential, subscription_id)
# Get function app details
function_app_details = app_service_client.web_apps.get(resource_group, function_app_name)
print(function_app_details)
# Get function app configuration details
function_app_config = app_service_client.web_apps.get_configuration(resource_group, function_app_name)
print(function_app_config)
# List function app application settings
function_app_settings = app_service_client.web_apps.list_application_settings(resource_group, function_app_name)
print(function_app_settings)
2条答案
按热度按时间tzdcorbm1#
下面的代码将为我们提供功能应用程序列表以及所有详细信息:
在相应的变量中输入您的订阅ID和资源组。
有关添加额外参数的信息,请查看文档。
测试的输出信息:
bhmjp9jg2#
您可以使用WebSiteManagementClient类查询函数应用程序的更多详细信息。
WebSiteManagementClient示例可以示例化WebAppsOperations类,该类允许您在函数应用上执行许多操作。
请参阅下面的示例代码,我的工作:
有关需要访问的任何其他详细信息,请参阅WebAppsOperations方法。