Max
Max

Reputation: 1548

Azure App Configuration - Disable Refresh - SetCacheExpiration

I am using Azure App Configuration for loading config into my Azure Functions. https://learn.microsoft.com/en-us/dotnet/api/overview/azure/data.appconfiguration-readme?view=azure-dotnet-preview

I am using a free plan, and I ran into request throttled issue because of the default 30 seconds cache expiration. [at least I believe so]

To prevent this I used SetCacheExpiration as follow,

 builder.AddAzureAppConfiguration(options =>
            {
                options.Connect(this.Values.AppConfigConnectionString)
                    .ConfigureRefresh(refresh =>
                    {
                        // default is 30 seconds
                        refresh.SetCacheExpiration(TimeSpan.FromDays(10));
                    });
                options.Select(keyFilter: KeyFilter.Any, labelFilter: this.Values.Env);
            });

I do not need to refresh this key-value, because it's not going to change frequently. So my question is, is it possible to disable this cache expiration?

If so, how? If not, what should be the workaround?

TIA, Kiran.

Upvotes: 0

Views: 1572

Answers (2)

J. Campbell
J. Campbell

Reputation: 730

As long as you are not calling RefreshAsync anywhere this should not matter. If you are not calling RefreshAsync then there must be another reason the limit was hit. My guess would be that multiple configuration builders are being built.

Upvotes: 1

Krzysztof Madej
Krzysztof Madej

Reputation: 40909

You can try to use Infinite Timespan:

public static readonly TimeSpan InfiniteTimeSpan = new TimeSpan(0, 0, 0, 0, Timeout.Infinite);

Taken from this question Timeout.InfiniteTimespan in .Net 4.0?.

Upvotes: 1

Related Questions