简体   繁体   English

通过Powershell添加负载均衡器规则

[英]Adding Load Balancer Rule via Powershell

I'm attempting to add a load balancer rule via Powershell as we need to open multiple ports for passive ftp. 我试图通过Powershell添加负载平衡器规则,因为我们需要为被动ftp打开多个端口。

Connect-AzureRmAccount

Set-AzureRmContext -SubscriptionId "MySubId"

$slb = Get-AzureRmLoadBalancer -Name "MyLB" -ResourceGroupName "MyRG"

$prb = Get-AzureRmLoadBalancerProbeConfig -Name "MyProbe" -LoadBalancer $slb

$beaddpool = Get-AzureRmLoadBalancerBackendAddressPoolConfig -Name "BEADDPOOL" -LoadBalancer $slb

$slb | Add-AzureRmLoadBalancerRuleConfig -Name "PassivePort_50010" -FrontendIPConfiguration $slb.FrontendIpConfigurations[0] -BackendAddressPool $beaddpool -Protocol "Tcp" -FrontendPort 50010 -BackendPort 50010 -Probe $prb -IdleTimeoutInMinutes 4

$slb | Set-AzureRmLoadBalancerRuleConfig -Name "PassivePort_50010" -FrontendIPConfiguration $slb.FrontendIpConfigurations[0] -BackendAddressPool $beaddpool -Protocol "Tcp" -FrontendPort 50010 -BackendPort 50010 -Probe $prb -IdleTimeoutInMinutes 4

As you can see above, I'm logging in, grabbing the LB in question, the LB Probe and the LB BackEndAddressPool. 如您在上面看到的,我正在登录,获取有问题的LB,LB探针和LB BackEndAddressPool。 I'm then using Add-AzureRmLoadBalancerRuleConfig and Set-AzureRmLoadBalancerRuleConfig as mentioned in the documentation 然后,我按照文档中所述使用Add-AzureRmLoadBalancerRuleConfig和Set-AzureRmLoadBalancerRuleConfig

I can see from the PowerShell output that the rule is there. 从PowerShell输出中可以看到该规则已存在。 However it lacks one obvious property in comparison to those added via the portal. 但是,与通过门户网站添加的属性相比,它缺乏一个明显的属性。

"ProvisioningState": "Succeeded" “ ProvisioningState”:“成功”

The new rule is not shown in the portal, but is visible when getting the LB via PS. 新规则未在门户中显示,但在通过PS获取LB时可见。

Is there a way I'm missing to ensure the rule is displayed in the azure portal? 有什么方法可以确保规则显示在azure门户中吗? Or does the rule take much longer to be provisioned in this way? 还是以这种方式设置规则需要更长的时间?

创建属性后,需要应用它们:

$slb | Set-AzureRmLoadBalancer
Connect-AzureRmAccount

Set-AzureRmContext -SubscriptionId "MySubId"

$slb = Get-AzureRmLoadBalancer -Name "MyLB" -ResourceGroupName "MyRG"

$slb | Add-AzureRmLoadBalancerRuleConfig -Name "PassivePort_50010" -FrontendIPConfiguration $slb.FrontendIpConfigurations[0] -BackendAddressPool $beaddpool -Protocol "Tcp" -FrontendPort 50010 -BackendPort 50010 -Probe $prb -IdleTimeoutInMinutes 4

$slb | Set-AzureRmLoadBalancer 

For more details, you may refer similar MSDN thread, which addressing same issue. 有关更多详细信息,您可以引用类似的MSDN线程,以解决同一问题。

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

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