ServiceFabric 警告 "Endpoint with ExplicitPort is within application port range. This can cause port conflicts."

ServiceFabric Warning "Endpoint with ExplicitPort is within application port range. This can cause port conflicts."

将我的 ServiceFabric 集群更新到版本 6.5 后,我的应用程序开始弹出警告。

Endpoint MyEndpoint with ExplicitPort 27000 is within application port range. This can cause port conflicts. Please select a port from outside application port range.

为什么会出现这个错误,我需要做什么来修复它?

从 ServiceFabric 6.5CU2 开始,ServiceFabric 开始显示针对这些错误配置的警告。这些警告将来可能会变成错误。

By design static ports should not overlap with application port range specified in the ClusterManifest. If you specify a static port, assign it outside of application port range, otherwise it will result in port conflicts. With release 6.5CU2 we will issue a Health Warning when we detect such a conflict but let the deployment continue in sync with the shipped 6.5 behaviour. However, we may prevent the application deployment from the next major releases.

(https://docs.microsoft.com/en-gb/azure/service-fabric/service-fabric-service-manifest-resources)

应用程序端口范围是集群范围的,默认为20000-30000。

您可以更改它,例如通过 ARM 模板或 https://resources.azure.com

    "nodeTypes": [
      {
        "name": "nt",
...

        "applicationPorts": {
          "startPort": 20000,
          "endPort": 30000
        },
...
      }
    ],

可以在您的服务的 servicemanifest.json 中配置静态端点端口。

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest ...>
  <Resources>
    <Endpoints>
      <!-- This endpoint is used by the communication listener to obtain the port on which to 
           listen. Please note that if your service is partitioned, this port is shared with 
           replicas of different partitions that are placed in your code. -->
      <Endpoint Name="MyEndpoint" Protocol="http" Port="27000" PathSuffix="/xxx" UriScheme="http" Type="Input" />
    </Endpoints>
  </Resources>
</ServiceManifest>