Environment configuration, what I mean by this are your settings that allow your application to run in the different environments it needs to run in. Development, QA, Production etc...
This is an ever changing entity where I work. We use a custom Microsoft Enterprise Library implementation to store connection string and credentials. We use .Net config files for almost everything else. We also have some third party tools we use for configuring console applications with command line parameters.
I have come up with a very nice method that uses custom sections in the config such as below:
<Environment>
<add key="CurrentEnvironment" value="1"/> 1=local, 2=dev, 3=qa 4= prod
</Environment>
<local>
<keys....
</local>
<Dev>
<keys....
</Dev>
ETC.....
Then we setup a class with properties that allows you to pull from the custom sections or use the appSettings section for items that don't change between environments. We then define properties in the class that expose all of the keys in the config file and it is transparent when we use the properties whether they are environment specific or common.
At build time, in the build scripts we use, we create a new build for each environment and change the XML in the config file to set the CurentEnvironment for the correct build target. So far this has been working fine and we use built in .Net configuration methods to access config file values. This has proven more stable than using custom XML configuration files and cache objects.
Please feel free to leave comments or suggestions if you have better methods of configuring your applications for different environments.
No comments:
Post a Comment