Doug Finke
Doug Finke

Reputation: 6823

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.

Upvotes: 7

Views: 11627

Answers (6)

stack247
stack247

Reputation: 5747

PowerShell to get all the Functions in all ResourceGroup. If only certain RG needed, this can be filtered by uncomment the code where RG filter is.

In my case, I'm looking for Azure Function v3, so I print out only the function V3, but you can filter the list or update the Functions however you want.

$subscriptionId = "some-guid-subscription"
Set-AzContext -SubscriptionId $subscriptionId
$apps = Get-AzFunctionApp -SubscriptionId $subscriptionId
Write-Output ("Checking subscription " + $subscriptionId)
foreach ($app in $apps) {
    # Filter RG here if needed
    #if ($app.ResourceGroupName -ne "a-resource-group") { continue }
    $appsetting = Get-AzFunctionAppSetting -Name $app.Name -ResourceGroupName $app.ResourceGroupName
    if ($appsetting.FUNCTIONS_EXTENSION_VERSION -eq "~3") {
        Write-Output ($app.Name + " in RG: " + $app.ResourceGroupName + " has version" + $appsetting.FUNCTIONS_EXTENSION_VERSION)
    }
}

Upvotes: 0

riks
riks

Reputation: 15

you can use below

Disable

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

Enable

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

Upvotes: 0

Fabio Cavalcante
Fabio Cavalcante

Reputation: 12538

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": [
    {
      ...
    }
  ]
}

Upvotes: 4

freedev
freedev

Reputation: 30197

In 2021, you can use func

func azure functionapp list-functions FUNCTION_NAME

available in azure-functions-core-tools@3

Upvotes: 7

markekraus
markekraus

Reputation: 51

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

Upvotes: 4

Shui shengbao
Shui shengbao

Reputation: 19223

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

Upvotes: 5

Related Questions