From b1db0f5de4bb5bb6333fe1f5ae8b3f1e15aa8580 Mon Sep 17 00:00:00 2001 From: Varshitha Bachu Date: Wed, 17 Jul 2024 11:14:48 -0700 Subject: [PATCH] Revert "Cache TokenCredential (#2845)" This reverts commit 68d8ec99df084f92f989479a308a953efd0cc0b1. --- .../AzureStorageAccountProvider.cs | 9 +-------- test/Common/AzureStorageAccountProviderTests.cs | 10 +++++----- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/WebJobs.Extensions.DurableTask/AzureStorageAccountProvider.cs b/src/WebJobs.Extensions.DurableTask/AzureStorageAccountProvider.cs index 7d42ec413..1e22e2716 100644 --- a/src/WebJobs.Extensions.DurableTask/AzureStorageAccountProvider.cs +++ b/src/WebJobs.Extensions.DurableTask/AzureStorageAccountProvider.cs @@ -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; @@ -21,9 +19,6 @@ internal sealed class AzureStorageAccountProvider : IStorageAccountProvider #if !FUNCTIONS_V1 private readonly ITokenCredentialFactory credentialFactory; - private readonly ConcurrentDictionary cachedTokenCredentials = - new ConcurrentDictionary(); - public AzureStorageAccountProvider(IConnectionInfoResolver connectionInfoResolver, ITokenCredentialFactory credentialFactory) { this.connectionInfoResolver = connectionInfoResolver ?? throw new ArgumentNullException(nameof(connectionInfoResolver)); @@ -49,9 +44,7 @@ public StorageAccountDetails GetStorageAccountDetails(string connectionName) AzureStorageAccountOptions account = connectionInfo.Get(); if (account != null) { - TokenCredential credential = this.cachedTokenCredentials.GetOrAdd( - connectionName, - attr => this.credentialFactory.Create(connectionInfo)); + TokenCredential credential = this.credentialFactory.Create(connectionInfo); return new StorageAccountDetails { diff --git a/test/Common/AzureStorageAccountProviderTests.cs b/test/Common/AzureStorageAccountProviderTests.cs index 886903f37..67774b2ec 100644 --- a/test/Common/AzureStorageAccountProviderTests.cs +++ b/test/Common/AzureStorageAccountProviderTests.cs @@ -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]