You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe the problem.
Recently I created through the SDK a batch request to receive the members and owners of a bunch of group ids. During testing, I noticed that adding all these requests to the batch takes a relatively long time.
After some digging into the code I found the root source to be the call to RequestAdapter.ConvertToNativeRequestAsync<HttpRequestMessage>() which will call AuthenticateRequestAsync() of the given authentication provider. This is not needed, cause the token on the individual request will be ignored and not being serialized into the batch step information.
Describe the solution you'd like.
To solve this issue I created an intermediate service client with my own do nothing authentication provider, used that to create the native request and added it via AddBatchRequestStep(). After doing so, the loop with 200 requests dropped from 300ms down to 1ms:
To make it easier to reproduce the problem, here is some sample code that shows how AddBatchRequestStepAsync() internally calls the authentication validator:
privateclassSlowAuthenticationProvider:IAuthenticationProvider{publicasyncTaskAuthenticateRequestAsync(RequestInformationrequest,Dictionary<string,object>?additionalAuthenticationContext=null,CancellationTokencancellationToken=default){Console.WriteLine("Trying to authenticate request...");awaitTask.Delay(100,cancellationToken);}}publicstaticasyncTaskMain(){varauthProvider=newSlowAuthenticationProvider();varserviceClient=newGraphServiceClient(authProvider);varbatch=newBatchRequestContentCollection(serviceClient);varmembersRequest=serviceClient.Groups["abc"].Members.ToGetRequestInformation();// Calls the authentication provider (can't be avoided IMHO)varnativeRequest=awaitserviceClient.RequestAdapter.ConvertToNativeRequestAsync<HttpRequestMessage>(membersRequest);batch.AddBatchRequestStep(newBatchRequestStep("abc|members",nativeRequest));// Calls the authentication provider (could be avoided IMHO)awaitbatch.AddBatchRequestStepAsync(membersRequest);}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe the problem.
Recently I created through the SDK a batch request to receive the members and owners of a bunch of group ids. During testing, I noticed that adding all these requests to the batch takes a relatively long time.
After some digging into the code I found the root source to be the call to
RequestAdapter.ConvertToNativeRequestAsync<HttpRequestMessage>()
which will callAuthenticateRequestAsync()
of the given authentication provider. This is not needed, cause the token on the individual request will be ignored and not being serialized into the batch step information.Describe the solution you'd like.
To solve this issue I created an intermediate service client with my own do nothing authentication provider, used that to create the native request and added it via
AddBatchRequestStep()
. After doing so, the loop with 200 requests dropped from 300ms down to 1ms:Additional context?
To make it easier to reproduce the problem, here is some sample code that shows how
AddBatchRequestStepAsync()
internally calls the authentication validator:The text was updated successfully, but these errors were encountered: