I’m trying to find a query to list total number of Azure functions within a subscription using Azure Resource Graph Explorer.
I’m only able to get the total number of Function Apps and not the underlying functions.
Is there a way using Graph query? Or is there a script which I can use?
Note: Only interested in Azure Functions not the Azure Function App.
2
Answers
I do not think this is possible through a Resource Graph Query. One possible approach would be to use Azure REST API subsequently to get the results. Here is a PowerShell example:
You need to generate a Bearer token in order to query the REST API. You could use a function like this to generate it.
There are a lot of other ways to get a token though. However, I will use this to retrieve it…
Then you would run your resource graph query in order to get all Function Apps across the tenant and in any subscription.
…and finally execute the REST API Calls for all the Function Apps that the query returned.
The
$functions.value
variable now holds all the different functions.I suggest using the REST API instead of standard PowerShell cmdlets because it is faster in large environments – it prevents you from having to switch between subscriptions when you have resources spread across various subscriptions.
After reproducing from my end, I could able to achieve your requirement using the PowerShell script. Below is the script that worked for me.
RESULTS:
Update
To get the count of number of functions in a function app, you can use
.count
.Update-2