Reputation: 982
After spending Hours of Research I am nothing more than absolutely confused. There was so much Change ongoing all around azure functions and azure logic apps and graph and authentication stuff around azure ad so it is really hard to finde the Right Resources.
What i want to achieve is quite simple:
Expect the step number 2 everything is already working. Unfortunately no Default connector provides any action to read more details about meeting requests and no connector action is there to decline meeting requests. So the obvious way is to go with an azure function and do the stuff with Microsoft Graph API.
So the point where I always fail is: How to get a correct Auth token in the azure function to Access Microsoft graph?
Since the logic app is executed non interactively i can not do any interactive login and i do not want to hardcode any credentials in the Code.
Upvotes: 0
Views: 242
Reputation: 20127
1.Open MSI in function app
In your function app , navigate to Platform features
, select Identity
and switch Status
to On
. Click Save
.
2.Permissions and Roles for the Managed Service Identity
Give Service Principal permission to get some Directory data like user information from my Azure AD. The following Azure AD commands adds my service principal to the AD Directory Role Directory Readers
:
3.Get token
As you have turn on MSI in Azure function, you could go to https://***.scm.azurewebsites.net
and click Environment and get the MSI_SECRET
public static async Task<HttpResponseMessage> GetToken(string resource, string apiversion) {
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Secret", Environment.GetEnvironmentVariable("MSI_SECRET"));
return await client.GetAsync(String.Format("{0}/?resource={1}&api-version={2}", Environment.GetEnvironmentVariable("MSI_ENDPOINT"), resource, apiversion));
}
For more details, you could refer to this article and this one.
Upvotes: 2