question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Azure.Identity.AuthenticationFailedException : AzurePowerShellCredential authentication failed: String '14-7-2021 06:36:10 +00:00' was not recognized as a valid DateTime

See original GitHub issue

Describe the bug I’m running some integration tests on Azure Pipelines, it was working fine until 13 of July (code was released at the beginning of July). These tests connect to an azure subscription to get some values from an Azure KeyVault. I don’t send any datetime and I didn’t see any way to send a date or a specific format. The issue happens running the tests in the pipeline but it doesn’t happen running the tests on a local machine.

I ran a Get-Culture command and the value is: LCID Name DisplayName

1043 nl-NL Dutch (Netherlands)

Expected behavior Connect to key vault and retrieve the secrets.

Actual behavior (include Exception or Stack Trace) From day 1 to day 12 of a month pipeline can connect to Azure keyvault and gets the secrets stored, from day 13 to 31 of a month pipelines throws and exception because the format of the date is dd-MM-yyyy.

Error Message: Azure.Identity.AuthenticationFailedException : AzurePowerShellCredential authentication failed: String ‘14-7-2021 06:36:10 +00:00’ was not recognized as a valid DateTime. ---- System.FormatException : String ‘14-7-2021 06:36:10 +00:00’ was not recognized as a valid DateTime. Stack Trace: at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex) at Azure.Identity.AzurePowerShellCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken) at Azure.Identity.AzurePowerShellCredential.GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken) at Azure.Identity.DefaultAzureCredential.GetTokenFromSourcesAsync(TokenCredential[] sources, TokenRequestContext requestContext, Boolean async, CancellationToken cancellationToken) at Azure.Identity.DefaultAzureCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken) at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex) at Azure.Identity.DefaultAzureCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken) at Azure.Identity.DefaultAzureCredential.GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AccessTokenCache.GetHeaderValueFromCredentialAsync(TokenRequestContext context, Boolean async, CancellationToken cancellationToken) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AccessTokenCache.GetHeaderValueAsync(HttpMessage message, TokenRequestContext context, Boolean async) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AccessTokenCache.GetHeaderValueAsync(HttpMessage message, TokenRequestContext context, Boolean async) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AuthenticateAndAuthorizeRequestAsync(HttpMessage message, TokenRequestContext context) at Azure.Security.KeyVault.ChallengeBasedAuthenticationPolicy.AuthorizeRequestOnChallengeAsyncInternal(HttpMessage message, Boolean async) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory1 pipeline, Boolean async) at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory1 pipeline, Boolean async) at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory1 pipeline, Boolean async) at Azure.Core.Pipeline.HttpPipeline.SendRequestAsync(Request request, CancellationToken cancellationToken) at Azure.Security.KeyVault.KeyVaultPipeline.SendRequestAsync(Request request, CancellationToken cancellationToken) at Azure.Security.KeyVault.KeyVaultPipeline.GetPageAsync[T](Uri firstPageUri, String nextLink, Func1 itemFactory, String operationName, CancellationToken cancellationToken) at Azure.Core.PageResponseEnumerator.FuncAsyncPageable1.AsPages(String continuationToken, Nullable1 pageSizeHint) at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore1.GetResult(Int16 token) at Azure.AsyncPageable1.GetAsyncEnumerator(CancellationToken cancellationToken) at Azure.AsyncPageable1.GetAsyncEnumerator(CancellationToken cancellationToken) at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore1.GetResult(Int16 token) at Azure.Extensions.AspNetCore.Configuration.Secrets.AzureKeyVaultConfigurationProvider.LoadAsync() at Azure.Extensions.AspNetCore.Configuration.Secrets.AzureKeyVaultConfigurationProvider.LoadAsync() at Azure.Extensions.AspNetCore.Configuration.Secrets.AzureKeyVaultConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot…ctor(IList`1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()

To Reproduce Configuration :

            var configBuilder = new ConfigurationBuilder()
                .AddJsonFile("testsettings.json", true)
                .AddEnvironmentVariables();

            var builtConfig = configBuilder.Build();

            Configuration = configBuilder
                .AddAzureKeyVault(new Uri(builtConfig["key_vault_azure_uri"]), new DefaultAzureCredential())
                .Build();

To get a secret: var secret= Configuration["secret_key"]

Environment:

  • The project is on Net Core 2.2
  • Azure.Identity 1.4.0, Azure.Security.KeyVault.Secrets 4.2.0,
  • Pipelines run in a hosted agent with Windows Server 2019
  • Visual Studio PRO 2019 16.8.1.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dcanamarescommented, Oct 13, 2021

@brwilkinson No, It was merged in 1.5.0 beta 3 or beta 4.

0reactions
JohnGalt1717commented, Oct 25, 2021

@christothes well the #1 issue you guys have is that there are about a billion libraries all getting maintained for everything Azure and you don’t even note in the nuget release what their status is. So there’s that.

But by using culture in your stuff you’re making all Docker-based (and thus K8s) use massively more memory and storage for no reason. I’d strongly advise that you fix your libraries and eliminate the need for culture references. Specifically, in Azure.Identity, culture should be irrelevant as you should be returning UTC and ICT dates and times, not things that are culture specific.

This use of culture in these is harming .NET’s adoption specifically because you’re making it bloat for no reason on Docker and K8s which is the defacto standard at this point for any serious, scaling system.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure storage is requiring Cultures to be installed instead ...
[BUG] Azure.Identity.AuthenticationFailedException : AzurePowerShellCredential authentication failed: String '14-7-2021 06:36:10 +00:00' was ...
Read more >
not able to fetch token using DefaultAzureCredential and ...
I am using Azure.Identity 1.7 and using VS 2022 , trying to get the token using DefaultAzureCredential, var tokenCredential = new ...
Read more >
Azure.Identity.AuthenticationFailedException: - Microsoft Q&A
The error message implies that the authentication failed. Did you sign in into the Visual Studio code using the same Azure credentials that...
Read more >
Azure.Identity.AuthenticationFailedException: ' ...
When calling the Graph SDK, the following error was thrown: Azure.Identity.AuthenticationFailedException: 'OnBehalfOfCredential authentication ...
Read more >
Azure.Identity.CredentialUnavailableException: ...
Looking at my stdout logs I get the following exception everytime. Azure.Identity.CredentialUnavailableException: DefaultAzureCredential failed ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found