Search code examples
.netazureasp.net-core.net-coreazure-app-configuration

updated values of Azure app configuration are not reflecting in AppSettings IMMEDIATELY


I have created a .net webapi app and using azure app configuration and setup auto-refresh with a sentinel key with cache expiration of 5 seconds

  • let's say i have a key "demokey" with value 1
  • I hit request and find 1 in new AppSettings().demoKey = 1
  • then I updated demokey = 2 and in app configuration and also updated the sentinel key to get new changes
  • after updating the value of demokey, I hit first request after 5 seconds
  • but it gives me 1 (the old value)
  • then completes the request lifecycle
  • then it looks for sentinel key changes
  • reloads the values and set new AppSettings().demoKey = 2
  • after that, I hit a second request, then I get demokey = 2 in my code

I am expecting to get the updated value of demokey (2 in this case) in the first request itself that I hit immediately after updating the value on azure app config

Expected behaviour:

  • let's say i have a key "demokey" with value 1
  • I hit request and find 1 in new AppSettings().demoKey = 1
  • then I updated demokey = 2 and in app configuration and also updated the sentinel key to get new changes
  • after updating the value of demokey, I hit first request after 5 seconds
  • it should first looks for sentinel key changes
  • should reload the values and set new AppSettings().demoKey = 2
  • and it should give me 2 (the new value)
  • then completes the request lifecycle

Solution

  • The behavior observed is by design. Please see discussions in the document Request-driven configuration refresh.

    The configuration refresh happens asynchronously to the processing of your app's incoming requests. It will not block or slow down the incoming request that triggered the refresh. The request that triggered the refresh may not get the updated configuration values, but later requests will get new configuration values.