[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 issueDescribe 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, ReadOnlyMemory
1 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, Func
1 itemFactory, String operationName, CancellationToken cancellationToken)
at Azure.Core.PageResponseEnumerator.FuncAsyncPageable1.AsPages(String continuationToken, Nullable
1 pageSizeHint)
at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore1.GetResult(Int16 token) at Azure.AsyncPageable
1.GetAsyncEnumerator(CancellationToken cancellationToken)
at Azure.AsyncPageable1.GetAsyncEnumerator(CancellationToken cancellationToken) at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore
1.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:
- Created 2 years ago
- Comments:12 (4 by maintainers)
Top GitHub Comments
@brwilkinson No, It was merged in 1.5.0 beta 3 or beta 4.
@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.