Does anyone know if you take a performance hit calling CloudConfigurationManager GetSetting method? Does it reparse the azure file for example or is it cached? Not sure if I should add my own caching/static variable to improve perf for something called often like a connection string.
Thanks
The source is available on github.
If you take a look at the source you can see that it isn't doing any caching, so if you are seeing performance issues you may want to implement your own caching.
The body of GetSetting
shows a simple return:
value = GetValue("ServiceRuntime", name, GetServiceRuntimeSetting);
if (value == null)
{
value = GetValue("ConfigurationManager", name, n => ConfigurationManager.AppSettings[n]);
}
return value;
The accepted answer might not be correct.
It's true that CloudConfigurationManager
itself does not cache, but that's because it internally delegates to ConfigurationManager
or WebConfigurationManager
, which do cache values.
From MSDN:
For
<appSettings>
and<connectionStrings>
, you use the AppSettings and ConnectionStrings properties. These methods perform read-only operations, use a single cached instance of the configuration, and are multithread aware.
So that even if you access from CloudConfigurationManager
directly, most probably, there would be no IO operation incurred.
No, it is not cached, as you suggested you would have to create you own caching for performance improvement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With