Home > OS >  is it possible to build a azure function which uses graph api call and can handle reliable authentif
is it possible to build a azure function which uses graph api call and can handle reliable authentif

Time:02-03

According to this post

How to use a token authentification from Graph API in Azure http trigger function as webhook

the azure function crashes on many triggers at same time and so if in the code the token (Graph API) is executed the token will be requested so many time there was thrown this exception.

2022-01-31T06:51:59Z [Information] AADSTS900023: Specified tenant identifier 'a1ae89fb-21b9-40bf-9d82-a10ae85a2407a1ae89fb-21b9-40bf-9d82-a10ae85a2407' is neither a valid DNS name, nor a valid external domain.

Trace ID: ebbb51ed-2ef1-4931-81b6-702833c93f00
Correlation ID: cb112afc-08bf-44bb-9a8e-b0a93938f6cb
Timestamp: 2022-01-31 06:51:55Z

at Microsoft.Identity.Client.Internal.Requests.RequestBase.HandleTokenRefreshError(MsalServiceException e, MsalAccessTokenCacheItem cachedAccessTokenItem)
at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.ExecuteAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.ApiConfig.Executors.ConfidentialClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenForClientParameters clientParameters, CancellationToken cancellationToken)
at Namespace1.Webhook.GetOnlyDesiredDataAfterFiltersAsync(String CallRecordId, AzFuncCallRecordsConfiguration config, ILogger log) in D:\Repos\Webhook.cs:line 518
at Namespace1.Webhook.Run(HttpRequest req, ExecutionContext context, ILogger log) in D:\Repos..\BWebhook.cs:line 180

So the question is now: Is it realizeable with azure functions because on statefull services it is possible to store the auth token to avoid requiring every time?

I hope this question will not be seen as a duplicate, but it is 2 different questions.

if no please write the possible failure causes why it is not possible.

CodePudding user response:

In .NET Azure Functions you can use static variables to hold data across executions. The variables will be specific to that instance and will be wiped if that instance is removed.

  •  Tags:  
  • Related