Hicki
Hicki

Reputation: 167

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.

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. I'm then using Add-AzureRmLoadBalancerRuleConfig and Set-AzureRmLoadBalancerRuleConfig as mentioned in the documentation

I can see from the PowerShell output that the rule is there. However it lacks one obvious property in comparison to those added via the portal.

"ProvisioningState": "Succeeded"

The new rule is not shown in the portal, but is visible when getting the LB via PS.

Is there a way I'm missing to ensure the rule is displayed in the azure portal? Or does the rule take much longer to be provisioned in this way?

Upvotes: 0

Views: 889

Answers (2)

4c74356b41
4c74356b41

Reputation: 72171

After you've created properties you need to apply them:

$slb | Set-AzureRmLoadBalancer

Upvotes: 3

CHEEKATLAPRADEEP
CHEEKATLAPRADEEP

Reputation: 12768

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.

Upvotes: 0

Related Questions