Sunil Katke
Sunil Katke

Reputation: 3

How do i create Azure application gateway using Powershell -Multiple BackendPool

https://learn.microsoft.com/en-us/azure/application-gateway/tutorial-ssl-powershell

Hi All,

Using above link I'm able to create an application gateway with one Backend pool, with one Http settings, with one listener and with one rule.

But when it comes to Multiple Backend Pool, multiple Http settings, multiple listeners, multiple rules?

How do I define multiple Backend Pools, http settings, listeners and rules while creating Azure application gateway using PowerShell?

Upvotes: 0

Views: 1071

Answers (1)

RamaraoAdapa
RamaraoAdapa

Reputation: 3119

I have tested in my environment.

You can define multiple Backend Pools, http settings, listeners and rules while creating Azure application gateway using PowerShell

For defining multiple front end ports, use below command :

$frontendport1 = New-AzApplicationGatewayFrontendPort -Name FrontendPort1 -Port portnumber
$frontendport2 = New-AzApplicationGatewayFrontendPort -Name FrontendPort2 -Port portnumber

For defining multiple backend pools, use below command :

$backendPool1 = New-AzApplicationGatewayBackendAddressPool -Name AGBackendPool1
$backendPool2 = New-AzApplicationGatewayBackendAddressPool -Name AGBackendPool2

For defining multiple poolsettings, use below command :

$poolSettings1 = New-AzApplicationGatewayBackendHttpSetting -Name myPoolSettings1 -Port portnumber  -Protocol Http -CookieBasedAffinity Enabled -RequestTimeout 30
$poolSettings2 = New-AzApplicationGatewayBackendHttpSetting -Name myPoolSettings2 -Port portnumber  -Protocol Http -CookieBasedAffinity Enabled -RequestTimeout 30

For defining multiple listeners, use below command :

$defaultlistener1 = New-AzApplicationGatewayHttpListener -Name AGListener1 -Protocol Http -FrontendIPConfiguration $fipconfig -FrontendPort $frontendport1
$defaultlistener2 = New-AzApplicationGatewayHttpListener -Name AGListener2 -Protocol Http -FrontendIPConfiguration $fipconfig -FrontendPort $frontendport2

For defining multiple rules, use below command :

$frontendRule1 = New-AzApplicationGatewayRequestRoutingRule -Name rule1 -RuleType Basic -HttpListener $defaultlistener1 -BackendAddressPool $backendPool1 -BackendHttpSettings $poolSettings1
$frontendRule2 = New-AzApplicationGatewayRequestRoutingRule -Name rule2 -RuleType Basic -HttpListener $defaultlistener2 -BackendAddressPool $backendPool2 -BackendHttpSettings $poolSettings2

Now you can define this multiple Backend Pools, http settings, listeners and rules while creating Azure application gateway.

You can use below command to create Azure Application Gateway :

New-AzApplicationGateway -Name AppGatewayName -ResourceGroupName RGName -Location westus2 -BackendAddressPools $backendPool1, $backendPool2 -BackendHttpSettingsCollection $poolSettings1, $poolSettings2 -FrontendIpConfigurations $fipconfig -GatewayIpConfigurations $gipconfig -FrontendPorts $frontendport1, $frontendport2 -HttpListeners $defaultlistener1, $defaultlistener2 -RequestRoutingRules $frontendRule1, $frontendRule2 -Sku $sku

enter image description here

Upvotes: 1

Related Questions