如何列出 Azure Function App 中的所有函数

How to list all the functions in an Azure Function App

我可以使用 PowerShell cmdlet Get-AzureRMResource 列出所有 Azure 资源。

是否有一个 cmdlet 接受一个 ResourceGroupName 和一个 SiteName 并且它 returns 具有 "Site" 中的所有功能。

或者,我可以使用 cmdlet 的组合来获取这些详细信息。

不是 PowerShell cmdlet,但您可以按照 here

所述使用 ListingFunctions API
Listing functions
get /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Web/sites/{functionapp}/functions?api-version=2015-08-01

Response:
{
  "value": [
    {
      ...
    }
  ]
}

正如 Fabio Cavalcante 所说,Azure PowerShell 不支持此功能,您可以使用 Rest API 来获取它。这是一个如何使用 PowerShell 获取函数的示例。

#

#get token
$TENANTID="<tenantid>"
$APPID="<application id>"
$PASSWORD="<app password>"
$result=Invoke-RestMethod -Uri https://login.microsoftonline.com/$TENANTID/oauth2/token?api-version=1.0 -Method Post -Body @{"grant_type" = "client_credentials"; "resource" = "https://management.core.windows.net/"; "client_id" = "$APPID"; "client_secret" = "$PASSWORD" }
$token=$result.access_token

##set Header
$Headers=@{
    'authorization'="Bearer $token"
    'host'="management.azure.com"
}

$functions = Invoke-RestMethod  -Uri "https://management.azure.com/subscriptions/<subscriptions id>/resourceGroups/<group name>/providers/Microsoft.Web/sites/<function name>/functions?api-version=2015-08-01"  -Headers $Headers -ContentType "application/json" -Method GET

$functions.value

这可以使用 Get-AzureRmResource cmdlet。

$Params = @{
    ResourceGroupName = $ResourceGroupName
    ResourceType      = 'Microsoft.Web/sites/functions'
    ResourceName      = $AppName
    ApiVersion        = '2015-08-01'
}
Get-AzureRmResource @Params

2021 年,您可以使用 func

func azure functionapp list-functions FUNCTION_NAME

azure-functions-core-tools@3

可用

你可以在下面使用

禁用

Update-AzFunctionAppSetting -Name <FUNCTION_APP_NAME> -ResourceGroupName <RESOURCE_GROUP_NAME> -AppSetting @{"AzureWebJobs.<Function_Name>.Disabled" = "true"}

启用

Update-AzFunctionAppSetting -Name <FUNCTION_APP_NAME> -ResourceGroupName <RESOURCE_GROUP_NAME> -AppSetting @{"AzureWebJobs.QueueTrigger.Disabled" = "false"}