Export (0) Print
Expand All

Retrieve Role Instance Data

Updated: October 24, 2014

To determine the port number for an internal endpoint on a role instance, you can use the InstanceEndpoints property to return a Dictionary object that contains endpoint names and their corresponding IP addresses and ports. The IPEndpoint property returns the IP address and port for a specified endpoint. The PublicIPEndpoint property returns the port for a load balanced endpoint. The IP address portion of the PublicIPEndpoint property is not used.

  1. Open the source file that you want to use for retrieving role instance data.

  2. Add the code to iterate through the role instances. The following code example shows how to write out the identifier, port, and IP address information for role instances:

    foreach (RoleInstance roleInst in RoleEnvironment.CurrentRoleInstance.Role.Instances)
       Trace.WriteLine("Instance ID: " + roleInst.Id);
       foreach (RoleInstanceEndpoint roleInstEndpoint in roleInst.InstanceEndpoints.Values)
          Trace.WriteLine("Instance endpoint IP address and port: " + roleInstEndpoint.IPEndpoint);
  3. Save the file.

For information about internal endpoints within the service definition file, see Service Definition Schema.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft