在虚拟机规模集中查找其他实例

Find other instances within a Virtual Machine Scale Set

虚拟机规模集中的实例是否可以发现同一规模集中的其他实例(私有 IP 地址)? VMSS 设置为自动缩放,因此其他实例可能随时出现和消失。

Azure 实例元数据服务仅 returns 有关进行查询的实例的信息,而不是 VMSS 中的任何其他实例。 az vmss list-instance-connection-info 命令仅 returns 有关负载均衡器上入站 NAT 池的公共可访问端口的信息。

我正在尝试为 VMSS 中的实例创建一个反向通道以(同步)协作。我考虑过的其他替代方案包括子网上的 UDP 多播以宣传可用性、VM 注册其网络信息的 Azure Redis 缓存(并在缩小时注销)和 Service Fabric Reliable Collections(我们不使用容器) .还有其他办法吗?

看来你想知道一个VMSS中每个实例的私有IP地址。

如果是这样,您可以使用 Azure CLI 检索它,

az vmss nic list -g nancyvm --vmss-name myvmss --query "[].ipConfigurations[].{ID:id,PrivateIPAddress:privateIpAddress}" -o table

如果你运行它在Linux,你可以更容易,

az vmss nic list -g nancyvm --vmss-name myvmss | grep -w "privateIpAddress" 

有关它的更多 PowerShell 脚本,请参阅 this blog