0
我创建了一个具有两个角色的托管服务 - 一个web和一个worker角色。我想使用ZeroMQ在内部角色之间进行通信(我计划创建一堆这样的托管服务,每个处理的数据略有不同)。我想知道如何从web角色中找出worker角色的内部IP地址,反之亦然,以便我可以在ZMQ的connect()中使用它们。这可能吗?来自webrole的Azure worker internalendpoint
我创建了一个具有两个角色的托管服务 - 一个web和一个worker角色。我想使用ZeroMQ在内部角色之间进行通信(我计划创建一堆这样的托管服务,每个处理的数据略有不同)。我想知道如何从web角色中找出worker角色的内部IP地址,反之亦然,以便我可以在ZMQ的connect()中使用它们。这可能吗?来自webrole的Azure worker internalendpoint
是的,这是可能的。您可以通过角色环境访问您的角色,然后您可以访问您的实例,您的端点,...
foreach (var role in RoleEnvironment.Roles)
{
// Access role.Key to identify the role.
foreach (var instance in role.Value.Instances)
{
// Access instance.Id to identify the instance.
foreach (var endpoint in instance.InstanceEndpoints)
{
// Access endpoint.Key to identify the endpoint.
System.Net.IPAddress ip = endpoint.Value.IPEndpoint.Address;
int port = endpoint.Value.IPEndpoint.Port;
}
}
}