Reputation: 540
I have a Azure project which uses the Azure Storage. The connection string for the Azure Storage is saved in the Configuration Settings for the Azure Project.
Now I have created a class library. I want to be able to load the connection string in the class library. What is the best way of doing this?
For example, do I put the connection string in the app.config for the class library? If so, will the Azure project override this automatically when I run the solution?
Upvotes: 0
Views: 216
Reputation: 540
RoleEnvironment.GetConfigurationSettingValue("") is what I was looking for.
Upvotes: 0
Reputation: 311
You may be looking for Microsoft.WindowsAzure.CloudConfigurationManager
. The GetSetting
method attempts to pull the setting from the Cloud configuration, but if the role isn't available (for instance because you're in a unit test), it reads from the <AppSettings>
element inside your app.config or web.config file.
Here's the basic syntax:
using Microsoft.WindowsAzure;
...
var settingValue = CloudConfigurationManager.GetSetting("SettingKey");
MSDN[1] says the syntax is deprecated with the release of Storage 3.0, but the class and method aren't attributed as such, so the documentation may just have a bit of copy pasta in it.
Upvotes: 0