Service Fabric Reverse Proxy Port discovery
The reverse proxy is a feature of Service Fabric that allows to expose internal endpoints, taking care of naming resolution, discovery and maintenance. Basically each service can be reached using an URI like:
In this Uri PORT is the Reverse Proxy port, ApplicationName is the name of the deployed application (root of many services) and ServiceName is the name of the single service inside the application package.
Unfortunately the reverse proxy port is not fixed! It depends from the node where the application is running, so it can even change during the application lifetime. This because the port is defined by the node type, so if the application change node type it changes the port.
To avoid this you can force an application to be deployment only on a specific node type:
<PlacementConstraints> NodeType == NodeType2 </PlacementConstraints>
By the way even with a fixed node type, the port is not "well-known" and can change from cluster to cluster (as it is defined in the cluster config).
If you need to get the port by code at runtime unfortunately there isn't an easy way yet. Basically you need to manually parse the xml cluster manifest, get the list of the node types, find the type where your application is deployed and then read the properties of the HttpApplicationGatewayEndpoint element.
You can check the code needed for this looking at this simple project: SFHelper
Also published as nuget package : https://www.nuget.org/packages/SFHelper/