'Azure app configuration throws exception & does not load the configuration when a disabled key vault secret is present as KV reference

I have an Azure app configuration with 2 keys. Both have key vault references as values. When one of the key-vault secrets is disabled for some reason (because expiration date has passed, not needed for now etc.,), entire configuration loading fails with KeyVault reference exception. I tried using SetSecretResolver, but it looks like if the registered KV client encounters any exception, secret resolver fallback will not be called. Is there any solution for this issue? Basically, I don't want to stop loading the config, if any or some of the KV secrets are disabled. BTW, I tried setting the "Options: true" to suppress the exception throwing, but that did not load the config.

app config Keys:-

abc:def:key1 - has a valid key vault secret
abc:def:key2 - has a disabled key vault secret.

code:-

public IConfiguration AzureAppConfig { get; set; }
public IConfigurationRefresher AzureAppConfigRefresher { get; set; }

builder.AddAzureAppConfiguration(options =>
                {
                    options.Connect(new Uri("uri"), credential)
                        .Select("abc:def:*")
                        .ConfigureKeyVault(kvOptions =>
                        {
                            kvOptions.SetCredential(credential);
                        })
                    .ConfigureRefresh(refresh =>
                    {
                        refresh.Register("abc:def:key1")
                            .SetCacheExpiration(TimeSpan.FromMinutes(30));
                    });
                    AzureAppConfigRefresher = options.GetRefresher();
                });

AzureAppConfig = builder.Build();

Thanks in advance for any help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source