Getting the environment tag using Machine Names Map - eaardal/konfiggy GitHub Wiki

This method resolves the environment tag by using a pre-defined dictionary of machine/server names and environment tags.

In your start-up logic, set Konfiggy's EnvironmentTagStrategy property to the MachineNameTagStrategy implementation.

You must supply a dictionary containing the names of all the machines/servers the app will be running in as the keys and the environment tag for each given server as the value.

var machineNamesMap = new Dictionary<string, string>
            {
                {"my-dev-computer", "local"},
                {"company-server-1", "dev"},
                {"company-server-2", "qa"},
                {"company-server-3", "prod"},
            };
IKonfiggy konfiggy = new Konfiggy();
konfiggy.EnvironmentTagStrategy = new MachineNameTagStrategy(machineNamesMap);

The machine names is not case sensitive.

Konfiggy will look at the System.Environment.MachineName to find the current machine it's running on and resolve the environment tag by matching that name to the first matching key it finds in the dictionary.