Best practices for deployment from dev to stage to production

Discussion in 'ASP General' started by dasomerville, Oct 19, 2006.

  1. dasomerville

    dasomerville Guest

    We have different settings for our development, stage and production
    environments. For example, our development environment connection strings
    point to development database instances, stage connection strings point to
    stage database instances and so forth.

    Without having to maintain separate web.config files, what are the various
    approaches to having environment-specific settings?
     
    dasomerville, Oct 19, 2006
    #1
    1. Advertising

  2. dasomerville

    Uli Guest

    Hi,

    here is the way I'm doing it.

    Set a machine identity in the machine.config that says if it is a
    development, stage or production server (e.g. d, s or p. It might be good to
    add an "l" for local also).

    for the Development-server
    <add key="ApplEnv-l" value="d" />


    Then you can put the connection strings for all environments into the
    web.config

    <add key="ConnectionString-l" value="server=(local);......."/>
    <add key="ConnectionString-d" value="server=DEV-Server;......"/>
    <add key="ConnectionString-s" value="server=STG_Server;....."/>
    <add key="ConnectionString-p" value="server=PRD-Server;....."/>

    In your code put something like:

    private static string DbConnectionString
    {
    get
    {
    string strApplEnv = ConfigurationSettings.AppSettings["ApplEnv"];
    string paramSuffix = strApplEnv.ToLower().Substring(0,1);
    return ConfigurationSettings.AppSettings["ConnectionString-" +
    paramSuffix] ;
    }


    This way you can use the web.config for all environments.

    Regards,
    Uli
    --
    Wer nicht fragt, stirbt dumm.
    If you don''t ask, you'll die as a dumba**.


    "dasomerville" wrote:

    > We have different settings for our development, stage and production
    > environments. For example, our development environment connection strings
    > point to development database instances, stage connection strings point to
    > stage database instances and so forth.
    >
    > Without having to maintain separate web.config files, what are the various
    > approaches to having environment-specific settings?
     
    Uli, Oct 28, 2006
    #2
    1. Advertising

  3. dasomerville

    Uli Guest

    sorry, it has to be:

    <add key="ApplEnv" value="d" />
    and not
    <add key="ApplEnv-l" value="d" />


    --
    Wer nicht fragt, stirbt dumm.
    If you don''''''''t ask, you''''''''ll die as a dumba**.


    "Uli" wrote:

    > Hi,
    >
    > here is the way I'm doing it.
    >
    > Set a machine identity in the machine.config that says if it is a
    > development, stage or production server (e.g. d, s or p. It might be good to
    > add an "l" for local also).
    >
    > for the Development-server
    > <add key="ApplEnv-l" value="d" />
    >
    >
    > Then you can put the connection strings for all environments into the
    > web.config
    >
    > <add key="ConnectionString-l" value="server=(local);......."/>
    > <add key="ConnectionString-d" value="server=DEV-Server;......"/>
    > <add key="ConnectionString-s" value="server=STG_Server;....."/>
    > <add key="ConnectionString-p" value="server=PRD-Server;....."/>
    >
    > In your code put something like:
    >
    > private static string DbConnectionString
    > {
    > get
    > {
    > string strApplEnv = ConfigurationSettings.AppSettings["ApplEnv"];
    > string paramSuffix = strApplEnv.ToLower().Substring(0,1);
    > return ConfigurationSettings.AppSettings["ConnectionString-" +
    > paramSuffix] ;
    > }
    >
    >
    > This way you can use the web.config for all environments.
    >
    > Regards,
    > Uli
    > --
    > Wer nicht fragt, stirbt dumm.
    > If you don''t ask, you'll die as a dumba**.
    >
    >
    > "dasomerville" wrote:
    >
    > > We have different settings for our development, stage and production
    > > environments. For example, our development environment connection strings
    > > point to development database instances, stage connection strings point to
    > > stage database instances and so forth.
    > >
    > > Without having to maintain separate web.config files, what are the various
    > > approaches to having environment-specific settings?
     
    Uli, Oct 28, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. karim
    Replies:
    0
    Views:
    488
    karim
    Jul 13, 2003
  2. =?Utf-8?B?c3N0ZXZlbnM=?=

    Deployment Best Practices

    =?Utf-8?B?c3N0ZXZlbnM=?=, Oct 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,055
    John Saunders
    Nov 2, 2004
  3. Brian Folke Seaberg

    Initialization -- One Stage or Two Stage

    Brian Folke Seaberg, Jan 4, 2005, in forum: C++
    Replies:
    4
    Views:
    745
    Howard
    Jan 4, 2005
  4. John Dalberg
    Replies:
    3
    Views:
    603
    samuelhon
    Nov 16, 2006
  5. Chicken McNuggets

    Best book on C gotchas and best practices?

    Chicken McNuggets, Jul 31, 2013, in forum: C Programming
    Replies:
    9
    Views:
    287
    Fred J. Tydeman
    Aug 5, 2013
Loading...

Share This Page