Skip to content

Commit

Permalink
Revert "Cache TokenCredential (#2845)"
Browse files Browse the repository at this point in the history
This reverts commit 68d8ec9.
  • Loading branch information
bachuv committed Jul 17, 2024
1 parent c88b62c commit b1db0f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Concurrent;
using DurableTask.AzureStorage;
using Microsoft.Azure.WebJobs.Extensions.DurableTask.Options;
using Microsoft.Extensions.Configuration;

#if !FUNCTIONS_V1
using Microsoft.Azure.WebJobs.Extensions.DurableTask.Auth;
using Microsoft.WindowsAzure.Storage.Auth;
Expand All @@ -21,9 +19,6 @@ internal sealed class AzureStorageAccountProvider : IStorageAccountProvider
#if !FUNCTIONS_V1
private readonly ITokenCredentialFactory credentialFactory;

private readonly ConcurrentDictionary<string, TokenCredential> cachedTokenCredentials =
new ConcurrentDictionary<string, TokenCredential>();

public AzureStorageAccountProvider(IConnectionInfoResolver connectionInfoResolver, ITokenCredentialFactory credentialFactory)
{
this.connectionInfoResolver = connectionInfoResolver ?? throw new ArgumentNullException(nameof(connectionInfoResolver));
Expand All @@ -49,9 +44,7 @@ public StorageAccountDetails GetStorageAccountDetails(string connectionName)
AzureStorageAccountOptions account = connectionInfo.Get<AzureStorageAccountOptions>();
if (account != null)
{
TokenCredential credential = this.cachedTokenCredentials.GetOrAdd(
connectionName,
attr => this.credentialFactory.Create(connectionInfo));
TokenCredential credential = this.credentialFactory.Create(connectionInfo);

return new StorageAccountDetails
{
Expand Down
10 changes: 5 additions & 5 deletions test/Common/AzureStorageAccountProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public void GetStorageAccountDetails_ConfigSection_Endpoints()
Assert.Equal(options.TableServiceUri, actual.TableServiceUri);

// Get CloudStorageAccount
CloudStorageAccount account = actual.ToCloudStorageAccount();
Assert.Same(actual.StorageCredentials, account.Credentials);
Assert.Equal(options.BlobServiceUri, account.BlobEndpoint);
Assert.Equal(options.QueueServiceUri, account.QueueEndpoint);
Assert.Equal(options.TableServiceUri, account.TableEndpoint);
CloudStorageAccount acount = actual.ToCloudStorageAccount();
Assert.Same(actual.StorageCredentials, acount.Credentials);
Assert.Equal(options.BlobServiceUri, acount.BlobEndpoint);
Assert.Equal(options.QueueServiceUri, acount.QueueEndpoint);
Assert.Equal(options.TableServiceUri, acount.TableEndpoint);
}

[Fact]
Expand Down

0 comments on commit b1db0f5

Please sign in to comment.