0

The new ASP.NET documentation under Fundamentals/Working with Multiple Environments it has a detailed description of how to handle multiple environments (surprise surprise) in code.

I was wondering if this is the "best practice" when dealing with multiple environments or should it be handled by something other than code like the tool that is doing the deployment for example?

2 Answers 2

1

At my workplace we have many test environments to manage, and we generally run a .NET stack for websites. We currently use Octopus Deploy which, for each environment, will configure applications at deploy time. Our apps are built and packaged up with replaceable variables which Octopus fills in on deployment.

Even if you don't use such a tool I would recommend configuration at deployment time. Your application that you package up (in your CI tool of choice) for deployment should be the same repeatable package that goes into dev, test and prod. We use Team City which builds our deployment packages, and another tool which is a package repository to store all the build artefacts.

Having code paths that are special for an environment potentially makes testing harder since your application is behaving differently.

1
  • We have a similar stack, using Octopus and Team City and we are currently on the path to replace variables with Octopus as you suggest above. The only thing that gives me pause is the idea that it would be clearer to keep all the test, staging, live (or insert environment names here) values in the same place.
    – RyanCosans
    Commented Mar 18, 2016 at 11:57
1
  1. Continuous integration which compiles all code as it checks in and runs unit tests.

  2. As in point 1 plus variant or parameterized builds. Build for windows server. Build for linux server. Etc.

  3. For internal components or shared assemblies one or multiple private nuget feeds may be desirable.

  4. A devops culture may be useful.

  5. A strategy for continuous deployment of systems composed of subcomponents often tagged as microservices may be useful for asp.net webapi services.

  6. Blue/green deployment may be useful. See http://martinfowler.com/bliki/BlueGreenDeployment.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.