Partilhar via


RoleEnvironment.CurrentRoleInstance Property

 

Gets a RoleInstance object that represents the role instance in which the code is currently running.

Namespace:   Microsoft.WindowsAzure.ServiceRuntime
Assembly:  Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)

Syntax

public static RoleInstance CurrentRoleInstance { get; }
public:
property RoleInstance^ CurrentRoleInstance {
    static RoleInstance^ get();
}
static member CurrentRoleInstance : RoleInstance with get
Public Shared ReadOnly Property CurrentRoleInstance As RoleInstance

Property Value

Type: Microsoft.WindowsAzure.ServiceRuntime.RoleInstance

Type: Microsoft.WindowsAzure.ServiceRuntime.RoleInstance

An instance of RoleInstance.

Remarks

A role is a component of an application that performs specific functionality, such as running a website or performing background tasks. A role instance is a running copy of the role in Windows Azure or the Windows Azure Compute Emulator. A role must have endpoints defined to communicate internally and externally. The following code example shows how to retrieve endpoint information for the current role instance:

var roleInstance = RoleEnvironment.CurrentRoleInstance; 
foreach (RoleInstanceEndpoint instanceEndpoint in roleInstance.InstanceEndpoints.Values) 
{  
   Trace.WriteLine("Instance endpoint address and port: " + instanceEndpoint.IPEndpoint, "Information");
   Trace.WriteLine("Protocol for the endpoint: " + , instanceEndpoint.Protocol, "Information");
}

See Also

RoleEnvironment Class
Microsoft.WindowsAzure.ServiceRuntime Namespace

Return to top