Azure App Config Caching

Rajarajacholan Krishnamurthy 21 Reputation points
2022-08-26T10:43:27.3+00:00

With Azure App Config how can I ensure to read only once a day from a key? I tried:
config.AddAzureAppConfiguration(options =>
{
options.Connect(azAppConfigConnection)
.Select("dbConnectionString", "Production");

                options.ConfigureRefresh(refresh =>  
                {  
                    // Register for refresh operation.  
                    refresh.Register("dbConnectionString", "Production").SetCacheExpiration(TimeSpan.FromSeconds(86400));  
                });  
                refresher = options.GetRefresher();  
            });  

The above snippet to read only once a day, but it still keeps on reading for every request. I am not sure of what I am missing. Any help would be much appreciated.

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
214 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sreeju Nair 12,181 Reputation points
    2022-08-26T11:12:54.88+00:00

    Can you try chaining the Configure Refresh with the Select. For e.g.

    options.Connect(azAppConfigConnection)
    .Select("dbConnectionString", "Production").ConfigureRefresh(refresh =>........
    ........

    0 comments No comments

  2. MughundhanRaveendran-MSFT 12,446 Reputation points
    2022-08-30T07:32:57.983+00:00

    Hi @Rajarajacholan Krishnamurthy ,

    Thanks for reaching out to Q&A forum.

    Configuration builder and AddAzureAppConfiguration should be called at the start of the application. This makes sure that it is called only once. If the application builds configuration instances multiple times along the way, it will send requests to Azure AppConfiguration each time.

    0 comments No comments