RoleEnvironment.Roles Property
Gets the set of Role objects defined for the hosted service.
Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)
Syntax
public static IDictionary<string, Role> Roles { get; }
public:
property IDictionary<String^, Role^>^ Roles {
static IDictionary<String^, Role^>^ get();
}
static member Roles : IDictionary<string, Role> with get
Public Shared ReadOnly Property Roles As IDictionary(Of String, Role)
Property Value
Type: System.Collections.Generic.IDictionary<String, Role>
Type: System.Collections.Generic.IDictionary
A IDictionary<TKey, TValue> that contains the Role objects that are defined for the hosted service.
Remarks
Roles are defined in the ServiceDefinition.csdef file. For more information about defining roles for a hosted service, see Setting Up a Hosted Service for Windows Azure.
The following code example shows how to obtain the role instance IDs for defined roles:
foreach (var roleDefinition in RoleEnvironment.Roles)
{
foreach (var roleInstance in roleDefinition.Value.Instances)
{
Trace.WriteLine("Role instance ID: " + roleInstance.Id, "Information");
}
}
Note
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.
See Also
RoleEnvironment Class
Microsoft.WindowsAzure.ServiceRuntime Namespace
Return to top