Skip to content

Commit 6e8d22f

Browse files
committed
Revert "Handle exceptions thrown during Key Vault reference resolution during startup (#518)"
This reverts commit 6ce60b9.
1 parent efb7742 commit 6e8d22f

File tree

2 files changed

+0
-84
lines changed

2 files changed

+0
-84
lines changed

src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationProvider.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -670,17 +670,6 @@ private async Task<bool> TryInitializeAsync(IEnumerable<ConfigurationClient> cli
670670

671671
throw;
672672
}
673-
catch (KeyVaultReferenceException exception)
674-
{
675-
if (IsFailOverable(exception))
676-
{
677-
startupExceptions.Add(exception);
678-
679-
return false;
680-
}
681-
682-
throw;
683-
}
684673
catch (AggregateException exception)
685674
{
686675
if (exception.InnerExceptions?.Any(e => e is OperationCanceledException) ?? false)
@@ -1031,15 +1020,6 @@ private async Task<T> ExecuteWithFailOverPolicyAsync<T>(
10311020
throw;
10321021
}
10331022
}
1034-
catch (KeyVaultReferenceException kvre)
1035-
{
1036-
if (!IsFailOverable(kvre) || !clientEnumerator.MoveNext())
1037-
{
1038-
backoffAllClients = true;
1039-
1040-
throw;
1041-
}
1042-
}
10431023
catch (AggregateException ae)
10441024
{
10451025
if (!IsFailOverable(ae) || !clientEnumerator.MoveNext())
@@ -1128,20 +1108,6 @@ innerException is SocketException ||
11281108
innerException is IOException;
11291109
}
11301110

1131-
private bool IsFailOverable(KeyVaultReferenceException kvre)
1132-
{
1133-
if (kvre.InnerException is RequestFailedException rfe && IsFailOverable(rfe))
1134-
{
1135-
return true;
1136-
}
1137-
else if (kvre.InnerException is AggregateException ae && IsFailOverable(ae))
1138-
{
1139-
return true;
1140-
}
1141-
1142-
return false;
1143-
}
1144-
11451111
private async Task<Dictionary<string, ConfigurationSetting>> MapConfigurationSettings(Dictionary<string, ConfigurationSetting> data)
11461112
{
11471113
Dictionary<string, ConfigurationSetting> mappedData = new Dictionary<string, ConfigurationSetting>(StringComparer.OrdinalIgnoreCase);

tests/Tests.AzureAppConfiguration/FailoverTests.cs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -332,55 +332,5 @@ public void FailOverTests_GetNoDynamicClient()
332332
// Only contains the client that passed while constructing the ConfigurationClientManager
333333
Assert.Single(clients);
334334
}
335-
336-
[Fact]
337-
public void FailOverTests_FailOverOnKeyVaultReferenceException()
338-
{
339-
// Arrange
340-
IConfigurationRefresher refresher = null;
341-
var mockResponse = new Mock<Response>();
342-
343-
var mockClient1 = new Mock<ConfigurationClient>();
344-
mockClient1.Setup(c => c.GetConfigurationSettingsAsync(It.IsAny<SettingSelector>(), It.IsAny<CancellationToken>()))
345-
.Throws(new KeyVaultReferenceException("Key vault reference failed.", new RequestFailedException(503, "Request failed.")));
346-
mockClient1.Setup(c => c.GetConfigurationSettingAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
347-
.Throws(new KeyVaultReferenceException("Key vault reference failed.", new RequestFailedException(503, "Request failed.")));
348-
mockClient1.Setup(c => c.GetConfigurationSettingAsync(It.IsAny<ConfigurationSetting>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()))
349-
.Throws(new KeyVaultReferenceException("Key vault reference failed.", new RequestFailedException(503, "Request failed.")));
350-
mockClient1.Setup(c => c.Equals(mockClient1)).Returns(true);
351-
352-
var mockClient2 = new Mock<ConfigurationClient>();
353-
mockClient2.Setup(c => c.GetConfigurationSettingsAsync(It.IsAny<SettingSelector>(), It.IsAny<CancellationToken>()))
354-
.Returns(new MockAsyncPageable(Enumerable.Empty<ConfigurationSetting>().ToList()));
355-
mockClient2.Setup(c => c.GetConfigurationSettingAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
356-
.Returns(Task.FromResult(Response.FromValue<ConfigurationSetting>(kv, mockResponse.Object)));
357-
mockClient2.Setup(c => c.GetConfigurationSettingAsync(It.IsAny<ConfigurationSetting>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()))
358-
.Returns(Task.FromResult(Response.FromValue<ConfigurationSetting>(kv, mockResponse.Object)));
359-
mockClient2.Setup(c => c.Equals(mockClient2)).Returns(true);
360-
361-
ConfigurationClientWrapper cw1 = new ConfigurationClientWrapper(TestHelpers.PrimaryConfigStoreEndpoint, mockClient1.Object);
362-
ConfigurationClientWrapper cw2 = new ConfigurationClientWrapper(TestHelpers.SecondaryConfigStoreEndpoint, mockClient2.Object);
363-
364-
var clientList = new List<ConfigurationClientWrapper>() { cw1, cw2 };
365-
var configClientManager = new ConfigurationClientManager(clientList);
366-
367-
var config = new ConfigurationBuilder()
368-
.AddAzureAppConfiguration(options =>
369-
{
370-
options.ClientManager = configClientManager;
371-
options.Select("TestKey*");
372-
options.ConfigureRefresh(refreshOptions =>
373-
{
374-
refreshOptions.Register("TestKey1", "label")
375-
.SetCacheExpiration(TimeSpan.FromSeconds(1));
376-
});
377-
378-
refresher = options.GetRefresher();
379-
})
380-
.Build();
381-
382-
// The build should be successful since one client was backed off and it failed over to the second client.
383-
Assert.Equal("TestValue1", config["TestKey1"]);
384-
}
385335
}
386336
}

0 commit comments

Comments
 (0)