来自webrole的Azure worker internalendpoint

来自webrole的Azure worker internalendpoint,azure,zeromq,Azure,Zeromq,我创建了一个具有两个角色的托管服务—web角色和工作者角色。我希望使用ZeroMQ在角色之间进行内部通信(我计划创建一组这样的托管服务,每个托管服务中处理的数据略有不同)。我想知道如何从web角色中找出worker角色的内部IP地址,反之亦然,以便在ZMQ的connect()中使用它们。这可能吗?是的,这是可能的。您可以通过RoleEnvironment访问您的角色,然后您可以访问您的实例、端点 foreach (var role in RoleEnvironment.Roles) {

我创建了一个具有两个角色的托管服务—web角色和工作者角色。我希望使用ZeroMQ在角色之间进行内部通信(我计划创建一组这样的托管服务,每个托管服务中处理的数据略有不同)。我想知道如何从web角色中找出worker角色的内部IP地址,反之亦然,以便在ZMQ的connect()中使用它们。这可能吗?

是的,这是可能的。您可以通过RoleEnvironment访问您的角色,然后您可以访问您的实例、端点

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;
        }
    }
}

是的,这是可能的。您可以通过RoleEnvironment访问您的角色,然后您可以访问您的实例、端点

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;
        }
    }
}