Define Internal Endpoints for a Role
Updated: April 13, 2011
You can define internal endpoints for roles by adding an Endpoints element that contains InternalEndpoints elements to the WebRole, WorkerRole, and VirtualMachineRole elements in the service definition file. 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.
Open the ServiceDefinition.csdef file for your service in the text editor.
For a web role, worker role or VM role, add the Endpoints element that contains InternalEndpoint elements to the WebRole element. The following example shows how to add an HTTP internal endpoint for a web role with a specified port number:
<ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> <WebRole name="WebRole1"> <Endpoints> <InternalEndpoint name="InternalHttpIn" protocol="http" port="1000"/> </Endpoints> </WebRole> </ServiceDefinition>
Note Port is optional. You can let Windows Azure assign the port number.
The following example shows how to add a TCP internal endpoint for a worker role.
<ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> <WorkerRole name="WorkerRole1"> <Endpoints> <InternalEndpoint name="Endpoint1" protocol="tcp" /> </Endpoints> </WorkerRole> </ServiceDefinition>
You can also optionally define a range of port numbers:
<InternalEndpoint name="InternalPoint1" protocol="tcp"> <FixedPortRange min="1000" max="2000" /> </InternalEndpoint>
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.
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 perform one of the following steps:
For a web role, in the Internal endpoint section, select the HTTP checkbox, and then enter the name for the endpoint.
For a worker or VM role, click Add Endpoint, enter the name for the endpoint, select Internal for the type, and then select the protocol.
- For a web role, in the Internal endpoint section, select the HTTP checkbox, and then enter the name for the endpoint.
Save and build the project.