在 Service Fabric 中公开 Web API
Exposing Web API in Service Fabric
我在访问已部署到我的 Service Fabric 群集的 Web Api 时遇到问题。我遵循了新的无状态 Web Api 模板并添加了如下所示的 http 端点。我还对 OwinCommunication 进行了修改 here。
<Resources>
<Endpoints>
<Endpoint Name="ServiceEndpoint" Type="Input" Protocol="http" Port="8080" />
</Endpoints>
</Resources>
在创建我的集群时,我向我的节点类型添加了一个自定义端点 80。
我的集群的客户端连接端点是:mycluster.eastus.cloudapp.azure.com:19000
此外,我有一个负载平衡规则,通过 TCP 将端口 80 映射到后端端口 8080。关联的探测器位于端口 80 上,我已经尝试了两种协议(http 和 tcp),但似乎都不起作用。
在本地,我可以通过调用 http://localhost:8080/health/ping, and get back "pong". When I attempt to access it in service fabric cluster, a file is downloaded. The URL I use to access it in the cloud is http://mycluster.eastus.cloudapp.azure.com:19000/health/ping 访问 Web Api 上的端点。我试过其他端口(19080、80、8080),但它们要么挂起,要么给我一个 400。
我关于在服务结构集群中公开 Web Api 的问题是:
- 探测应该是 http 还是 tcp?
- 是否应将探测后端端口设置为 Web api 端口(例如 8080)?
- 我的URL/port访问我的api是否正确?
- 为什么下载的是二进制文件?这在所有浏览器中都会发生,并且内容会在 postman 和 fiddler 中显示。
经过多次探索后找到了我的问题的答案。如果我的 Web Api 端点设置为端口 8080,那么我需要以下内容:
- 探测 TCP 端口 8080
- 一个80端口和8080后端端口的负载均衡规则
- 通过以下 URL 访问网络 Api:http://mycluster.eastus.cloudapp.azure.com/health/ping
至于#4,这还是个谜。
http://mycluster.eastus.cloudapp.azure.com:19000/health/ping
这是错误的。
应该是http://mycluster.eastus.cloudapp.azure.com:8080/health/ping
至少文档是这么说的。所以它应该在不接触负载平衡器的情况下工作。
我在访问已部署到我的 Service Fabric 群集的 Web Api 时遇到问题。我遵循了新的无状态 Web Api 模板并添加了如下所示的 http 端点。我还对 OwinCommunication 进行了修改 here。
<Resources>
<Endpoints>
<Endpoint Name="ServiceEndpoint" Type="Input" Protocol="http" Port="8080" />
</Endpoints>
</Resources>
在创建我的集群时,我向我的节点类型添加了一个自定义端点 80。
我的集群的客户端连接端点是:mycluster.eastus.cloudapp.azure.com:19000
此外,我有一个负载平衡规则,通过 TCP 将端口 80 映射到后端端口 8080。关联的探测器位于端口 80 上,我已经尝试了两种协议(http 和 tcp),但似乎都不起作用。
在本地,我可以通过调用 http://localhost:8080/health/ping, and get back "pong". When I attempt to access it in service fabric cluster, a file is downloaded. The URL I use to access it in the cloud is http://mycluster.eastus.cloudapp.azure.com:19000/health/ping 访问 Web Api 上的端点。我试过其他端口(19080、80、8080),但它们要么挂起,要么给我一个 400。
我关于在服务结构集群中公开 Web Api 的问题是:
- 探测应该是 http 还是 tcp?
- 是否应将探测后端端口设置为 Web api 端口(例如 8080)?
- 我的URL/port访问我的api是否正确?
- 为什么下载的是二进制文件?这在所有浏览器中都会发生,并且内容会在 postman 和 fiddler 中显示。
经过多次探索后找到了我的问题的答案。如果我的 Web Api 端点设置为端口 8080,那么我需要以下内容:
- 探测 TCP 端口 8080
- 一个80端口和8080后端端口的负载均衡规则
- 通过以下 URL 访问网络 Api:http://mycluster.eastus.cloudapp.azure.com/health/ping
至于#4,这还是个谜。
http://mycluster.eastus.cloudapp.azure.com:19000/health/ping
这是错误的。
应该是http://mycluster.eastus.cloudapp.azure.com:8080/health/ping
至少文档是这么说的。所以它应该在不接触负载平衡器的情况下工作。