Azure的InstanceInput端点使用 [英] Azure InstanceInput endpoint usage

查看:157
本文介绍了Azure的InstanceInput端点使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以请张贴样本code使用InstanceInput终点?
我用下面的配置在在8080端口一个样本WCF服务侦听辅助角色

Can someone please post a sample code for using InstanceInput endpoints? I used the below configuration in a worker role where a sample WCF service listens at port 8080.

<Endpoints>
  <InstanceInputEndpoint name="InstanceAccess" protocol="tcp" localPort="8080">
    <AllocatePublicPortFrom>
      <FixedPortRange max="10105" min="10101" />
    </AllocatePublicPortFrom>
  </InstanceInputEndpoint>
</Endpoints>

但我不能使用任何端口从外部消费者访问此WCF服务10101到10105.我们应该用在Azure服务的公共DNS名称与范围内给予公口一起?

But I was not able to access this WCF service from an external consumer using any of the ports 10101 to 10105. Should we use the public DNS name of the Azure service along with the public ports in the give range?

另外,我是无法从辅助角色的OnStart()方法中访问该终端的详细信息。我用RoleEnvironment.CurrentRoleInstance.InstanceEndpoints [了instanceAccess。不过,这并不返回RoleInstanceEndpoint。我失去了一些东西在这里?

Also, I was not able to access this endpoint details from within the worker role OnStart() method. I used RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["InstanceAccess"]. But it does not return a RoleInstanceEndpoint. Am I missing something here?

推荐答案

这里是一个示例的Visual Studio解决方案,使用Azure的InstanceInput端点和主机上的工人角色的WCF服务。在每个单个实例运行的WCF服务可以使用Azure的DNS名称和映射到该实例的公共端口访问。我用下面的端点配置。

Here is a sample Visual Studio solution which uses Azure InstanceInput endpoint and hosts a WCF service on a worker role. The WCF service running on each of the individual instances can be accessed using the Azure DNS name and the public port mapped to that instance. I used the following endpoint configuration.

  <Endpoints>
      <InstanceInputEndpoint name="Endpoint1" protocol="tcp" localPort="10100">
        <AllocatePublicPortFrom>
          <FixedPortRange max="10110" min="10106" />
        </AllocatePublicPortFrom>
      </InstanceInputEndpoint>
    </Endpoints>

这个终点是有点不从WorkerRole(两者的OnStart()和run()的方法)中访问。所以我用'localhost'的。

This endpoint was somehow not accessible from within the WorkerRole (both OnStart() and Run() methods). So I used 'localhost'.

  string endpointIP = "localhost:10100";

  if (RoleEnvironment.CurrentRoleInstance.InstanceEndpoints.Keys.Contains("Endpoint1"))
  {
      IPEndPoint externalEndPoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint;
      endpointIP = externalEndPoint.ToString();
  }

该解决方案还包含使用托管DNS名称来调用这些单独的WCF服务控制台客户端。

The solution also contains a console client which uses the hosted DNS name to invoke these individual WCF services.

这篇关于Azure的InstanceInput端点使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆