RoleEnvironment.GetConfigurationSettingValue Method
Retrieves the value of a setting in the service configuration file.
Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)
[SecurityPermissionAttribute(SecurityAction.Assert, UnmanagedCode=true)] public static string GetConfigurationSettingValue ( string configurationSettingName )
/** @attribute SecurityPermissionAttribute(SecurityAction.Assert, UnmanagedCode=true) */ public static String GetConfigurationSettingValue ( String configurationSettingName )
public static function GetConfigurationSettingValue ( configurationSettingName : String ) : String
Parameters
- configurationSettingName
Type: System.String
The name of the configuration setting.
Return Value
Type: System.StringA String that contains the value of the configuration setting.| Exception type | Condition |
|---|---|
| RoleEnvironmentException |
The configuration setting that was being retrieved does not exist. |
Configuration settings for a role are defined in the ServiceDefinition.csdef file and the values for the settings are configured in the ServiceConfiguration.cscfg file. For more information about defining and configuring settings, see the following information:
The GetConfigurationSettingValue method can be used to retrieve the value that is defined in the ServiceConfiguration.cscfg file. The following code example shows how to get and write out the value for a setting called MySetting:
var settingValue = RoleEnvironment.GetConfigurationSettingValue("MySetting"); Trace.WriteLine("The setting value is: " + settingValue, "Information");
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Development Platforms
Windows Vista, Windows 7 and Windows Server 2008Target Platforms
Thank you for your feedback
Thank you for your feedback. The topic has been updated and a new version will be published soon.
- 11/15/2011
- David Murray - MSFT
Conflicting settings locations
The Remarks section above states two file names for the settings:
"settings are configured in the ServiceConfiguration.cscfg file."
"used to retrieve the value that is defined in the ServiceDefinintion.cscfg file."
"settings are configured in the ServiceConfiguration.cscfg file."
"used to retrieve the value that is defined in the ServiceDefinintion.cscfg file."
- 9/7/2011
- CaryJ
What is service definition file?
service definition file = ServiceDefinition.csdef
- 4/18/2011
- devghai
What if the setting is not found
This document does not explain what happens when the setting is not found. I found that it returns a Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException whose message consists entirely of "error" :/
- 3/16/2011
- Evan Mc
What and where is the service definition file in an Azure project?
This documentation is too vague. What is the "service definition file?" Is it Web.config? Is it app.config? If so, the app.config files and Web.config files are huge and there are many different places where a setting could be placed. Need specific information and direct, concrete, task-oriented sample code.
"A role's configuration settings are defined in the service definition file. Values for configuration settings are set in the service configuration file"
"A role's configuration settings are defined in the service definition file. Values for configuration settings are set in the service configuration file"
- 2/24/2011
- rebcabin