0

Imagine a highly distributed system with same self-hosted WCF services on different machines. It's a pain to manage all App.Config files in a decentralized way.

I am sure there is a solution to load one Config section or a key value setting from some custom web-service, but I was not able to find a solution.

Andrey Ershov
  • 1,773
  • 1
  • 16
  • 26
  • Possible duplicate of [Relocating app.config file to a custom path](http://stackoverflow.com/questions/1838619/relocating-app-config-file-to-a-custom-path) – Panda Mar 22 '16 at 14:46
  • Not a duplicate, that question is about loading app.config from shared storage o locally – Andrey Ershov Mar 23 '16 at 12:15

1 Answers1

1

You can read the configurations from the section in your appConfig through

System.Configuration.ConfigurationManager.AppSettings.Get(key)

System.Configuration.ConfigurationManager has other configuration accessors, for example

ConfigurationManager.ConnectionStrings[name]

For documentation see https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k(System.Configuration.ConfigurationManager);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.5);k(DevLang-csharp)&rd=true

Wicher Visser
  • 1,513
  • 12
  • 21
  • But the point of the question is to get it from a web service, not from local App.config) – Andrey Ershov Mar 22 '16 at 15:32
  • You want to app.config file to come from a web.service? Or the configurations contained within (i..e loaded by the web.service and sent to the calling application)? – Wicher Visser Mar 22 '16 at 15:35
  • Ideally - parts of app.config come from some external source like webservice. – Andrey Ershov Mar 22 '16 at 17:26
  • 1
    Bootstrapping the config file is not advised. It is an application-level configuration, and a change to the file would make e.g. IIS restart the related website. You are better off extracting the relevant parts of the config by your dedicated service and forward those to services on the machines at which they are needed. – Wicher Visser Mar 23 '16 at 07:54
  • And how would've you advised to handle this scenario: repoint 3 services on 10 machines to different database and restart them? – Andrey Ershov Mar 23 '16 at 15:00
  • 1
    Maybe this helps? http://serverfault.com/questions/127409/iis-configuration-synchronization-for-web-server-farm – Wicher Visser Mar 23 '16 at 15:12
  • Sorry, I forgot to mention, that they are self-hosted :) Right now I am looking at systems like Salt, Ansible, Puppet, but I don't know if they are suited for this kind of task – Andrey Ershov Mar 23 '16 at 15:20