How do I define port for each endpoint in my azure cloud service

926 views Asked by At

So I have an Azure Cloud Service, and right now it has 2 instances. I want the ability to communicate with each instance individually, and it seems to me that the info found here - https://msdn.microsoft.com/en-us/library/azure/hh180158.aspx - should give me just what I need.

What I don't understand is, how do I communicate with each instance? If I define 2 input endpoints for my web role, how does it "know" which instance responds to one port, and which to the other?

For example, here's a sample of the ServiceDefinition file Im currently playing with:

<ServiceDefinition name="BasicWrapperServices.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2014-06.2.4">
  <WebRole name="MyCloudService" vmsize="Medium">
    <Certificates>
      <Certificate name="mydomain.com" storeLocation="LocalMachine" storeName="My" />
    </Certificates>
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
          <Binding name="HttpsIn" endpointName="HttpsIn" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
      <InputEndpoint name="HttpsIn" protocol="https" port="443" certificate="mydomain.com" />
      <InputEndpoint name="InputEndpoint1" protocol="https" port="10000" certificate="mydomain.com"/>
      <InputEndpoint name="InputEndpoint2" protocol="https" port="10001" certificate="mydomain.com" />
    </Endpoints>
    <Imports>
      <Import moduleName="RemoteAccess" />
      <Import moduleName="RemoteForwarder" />
    </Imports>
  </WebRole>
</ServiceDefinition>

What Im looking for here is to be able to communicate with one instance over port 10000 and the other over 10001, unless Im mistaken?

2

There are 2 answers

0
Panos On

If you want to connect directly to each one of the instances without going through the Loadbalancer, then on the same URL you provided, take a look at the Direct port endpoint.

The range of the ports e.g. 10000 to 10010 are allocated sequentially to the instances of your role. Role_0 gets 10000, Role_1 get's 10001 etc. etc.

Hope it helps.

0
d.popov On

You need an InstanceInputEndpoint, not an InputEndpoint So your config will look like this:

  <InstanceInputEndpoint name="TraceEndpoint" protocol="tcp" localPort="443">
    <AllocatePublicPortFrom>
      <FixedPortRange max="10000" min="10010" />
    </AllocatePublicPortFrom>
  </InstanceInputEndpoint>

Then you can look in the old portal what endpoints are allocated.

The local port may be whatever you want.

In your case it should be 443 I guess, as you want to access the instances over https protocol. So on each instance there must be something that is listening. In your case it is the IIS, on 443 port.

Then you can access the 443 local port for each of the instances by the public IP and the public port assigned for each of them.