Hi thanks for the question . There's a few walkthroughs, one of which is here. Now, this is not exactly what you asked for as the author is using an automation run book (to exec script) and you want to use a function (to exec code)
But the principals (no pun intended ;) ) are the same.
In the authors example they add the "directory readers" role to the service principal used by their automation account. But you could look for a lesser privileged role. The steps would be the same.
In your case the easiest thing for you would be to
(1) Enable the Managed Identity for your function app - in the portal go to the function app, under "settings" choose the "identity" menu item. Under the "system assigned" tab enable the managed identity. It takes a few seconds. Make a note of the principal "object Id" (guid)
(2) from here-in you can follow the same steps as the author
Go to active directory in the Az portal. Select the "roles and administrators" menu item. Search for "directory readers" role (or the role you choose). Click on assignments and "add assignment" (note you do the right level of privilege yourself, in your AAD tenant to do this) . In the "search box" that comes up when you add an assignment paste the guid from step one (the MSI principal id from the function). You should also be able to search via the function app name. Finally, click "add".
This should be enough for your function app MSI and therefore the code executed within the functions you deploy to the app, to read the AAD app registrations data
Note: I didnt actually try this as an end to end demo (I have done similar in the past with a function but not recently) so let me know if you get stuck. Remember that your function app code will need to auth. You didnt say which language you're using but usually the smoothest way is to use Azure.Identity package and "DefaultAzureCredential". Example here.