Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigurationManager GetConfigurationAsync is often slow #2600

Open
jsweiler opened this issue May 17, 2024 · 3 comments
Open

ConfigurationManager GetConfigurationAsync is often slow #2600

jsweiler opened this issue May 17, 2024 · 3 comments

Comments

@jsweiler
Copy link

Which version of Microsoft.IdentityModel are you using?
Note that to get help, you need to run the latest version.
Microsoft.IdentityModel.Protocols 7.5.2

Where is the issue?

  • [x ] M.IM.Protocols.OpenIdConnect

Is this a new or an existing app?
This is a new app or an experiment.

Repro

var wellKnownUri = "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration";
var configurationManager = new ConfigurationManager<OpenIdConnectConfiguration>(
    wellKnownUri, new OpenIdConnectConfigurationRetriever());
var openIdConfig = await configurationManager.GetConfigurationAsync();

Expected behavior
I would expect the call to GetConfigurationAsync() to be very fast.

Actual behavior
The call to GetConfigurationAsync() often takes 500ms or greater.

Additional context / logs / screenshots / links to code
As this code is handling a large amount of requests from Microsoft Graph presence updates we need to be able to quickly process notifications and this one call is too slow. Part of processing the notification is validating the token that comes along with the request. This code is running in an Azure Linux Function App running on .net 8 isolated mode. I notice the issue in Azure or as well running locally from my machine with Visual Studio. I notice it hits https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration and https://login.microsoftonline.com/common/discovery/v2.0/keys and I can see with Fiddler that those endpoints return very quickly (less than 5 milliseconds each).

When I first started this app I was using version 7.2.0 of the package and upgraded to 7.5.2 and the performance was a little better but there still are cases of it being slow.

@jmprieur
Copy link
Contributor

Are you sure you aren't using a sync over async pattern?

@jsweiler
Copy link
Author

I don't believe I am. My entry point which is the Azure Function returns a Task<HttpResponseData> and the method I am calling GetConfigurationAsync from returns Task<bool>. (My function calls a method to check if the token is valid and the GetConfigurationAsync is called from that method)

@keegan-caruso
Copy link
Contributor

@jsweiler Do you have any profile data by any chance? It would be very helpful to know where the time is being spent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants