Export (0) Print
Expand All

Role.Instances Property

Updated: December 6, 2013

Gets the collection of instances for the role.

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

public abstract ReadOnlyCollection<RoleInstance> Instances { get; }

Property Value

Type: System.Collections.ObjectModel.ReadOnlyCollection

A ReadOnlyCollection that contains the instance objects for the role.

The number of instances of a role to be deployed to Windows Azure is specified in the ServiceConfiguration.cscfg file. For more information about configuring the hosted service, see Windows Azure Service Configuration Schema.

The following code example shows how to retrieve the identifier for each role instance in the collection:


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.

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.

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Target Platforms

Community Additions

ADD
Show:
© 2014 Microsoft