Retrieve Azure load balancer NAT port for Azure VM in C#

夙愿已清 提交于 2019-12-11 16:14:06

问题


I have an Azure Load Balancer in front of a Azure VM Scale Set (VMSS). I also have a NAT pool configured on the Load Balancer like the following:

{ "name": "InstanceInputEndpointNatPool", "properties": { "backendPort": 10000, "frontendIPConfiguration": { "id": "[concat(resourceId('Microsoft.Network/loadBalancers', variables('loadBalancers_01_name')), '/frontendIPConfigurations/LoadBalancerIPConfig')]" }, "frontendPortRangeStart": 10100, "frontendPortRangeEnd": 10500, "protocol": "Tcp" } }

Essentially, for each VM in the VMSS, the load balancer forwards a request received at DNSName:PORT(between 10100-10500) to one of the VMs:10000(same backend port).

Is it possible to retrieve the PORT assigned to this VM, programmatically in C#, for a program running on that VM? This would help me directly target that VM port.


回答1:


You may refer the article and find the code on GitHub link.



来源:https://stackoverflow.com/questions/49298789/retrieve-azure-load-balancer-nat-port-for-azure-vm-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!