Define Input Endpoints for a Role
Updated: April 13, 2011
You can define input endpoints for roles by adding an Endpoints element that contains InputEndpoint elements to the WebRole, WorkerRole, or VirtualMachineRole elements in the service definition file. The InputEndpoint element defines the name, protocol, and port for the endpoint. For more information about these elements, see the Service Definition Schema.
You can edit the ServiceDefinition.csdef file by using your favorite text editor, or you can define the settings for your service by using Visual Studio 2010.
-
Open the ServiceDefinition.csdef file for your service in the text editor.
-
Add the Endpoints element that contains an InputEndpoint element to the role element. The following example shows how to add an HTTP input endpoint for a web role that listens on port 80 and also defines the internal port of 80:
<ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> <WebRole name="WebRole1"> <Endpoints> <InputEndpoint name="HttpIn" protocol="http" port="80" localPort="80" /> </Endpoints> </WebRole> </ServiceDefinition>
Note The localPort attribute is optional. If this attribute is not defined, the fabric assigns the internal port number at run time. The following example shows how to add a TCP input endpoint for a worker role that listens on port 10000.
<ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> <WorkerRole name="WorkerRole1"> <Endpoints> <InputEndpoint name="Endpoint1" protocol="tcp" port="10000" /> </Endpoints> </WorkerRole> </ServiceDefinition> -
Set the name of the endpoint to the name that you want to use.
-
Set the protocol to be the type of communication that you want to use. The possible choices are HTTP, HTTPS, or TCP.
-
Specify the port number that you want to use for the role communication.
-
Save the file.
-
Open your service project in Visual Studio.
-
In Solution Explorer, under the Roles node, right-click the role, and then click Properties.
-
Click Endpoints, and then click Add Endpoint.
-
Type the name of the endpoint.
-
Select Input for the type of endpoint.
-
Select the protocol for the endpoint. The possible choices are HTTP, HTTPS, or TCP.
-
Enter the port number that you want to use for communicating with the role.
-
Save and build the project.
See Also