简体   繁体   中英

Azure Cloud Service - different mapping per environment

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM