Esporta (0) Stampa
Espandi tutto

Classe Role

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

Spazio dei nomi: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in microsoft.windowsazure.serviceruntime.dll)

'Utilizzo
Dim instance As Role

public abstract class Role
public abstract class Role
public abstract class Role

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, Setting Up a Hosted Service for Windows 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.

noteNota
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.


System.Object
  Microsoft.WindowsAzure.ServiceRuntime.Role

Tutti i membri statici pubblici (Shared in Visual Basic) di questo tipo sono thread-safe. I membri di istanza non sono garantiti come thread-safe.

Piattaforme di sviluppo

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Server 2008 e Windows 2000

Piattaforme di destinazione

Aggiunte alla community

Microsoft sta conducendo un sondaggio in linea per comprendere l'opinione degli utenti in merito al sito Web di MSDN. Se si sceglie di partecipare, quando si lascia il sito Web di MSDN verrà visualizzato il sondaggio in linea.

Si desidera partecipare?
Mostra:
© 2014 Microsoft