Duration (Pacific Standard Time):
To (Pacific Standard Time):
Impact:
  • None
User Action:
  • None

RoleEnvironment Class

Updated: December 6, 2013

Provides information about the configuration, endpoints, and status of running role instances.

Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)
<WindowsAzureHostingPermissionAttribute(SecurityAction.LinkDemand, Unrestricted:=True)> _
Public NotInheritable Class RoleEnvironment
J#

You use the RoleEnvironment class to obtain configuration settings, local storage resources, and endpoint information for a specified role instance. The class also provides events that allow the role instance to react to configuration changes and receive notification when the role instance is about to be stopped.

noteNote
Windows Azure 1.3 and later reserves for its own use any environment variables that begin with the letters "RD", for example "RdRoleID". If your application creates environment variables that begin with "RD", in certain circumstances, the IsAvailable property will return false, and other methods and properties of the RoleEnvironment class will result in the error message "role discovery data is unavailable." To correct this, use environment variables that do not begin with the letters "RD".

noteNote
The RoleEnvironment class can be used on standalone components in an Azure VM outside of an Azure role. These components can be programs that can be run by, for example, remoting into the role instance and starting the component from the command line. These processes must be run with elevated privileges to access the RoleEnvironment class.

The following code example shows how to get and write out the value for a configuration setting called MySetting by using the GetConfigurationSettingValue method:

No code example is currently available or this language may not be supported.

For more information about defining and configuring settings, see Windows Azure Service Configuration Schema and Windows Azure Service Definition Schema.

The following code example shows how to retrieve a local storage resource and write a text file to it:

No code example is currently available or this language may not be supported.

The following code example shows how to retrieve endpoint information for the current role instance:

No code example is currently available or this language may not be supported.

The following code example shows how to retrieve the configuration changes that have been made to a role instance:

No code example is currently available or this language may not be supported.

The events are only raised if an internal endpoint is defined for the role in the ServiceDefinition.csdef file. For more information about defining endpoints, see How to Define Internal Endpoints for a Role.


System.Object
  Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment
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 2008

Target Platforms