Azure Cloud Service - different mapping per environment

114 Views Asked by At

I have a Cloud Service in Azure and I have multiple environments. One of my classes use a mapping (key-value mapping) for doing some calculations. The number of keys in that mapping varies depending on the environment.

I'm guessing I have no choice but to insert (somehow) the mapping to the environment's configuration (.cscfg file). Since the configuration is in XML format, I'm wondering what would be the cleanest and most extensible way for define the mapping for each of the environments.

Thanks


For example:

I have this ID to Region mapper:

private static readonly Dictionary<string, Region> Id = new Dictionary<string, Region>
{
    {"1", Region.UsE},
    {"2", Region.UsE},
    {"3", Region.UsE},
    {"4", Region.UsSC},
    {"5", Region.UsSC},
    {"6", Region.UsSC},
    {"7", Region.EuW},
    {"8", Region.EuN}
};

This mapping changes between environments and I would like somehow to elegantly set the mapping in the cscfg file of each environment.

Hope this better explains my question.

1

There are 1 best solutions below

2
On

You can add the values to the ConfigurationSettings element of the .CSCFG files for each environment. The values may then be read using the CloudConfigurationManager class.

You could also just have per-environment XML or JSON files.