azure - 将 Consul 与 Azure 应用服务结合使用

标签 azure azure-web-app-service consul

我希望将所有 Azure Web 应用服务以及 Azure 外部资源的所有配置设置都集中在一个位置。 Consul 的键值存储似乎很适合(如果有其他更适合的东西,我很高兴听到其他建议)。从我对 Consul 的有限了解来看,每个节点都需要运行一个代理才能访问键值存储。

这是正确的吗?如果是这样,我该如何做到这一点,是通过 Azure 中的连续 Web 作业吗?如果没有,如何在没有代理的情况下访问 KV 存储?

最佳答案

看起来我们根本无法将 consul 与 Azure 应用服务(又名 Web 应用)一起使用。

这是我尝试过的。

<强>1。天真的方法 - consul 作为 WebJob

由于网络限制,尝试连接到任何本地主机端口时,如果属于应用服务(Web 应用程序)本身的进程未生成,则最终会出现以下异常。

An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:8500.

引用文档:

https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#networking-restrictionsconsiderations

The only way an application can be accessed via the internet is through the already-exposed HTTP (80) and HTTPS (443) TCP ports; applications may not listen on other ports for packets arriving from the internet. However, applications may create a socket which can listen for connections from within the sandbox. For example, two processes within the same app may communicate with one another via TCP sockets; connection attempts incoming from outside the sandbox, albeit they be on the same machine, will fail. See the next topic for additional detail.

这是一个有趣的片段:

Connection attempts to local addresses (e.g. localhost, 127.0.0.1) and the machine's own IP will fail, except if another process in the same sandbox has created a listening socket on the destination port.

<强>2。 Consul 由应用服务本身衍生

我已将 consul 复制到 Web 应用程序(作为构建输出),并将以下几行添加到应用程序启动代码中:

var consul = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin/consul/consul.exe");

Process.Start(consul, "agent --data-dir=../../data");
Process.Start(consul, "join my-cluster-dns.name");

...它加入了集群并且我什至能够从应用服务(Web 应用程序)本身通过127.0.0.1:8500连接到consul。

但是,它仍然是无用的设置,因为 Consul 代理必须可以从服务器访问,所以从集群的角度来看,我所能看到的只是一个“serf”健康检查失败的死节点。同样,根据文档,没有解决此问题的方法:“通过互联网访问应用程序的唯一方法是通过已经公开的 HTTP (80) 和 HTTPS (443) TCP 端口”。

https://www.consul.io/docs/agent/basics.html

Not all Consul agents in a cluster have to use the same port, but this address MUST be reachable by all other nodes.

摘要

总而言之,可能无法通过 Azure 应用服务正确托管/使用 Consul。

consul

关于azure - 将 Consul 与 Azure 应用服务结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48507612/

相关文章:

azure - 如何在应用程序网关后面基于路径的反向代理应用程序服务?

kubernetes - 基于已验证的用户事件的应用程序启动和关闭

docker - 使用Consul的Docker的容器通信

azure - 通过Azure云连接2个不同国家的虚拟机

azure - 如何控制 ADAL AuthenticationContext 中的登录流程?

azure - 小表上的 Azure 表搜索和插入操作速度缓慢

azure - 将 Azure Web App 诊断日志设置添加到 ARM 模板

Azure - 将 Web 应用程序备份到网络保护存储

bash - 使用 shell 脚本解析 consul 模板文件中的行

Azure DNS 区域 : What should I do so that my custom DNS will be used instead of the Azure DNS with IP address 168. 63.129.16?