Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all the functions in an Azure Function App

I can use the PowerShell cmdlet Get-AzureRMResource to list all Azure resources.

Is there a cmdlet that takes a ResourceGroupName and a SiteName and it returns all the functions in that "Site".

Or, a combination of cmdlets that I can use to get these details.

like image 342
Doug Finke Avatar asked Jul 14 '17 18:07

Doug Finke


People also ask

How do I get function app logs?

To view streaming logs in the portal, select the Platform features tab in your function app. Then, under Monitoring, choose Log streaming. This connects your app to the log streaming service and application logs are displayed in the window.


4 Answers

As Fabio Cavalcante said, Azure PowerShell does not support this, you could use Rest API to get it. Here is a example how to get Functions with 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

enter image description here

like image 98
Shui shengbao Avatar answered Oct 10 '22 06:10

Shui shengbao


This is possible using the Get-AzureRmResource cmdlet.

$Params = @{
    ResourceGroupName = $ResourceGroupName
    ResourceType      = 'Microsoft.Web/sites/functions'
    ResourceName      = $AppName
    ApiVersion        = '2015-08-01'
}
Get-AzureRmResource @Params
like image 43
markekraus Avatar answered Oct 10 '22 08:10

markekraus


Not a PowerShell cmdlet, but you can use the ListingFunctions API as described here

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

Response:
{
  "value": [
    {
      ...
    }
  ]
}
like image 28
Fabio Cavalcante Avatar answered Oct 10 '22 06:10

Fabio Cavalcante


In 2021, you can use func

func azure functionapp list-functions FUNCTION_NAME

available in azure-functions-core-tools@3

like image 3
freedev Avatar answered Oct 10 '22 08:10

freedev