I'm trying to get a full list of function endpoints in my Azure function app from a Powershell script. I can get the list of functions from the management.azure.com API, but it just has the function name, like...
/subscriptions/ea4a3766-c3a8-4b9c-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/MyFunctionAppName/functions/FunctionName
But the function actually has an endpoint of (for instance) http://myfunctionapp.azurewebsites.net/api/allsources/{sourceName}
How can I get that endpoint name from the Azure management API from Powershell? It's displayed in the "Get Function URL" button on the portal, so I would imagine it has to be there somewhere.
EDIT: The suggested duplicate still doesn't provide the actual function endpoint. For instance, I have a function called CheckLock. Its endpoint per the "Get Function URL" button on the portal (and the one that I want) is: https://myfunctionapp.azurewebsites.net/api/account/lock/{id}?code=myfunctioncode
What I'm getting from the suggested duplicate is:
@{
name=CheckLock;
function_app_id=/subscriptions/ea4a3766-c3a8-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Web/sites/myfunctionappname;
script_root_path_href=https://myfunctionappname.scm.azurewebsites.net/api/vfs/site/wwwroot/CheckLock/;
script_href=https://myfunctionappname.scm.azurewebsites.net/api/vfs/site/wwwroot/bin/Funcs.dll;
config_href=https://myfunctionappname.scm.azurewebsites.net/api/vfs/site/wwwroot/CheckLock/function.json;
secrets_file_href=https://myfunctionappname.scm.azurewebsites.net/api/vfs/data/functions/secrets/CheckLock.json;
href=https://myfunctionappname.scm.azurewebsites.net/api/functions/CheckLock;
config=;
files=;
test_data=
}
I got it. In the data for the function itself, the route is part of the properties.config object.
Request should look like this: https://management.azure.com/subscriptions/{subscriptionid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{functionAppName}/functions/{functionName}?api-version=2016-08-01
In the return value is a properties
object, and within that is config
object. Underneath that is the route
property which contains the trigger endpoint.
In Powershell, it's this:
$functionData = Invoke-RestMethod -Method Get -Uri $functionName -Headers $accessTokenHeader
$triggerUrl = "https://$functionAppName.azurewebsites.net/api/" + $functionData.properties.config.route
You can test it here: https://learn.microsoft.com/en-us/rest/api/appservice/webapps/getfunction
Hope this helps someone else! Thanks to those who contributed.