views:

97

answers:

3

I recently worked on an app in a very interesting environment. There was 6 or 7 parallel levels for this application and only the 1st 2 levels were able to be touched by developers. As part of the company policy all builds were done as Tivoli packages, and very complex to setup.

The final kicker was that no code changes are allowed past the 1st level or "Dev" servers so web.config contained multiple encrypted sections of environment variables. The application is built to sense what environment its on by path and variables set in IIS.

This is a beast to maintain so what is a simple or better architecture for this type of problem?

A: 

Have you tried using OpenExeConfiguration of the ConfigurationManager and explicitly load the proper configurations for the appropriate environments instead of just using the default web.config?

For more, check out OpenExeConfiguration on MSDN

Gyuri
A: 

You could include all configurations for all environments in the web config and prefix their keys with the machine name of the appropriate environment. Then, using Server.MachineName (or some other way to identify the server that the app is running on) you can access the right configuration.

<appSettings>
<add key="DEVMACHINENAME_baseURL" value="http://dev.foo.com" />
<add key="QAMACHINENAME_baseURL" value="http://qa.foo.com" />
</appSettings>

No one would have to go in and modify anything in the web.config since the application can look up information for itself.

sujata
That is how we are doing it now with a huge multi-section config, but the machine name is a new spin. We are load balanced in the upper env so that may not be an option.
Tj Kellie
+1  A: 

Hmm, (disclaimer: I'll talk about something I've written)

Your subject seems slightly different from the post, but I think I have an idea of what you mean. The tool I'm writing, dashy, lets you handle a single codebase, and lets you configure it for various enviroments. It doesn't, however, place security restrictions on these enviroments over the other. But, depending on your source control, and general system, it may be of interest. You should get a reasonable idea of the way it works from the picture on the homepage. Perhaps it's of interest, perhaps not, but it's what we use to manage deployment to different environments. It's a work in progress ("beta") at the moment, but the current version is suitable for testing.

Noon Silk
Hey I upvoted this just for the cool tool, dashy looks nice but we are locked into an ancient Tivoli build tool to push these up the foodchain, no MSbuild or other build tools are options. Its crazy, and it means that after the 1st build, it goes up all the way to prod unchanged.
Tj Kellie
Tj: Ah, fair enough. But do note, though, that you can use dashy with any build system. All dashy needs is an svn repo to commit into. Then, you get full benefit by moving your configuration *into* dashy (and it's just xml, so you can edit it easily if you wish). It lets you then maintain 'releases' in the repository, which lets you track things and so on. But cheers, it's still in dev, (though we're using it for live stuff at work, and I use it at home), so it doesn't fully support what you want (transitioning of releases; but that's something i've working on the last few days! :)
Noon Silk