I am using CloudConfigurationManager for getting my connection string. I have created one *Azure Service Fabric Application.
storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
It is working fine, but i can see this as well:
Getting "StorageConnectionString" from ServiceRuntime: FAIL.
Kindly explain why is it showing such FAIL message. Also how is this CloudConfigurationManager works?
Note:Do not tag any workarounds, as I have seen them all. Here are the links that I already visited, but not satisfied.
Kindly explain why is it showing such FAIL message. Also how is this CloudConfigurationManager works?
AFAIK, Microsoft.WindowsAzure.ConfigurationManager is just a stand-alone library with no dependencies. And it describes as follows:
Microsoft Azure Configuration Manager provides a unified API to load configuration settings regardless of where the application is hosted - whether on-premises or in a Cloud Service.
The CloudConfigurationManager.GetSetting
would read the configuration settings from the appropriate configuration store. If your application is running as a .NET Web application, the GetSetting
method would retrieve the setting value from the Web.config
or app.config
file. While the application is running in Windows Azure Cloud Service or in a Windows Azure Website, the GetSetting
would retrieve the setting value from the ServiceConfiguration.cscfg
.
Use ILSpy, we could find the GetSetting
method would check the ServiceRuntime provider firstly and leverage RoleEnvironment.GetConfigurationSettingValue(string configurationSettingName) for getting the setting value. If the value is null
, then it would use the ConfigurationManager provider and leverage ConfigurationManager.AppSettings['<settingName>'];
.
internal string GetSetting(string name, bool outputResultsToTrace)
{
string value = AzureApplicationSettings.GetValue("ServiceRuntime", name, new Func<string, string>(this.GetServiceRuntimeSetting), outputResultsToTrace);
if (value == null)
{
string arg_44_0 = "ConfigurationManager";
Func<string, string> arg_44_2;
if ((arg_44_2 = AzureApplicationSettings.<>c.<>9__10_0) == null)
{
arg_44_2 = (AzureApplicationSettings.<>c.<>9__10_0 = new Func<string, string>(AzureApplicationSettings.<>c.<>9.<GetSetting>b__10_0));
}
value = AzureApplicationSettings.GetValue(arg_44_0, name, arg_44_2, outputResultsToTrace);
}
return value;
}
Since you configured the settings in your app.config
file, and the GetSetting
method would write log to Trace by default, then you would see the trace logs as you provided. Additionally, you could use GetSetting('<settingName>',false)
for disable the trace log.