Assembly: Microsoft.WindowsAzure.Configuration (in Microsoft.WindowsAzure.Configuration.dll)
The following example retrieves the value of a configuration setting named StorageConnectionString from the appropriate configuration store.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString"));
The CloudConfigurationManager class reads configuration settings from the appropriate configuration store for the platform on which the application is running.
Windows Azure cloud services (web roles and worker roles) and Windows Azure websites store configuration settings in the ServiceConfiguration.cscfg file, which is unique to applications running in Windows Azure. A .NET application running in an environment outside of Windows Azure usually stores configuration settings in a web.config or app.config file. The CloudConfigurationManager class enables you to read from the appropriate configuration file regardless of the environment in which your code is running.
If you are currently calling Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue from within a web or worker role to retrieve configuration settings, you can modify your code to call GetSetting instead. For new projects, using GetSetting is recommended.
Note that in order to use CloudConfigurationManager to read from an app.config file, you must specify the configuration settings in the appSettings tag, as in the following example, where StorageConnectionString is the configuration setting to read:
<?xml version="1.0" encoding="utf-8" ?> <configuration> … <appSettings> <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey"/> </appSettings> … </configuration>
Only configuration settings within the appSettings tag can be read by CloudConfigurationManager. If your configuration settings are within a different tag, calling GetSetting will return Null.
Development PlatformsWindows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012