An Azure service that provides an event-driven serverless compute platform.
How to Instantiate GraphServiceClient inside an azure function?
Hello,
I am trying to create an azure function which uses graph api to get the authenticated user's profile from azure ad.
I was able to add authentication of microsoft in the azure function app, but now when I try to create GraphServiceClient, all the resources on the internet, are not working in my case. Maybe it is due to the recent update of Microsoft Graph.
I have tried following ways,
//Method 1
var confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(Constants.AppId)
.WithTenantId(Constants.TenantId)
.WithClientSecret(Constants.ClientSecret)
.Build();
ClientCredentialProvider clientCredentialProvider = new ClientCredentialProvider(confidentialClientApplication);
GraphServiceClient _client = new GraphServiceClient(clientCredentialProvider);
//Method2
ClientSecretCredential clientSecretCredential = new ClientSecretCredential(Constants.TenantId, Constants.AppId, Constants.ClientSecret);
GraphServiceClient _client = new GraphServiceClient(clientSecretCredential, Constants.scope); ;
Even the microsoft's documentation suggests the second method, which is not working. By not working I mean, it is not even compiling, there is no such constructor in GraphServiceClient.
Kindly, suggest what should I do?
Azure Functions
Microsoft Security | Microsoft Entra | Microsoft Entra ID
A cloud-based identity and access management service for securing user authentication and resource access
Microsoft Security | Microsoft Graph
An API that connects multiple Microsoft services, enabling data access and automation across platforms
1 answer
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
7 deleted comments
Comments have been turned off. Learn more