Skip to content

Instantly share code, notes, and snippets.

@CoditCompany
Last active November 16, 2017 17:46
Show Gist options
  • Select an option

  • Save CoditCompany/e41da52e460a3ffb40724aef024003df to your computer and use it in GitHub Desktop.

Select an option

Save CoditCompany/e41da52e460a3ffb40724aef024003df to your computer and use it in GitHub Desktop.
Function Add-LoadBalancerRulesForSSO {
param(
[string]$subscriptionId,
[string]$clusterResourceGroupName,
[string]$loadBalancerName,
[string]$LoadbalancerFrontEndName,
[int]$startport,
[int]$endport
)
$loadbalancer = Get-AzureRmLoadBalancer -Name $LoadBalancerName -ResourceGroupName $ClusterResourceGroupName
$FrontEndConfig = Get-AzureRmLoadBalancerFrontendIpConfig -LoadBalancer $loadbalancer -Name $LoadbalancerFrontEndName
$BackendPool = $Loadbalancer | Get-AzureRmLoadBalancerBackendAddressPoolConfig
$Probe = Get-AzureRmLoadBalancerProbeConfig -LoadBalancer $loadbalancer -Name "$LoadbalancerFrontEndName-probe"
$count = $startport
while ($count -ne $endport ) {
$loadbalancer | Add-AzureRmLoadBalancerRuleConfig -Name "$LoadbalancerFrontEndName-rule_$count" -FrontendIpConfiguration $FrontendConfig -BackendAddressPool $BackendPool -Probe $Probe -Protocol TCP -FrontendPort $count -BackendPort $count
$loadbalancer | Set-AzureRmLoadBalancer
$count++
}
}
#Example usage:
#Login to your Azure account
Add-AzureRmAccount
$vars = @{
subscriptionId = '1234-5678-910' #your subscriptionId
clusterResourceGroupName = 'biztalk-sql-cluster-rg' #the resource group that contains your load balancer
loadBalancerName = 'SqlIlb' #the name of the load balancer
LoadbalancerFrontEndName = 'LB-Frontend-SSO'
startPort = 20000
endPort = 20022
}
Add-LoadBalancerRulesForSSO $vars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment