I usually maintain my SQL connection strings in ServiceDefinition files. * .cscfg. Thus, you get an additional advantage in the ability to edit them when starting instances, which is great for VIP swaps.
If you are testing out of the emulator on development machines, it is quite simple to write an abstraction over config:
class AzureConfig : IConfig { public string GetConnectionString(string name) { get { return RoleEnvironment.GetConfigurationSettingsValue(name); } } } class OnPremConfig : IConfig { public string GetConnectionString(string name) { get { return ConfigurationManager.ConnectionStrings[name].ConnectionString; } } }
Then configure your IoC container to check RoleEnvironment.IsAvailable and return the appropriate type.
source share