SALES: 1-800-867-1380

Role Class

 

Updated: December 6, 2013

Represents a role that is defined as part of a hosted service.

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

System::Object
  Microsoft.WindowsAzure.ServiceRuntime::Role

public ref class Role abstract 

NameDescription
System_CAPS_pubpropertyInstances

Gets the collection of instances for the role.

System_CAPS_pubpropertyName

Gets the name of the role as it is declared in the service definition file.

NameDescription
System_CAPS_pubmethodEquals(Object^)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

The application that you develop runs as a hosted service in Windows Azure, and the application is built from one or more roles. A role defines a component that may run in the execution environment within Windows Azure. For more information about defining and configuring roles in the service model for a hosted service see, Set Up a Cloud Service for Azure. Roles that are defined for the hosted service run as role instances in Windows Azure.

The Role class is used to obtain role instance objects. The following code example shows how to retrieve the name of the role and the instance IDs of role instances:


// Display the name of the role
Trace.WriteLine("Role Name: " + RoleEnvironment.CurrentRoleInstance.Role.Name);

// Iterate through each instance object and display the identifier
foreach (RoleInstance roleInst in RoleEnvironment.CurrentRoleInstance.Role.Instances)    
{
   Trace.WriteLine("Instance ID: " + roleInst.Id);    
}

You can change the number of role instances that are running by changing the instances count in the ServiceConfiguration.csfg file. For more information about changing the instance count, see How to Scale Applications by Increasing or Decreasing the Number of Role Instances.

System_CAPS_noteNote

At least one internal endpoint must be defined for a role to enable instances to be known at runtime. For more information about defining internal endpoints, see How to Define Internal Endpoints for a Role.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft