0
votes

I am trying to get azure function V2 key by using Powershell and Azure CLI, below is code. I am getting error:

Not Found({"error":{"code":"NotFound","message":"Error retrieving function keys."}})

It seems like it is not possible to get keys of Azure Function V2 without setting the AzureWebJobsSecretStorageType app setting to 'files'.

https://github.com/Azure/azure-functions-host/wiki/Changes-to-Key-Management-in-Functions-V2

The only helpful article I found is this:

https://markheath.net/post/managing-azure-functions-keys-2

According to https://github.com/Azure/azure-functions-host/issues/3994 it should work.

Am I missing something?


$webAppName = 'XXX'

$resourceGroup = 'YYY'

$subscriptionId = 'ZZZ'

$resourceId = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.Web/sites/$webAppName"

az rest --method post --uri "https://management.azure.com$resourceId/functions/$webAppName/listKeys?api-version=2018-02-01"

2
Did you try the official rest api.github.com/Azure/azure-functions-host/wiki/… - George Chen
as well as I understand in this case I need to deal with auth token, which I would like to avoid by using az rest - Maxim Khon

2 Answers

0
votes

I had incorrect uri format. From Microsoft support:

To retrieve the host keys execute the following command –

az rest --method post --uri "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.Web/sites/$webAppName/functions/$functionName/listKeys?api-version=2018-11-01"

To retrieve the specific function keys execute the following command –

az rest --method post --uri "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.Web/sites/$webAppName/host/default/listKeys?api-version=2018-11-01"

0
votes

Using the Az CLI

[1] Get the Function App keys:

az functionapp keys list -g $RESOURCE_GROUP -n $FUNCTION_APP_NAME

[2] Get the Function's keys:

az functionapp function keys list --function-name $FUNCTION_NAME -g $RESOURCE_GROUP -n $FUNCTION_APP_NAME