[BUG] DefaultAzureCredential takes a long time to authenticate
See original GitHub issueLibrary name and version
Azure.Identity 1.5.0
Describe the bug
Using DefaultAzureCredential
for authentication takes a very long time in package version 1.5.0.
The following code snippet takes ~3.5 seconds to run with Azure.Identity v1.4.0, and ~12.5 seconds with Azure.Identity v1.5.0.
var cred = new DefaultAzureCredential();
var result = cred.GetTokenAsync(new TokenRequestContext(new string[] { "<ValidScope>" })).Result;
Expected behavior
DefaultAzureCredential should not take >12 seconds to load credentials.
Actual behavior
DefaultAzureCredential takes >12 seconds to load credentials.
Reproduction Steps
Create an ASP .NET Core app with Azure.Identity v1.5.0 dependency. Add the code snippet above and measure the time taken for GetTokenAsync
to complete.
I had VisualStudioCredentials configured for authentication. Directly using VisualStudioCredentials for auth has no delay.
Environment
Tried running on .net3.1, .net5 and .net6 - same behavior. Running in Visual Studio 2019.
dotnet --info: .NET SDK (reflecting any global.json): Version: 6.0.101 Commit: ef49f6213a
Runtime Environment: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.101\
Host (useful for support): Version: 6.0.1 Commit: 3a25a7f1cc
.NET SDKs installed: 3.0.103 [C:\Program Files\dotnet\sdk] 3.1.416 [C:\Program Files\dotnet\sdk] 5.0.210 [C:\Program Files\dotnet\sdk] 5.0.403 [C:\Program Files\dotnet\sdk] 5.0.404 [C:\Program Files\dotnet\sdk] 6.0.101 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Issue Analytics
- State:
- Created 2 years ago
- Comments:18 (6 by maintainers)
Top GitHub Comments
@christothes is there an update for this issue? Version 1.6.1 still has this problem.
Yes - we have been discussing solutions to this problem and may have a preview of the change soon. cc @schaabs