Azure 外部负载均衡器 - 使用 PowerShell 添加 LB 规则
Azure External Load Balancer - Adding LB Rules with PowerShell
我已经用 Azure 负载均衡器解决这个问题好几天了,但我仍然很苦恼...:(
首先,我可以使用以下方法毫无问题地登录到 Azure:
Login-AzureRmAccount
那么,情况是这样的:
外部负载平衡器
具有唯一 Public IP 地址的多个前端池
具有唯一私有 IP 地址的多个后端池(池中有 VM)
前端和后端池匹配 1:1
LBRule1 - FrontEndPool -> BackEndPool 前后端80端口
LBRule1 - FrontEndPool -> BackEndPool 前后端443端口
现在,当尝试添加另一个 80/443 的 LBRule 时,我不能,因为它已被使用。与 Microsoft 支持人员交谈,只能通过 Powershell 完成(我也做了 enable/disable 浮动 IP)。
这是我的脚本:
# Variables
$rg='ResourceGroupName'
$location='west us'
$lb=Get-AzureRmLoadBalancer -Name LBName -ResourceGroupName $rg
$FEConfig=get-AzureRmLoadBalancerFrontendIpConfig -Name FEPoolName -LoadBalancer $lb
$fec=Get-AzureRmLoadBalancerFrontendIpConfig -Name $FEConfig.Name -LoadBalancer $lb
$BEPool=Get-AzureRmLoadBalancerBackendAddressPoolConfig -Name BEPoolName -LoadBalancer $lb
$BEP=Get-AzureRmLoadBalancerBackendAddressPoolConfig -Name $BEPool.Name -LoadBalancer $lb
$Probe=Get-AzureRmLoadBalancerProbeConfig -Name HTTP-80 -LoadBalancer $lb
$Probe1=Get-AzureRmLoadBalancerProbeConfig -Name HTTPS-443 -LoadBalancer $lb
$LBRule1=New-AzureRmLoadBalancerRuleConfig -Name APP-HTTP80 -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 80 -BackendPort 80 -EnableFloatingIP
$LBRule2=New-AzureRmLoadBalancerRuleConfig -Name APP-HTTP443 -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 443 -BackendPort 443 -EnableFloatingIP
# Command
$lb.LoadBalancingRules.Add($LBRule1)
$lb.LoadBalancingRules.Add($LBRule2)
现在,当我 运行 这个时,没有任何反应。如果你使用 Powershell ISE 来玩这个,你会看到变量会返回正确的信息,但是在资源管理器中看,没有创建新的池。
所以,我做了一些研究并使用上面的相同变量集,我把它们放在一起:
New-AzureRmLoadBalancerRuleConfig -Name $FEConfig.Name -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 80 -BackendPort 80 -EnableFloatingIP
这做同样的事情,没有。没有错误,什么都没有。
有人能看出我遗漏了什么吗?
好的,不确定为什么会有所不同,但我修复了它(我想我需要发泄和 post 这个问题)。无论如何,我希望这对处于这种情况的其他人有所帮助:
将以下行添加到脚本末尾:
$Set=Set-AzureRmLoadBalancer -LoadBalancer $lb
所以整个事情看起来像:
# Variables
$rg='ResourceGroupName'
$location='west us'
$lb=Get-AzureRmLoadBalancer -Name LBName -ResourceGroupName $rg
$FEConfig=get-AzureRmLoadBalancerFrontendIpConfig -Name FEPoolName -LoadBalancer $lb
$fec=Get-AzureRmLoadBalancerFrontendIpConfig -Name $FEConfig.Name -LoadBalancer $lb
$BEPool=Get-AzureRmLoadBalancerBackendAddressPoolConfig -Name BEPoolName -LoadBalancer $lb
$BEP=Get-AzureRmLoadBalancerBackendAddressPoolConfig -Name $BEPool.Name -LoadBalancer $lb
$Probe=Get-AzureRmLoadBalancerProbeConfig -Name HTTP-80 -LoadBalancer $lb
$Probe1=Get-AzureRmLoadBalancerProbeConfig -Name HTTPS-443 -LoadBalancer $lb
$LBRule1=New-AzureRmLoadBalancerRuleConfig -Name APP-HTTP80 -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 80 -BackendPort 80 -EnableFloatingIP
$LBRule2=New-AzureRmLoadBalancerRuleConfig -Name APP-HTTP443 -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 443 -BackendPort 443 -EnableFloatingIP
# Command
$lb.LoadBalancingRules.Add($LBRule1)
$lb.LoadBalancingRules.Add($LBRule2)
$Set=Set-AzureRmLoadBalancer -LoadBalancer $lb
好吧,我很高兴我能够解决这个问题,我希望这对其他人有帮助。 :D
我已经用 Azure 负载均衡器解决这个问题好几天了,但我仍然很苦恼...:(
首先,我可以使用以下方法毫无问题地登录到 Azure:
Login-AzureRmAccount
那么,情况是这样的:
外部负载平衡器 具有唯一 Public IP 地址的多个前端池 具有唯一私有 IP 地址的多个后端池(池中有 VM) 前端和后端池匹配 1:1 LBRule1 - FrontEndPool -> BackEndPool 前后端80端口 LBRule1 - FrontEndPool -> BackEndPool 前后端443端口
现在,当尝试添加另一个 80/443 的 LBRule 时,我不能,因为它已被使用。与 Microsoft 支持人员交谈,只能通过 Powershell 完成(我也做了 enable/disable 浮动 IP)。
这是我的脚本:
# Variables
$rg='ResourceGroupName'
$location='west us'
$lb=Get-AzureRmLoadBalancer -Name LBName -ResourceGroupName $rg
$FEConfig=get-AzureRmLoadBalancerFrontendIpConfig -Name FEPoolName -LoadBalancer $lb
$fec=Get-AzureRmLoadBalancerFrontendIpConfig -Name $FEConfig.Name -LoadBalancer $lb
$BEPool=Get-AzureRmLoadBalancerBackendAddressPoolConfig -Name BEPoolName -LoadBalancer $lb
$BEP=Get-AzureRmLoadBalancerBackendAddressPoolConfig -Name $BEPool.Name -LoadBalancer $lb
$Probe=Get-AzureRmLoadBalancerProbeConfig -Name HTTP-80 -LoadBalancer $lb
$Probe1=Get-AzureRmLoadBalancerProbeConfig -Name HTTPS-443 -LoadBalancer $lb
$LBRule1=New-AzureRmLoadBalancerRuleConfig -Name APP-HTTP80 -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 80 -BackendPort 80 -EnableFloatingIP
$LBRule2=New-AzureRmLoadBalancerRuleConfig -Name APP-HTTP443 -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 443 -BackendPort 443 -EnableFloatingIP
# Command
$lb.LoadBalancingRules.Add($LBRule1)
$lb.LoadBalancingRules.Add($LBRule2)
现在,当我 运行 这个时,没有任何反应。如果你使用 Powershell ISE 来玩这个,你会看到变量会返回正确的信息,但是在资源管理器中看,没有创建新的池。
所以,我做了一些研究并使用上面的相同变量集,我把它们放在一起:
New-AzureRmLoadBalancerRuleConfig -Name $FEConfig.Name -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 80 -BackendPort 80 -EnableFloatingIP
这做同样的事情,没有。没有错误,什么都没有。
有人能看出我遗漏了什么吗?
好的,不确定为什么会有所不同,但我修复了它(我想我需要发泄和 post 这个问题)。无论如何,我希望这对处于这种情况的其他人有所帮助:
将以下行添加到脚本末尾:
$Set=Set-AzureRmLoadBalancer -LoadBalancer $lb
所以整个事情看起来像:
# Variables
$rg='ResourceGroupName'
$location='west us'
$lb=Get-AzureRmLoadBalancer -Name LBName -ResourceGroupName $rg
$FEConfig=get-AzureRmLoadBalancerFrontendIpConfig -Name FEPoolName -LoadBalancer $lb
$fec=Get-AzureRmLoadBalancerFrontendIpConfig -Name $FEConfig.Name -LoadBalancer $lb
$BEPool=Get-AzureRmLoadBalancerBackendAddressPoolConfig -Name BEPoolName -LoadBalancer $lb
$BEP=Get-AzureRmLoadBalancerBackendAddressPoolConfig -Name $BEPool.Name -LoadBalancer $lb
$Probe=Get-AzureRmLoadBalancerProbeConfig -Name HTTP-80 -LoadBalancer $lb
$Probe1=Get-AzureRmLoadBalancerProbeConfig -Name HTTPS-443 -LoadBalancer $lb
$LBRule1=New-AzureRmLoadBalancerRuleConfig -Name APP-HTTP80 -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 80 -BackendPort 80 -EnableFloatingIP
$LBRule2=New-AzureRmLoadBalancerRuleConfig -Name APP-HTTP443 -FrontendIpConfigurationId $fec.Id -BackendAddressPoolId $BEP.Id -ProbeId $Probe.Id -Protocol Tcp -FrontendPort 443 -BackendPort 443 -EnableFloatingIP
# Command
$lb.LoadBalancingRules.Add($LBRule1)
$lb.LoadBalancingRules.Add($LBRule2)
$Set=Set-AzureRmLoadBalancer -LoadBalancer $lb
好吧,我很高兴我能够解决这个问题,我希望这对其他人有帮助。 :D