简体   繁体   English

在C#中为Azure VM检索Azure负载平衡器NAT端口

[英]Retrieve Azure load balancer NAT port for Azure VM in C#

I have an Azure Load Balancer in front of a Azure VM Scale Set (VMSS). 我在Azure VM规模集(VMSS)前面有一个Azure负载平衡器。 I also have a NAT pool configured on the Load Balancer like the following: 我还在负载均衡器上配置了一个NAT池,如下所示:

{ "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). 本质上,对于VMSS中的每个VM,负载平衡器会将在DNSName:PORT(在10100-10500之间)收到的请求转发到其中一个VM:10000(后端端口相同)。

Is it possible to retrieve the PORT assigned to this VM, programmatically in C#, for a program running on that VM? 是否可以通过C#以编程方式检索在该VM上运行的程序分配给该VM的PORT? This would help me directly target that VM port. 这将帮助我直接定位该VM端口。

您可以参考本文并在GitHub链接上找到代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM