If I am moving config settings from my Web.config to Aazure ServiceConfiguration.cscfg, Do I need to make any code changes
For Example my I have the below mentioned entries in my Web.config
<ConfigurationSettings>
<Setting name="webConfigHostName" value="Test.AzureTest" />
</ConfigurationSettings>
To read the above entry,I use
string myHostName=MyEnvironmentWrapper.GetConfigurationSettingValue("webConfigHostName");
Now I want to move my web application to Azure Cloud Environment
So I am planning to move the above web.config entries to my ServiceConfiguration.csfg After this do I need to make any code changes so that my application can read "webConfigHostName" directly from my ServiceConfiguration.csfg
I'm afraid (in the old days, see below) you did:
if (RoleEnvironment.IsAvailable)
{
return RoleEnvironment.GetConfigurationSettingValue("mySetting");
}
else
{
return ConfigurationManager.AppSettings["mySetting"].ToString();
// or whatever your configuration system requires
}
There are some great posts on this here and here.
We ended up writing our own wrapper around this to make our application agnostic, so in our code we use a static Configuration.GetValue()
. A quick global search-and-replace and we were away.
EDIT: Today this is easier: see the MSDN reference for the CloudConfigurationManager.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With