The reason i need the permissions is to read a specific mailbox and send mail from that mailbox.
The only entity that would manage the mailbox is the Function App.
I have found articles from Microsoft directly and on MS Forums on how to do it, but for me it is difficult to understand the process.
The main article i have read:
https://learn.microsoft.com/en-us/graph/permissions-grant-via-msgraph?tabs=powershell&pivots=grant-application-permissions
In the MS Learn article it reads that i have to use powershell (or CLI) to run the needed commands.
For that i first have to log into MS Graph with the command: Connect-MgGraph.
This command needs specific scopes to operate properly.
For my needs i have found that the lowest privilige scope (and therefore role / permission) i can specify to successfully run these commands is:
AppRoleAssignment.ReadWrite.All, as per https://learn.microsoft.com/en-us/graph/permissions-reference#approleassignmentreadwriteall
The problem with that is, that then i have to give MS Graph full authority over my tenant with the specified permissions.
I do not want to do that if possible, for that is a scope with priviliges which are too high in my opinion.
My question to this part is:
Is there any other scope i can log in with, that would let me run the commands but give the fewest permissions (no admin / highly priviliged permissions) to MS Graph?
If there are no such roles, then i have another question.
I have read that the Connect-MgGraph command only gives access AND recieves acces to the specified scopes for the duration of the SESSION!
https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/connect-mggraph?view=graph-powershell-1.0#example-1-delegated-access-using-interactive-authentication-where-you-provide-the-scopes-that-you-require-during-your-session
Does that mean that after i use the command Disconnect-MgGraph, MS Graph will automatically lose the permissions i have consented to in my tenant?
If not how can i remove them after i am done with the role assingments?
As a last question, what would be the best practice for cases like this?
NOTE: Assignment at App Role is not an option. Using Azure Logic Apps is not an option.