CloudConfigurationManager.GetSetting doesn’t retrieve settings from the section of app.config. Instead, it pulls values from the section or from Azure configuration sources, such as the Azure portal or environment variables.

To fix this, you have two options:

1. Use instead of :

Update your app.config to use the section like this:

<configuration> 
        <appSettings> 
             <add key="StorageConnectionString" value="[ConnectionStringHere]" />         
         </appSettings>
</configuration>

Now, CloudConfigurationManager.GetSetting(“StorageConnectionString”) will return the connection string correctly.

2. Use ConfigurationManager for Connection Strings:

Alternatively, you can read the connection string directly from the section using ConfigurationManager:

var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[“StorageConnectionString”].ConnectionString;

This will allow us to keep the connection string in the section. Just ensure that there is a reference to System.Configuration in the project.

var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;

This will allow us to keep the connection string in the section. Just ensure that there is a reference to System.Configuration in the project.

Support On Demand!

Cloud