Azure CLI - Set Azure Application Gateway Backend settings

856 Views Asked by At

I have created a Powershell script that calls the Az module..."az network application-gateway probe create" - https://learn.microsoft.com/en-us/cli/azure/network/application-gateway/probe?view=azure-cli-latest#az-network-application-gateway-probe-create

I have read the documentation on the above command but can't work out how to set 'backend settings' - the field marked below by the black line as shown below - any thoughts?

enter image description here

The 'Backend Settings' field is a drop-down box that does list the 'http settings' I want to set the value to - remember I want to do this via; ARM or CLI not manually via the Azure Portal..

enter image description here

1

There are 1 best solutions below

0
Rukmini On BEST ANSWER

I tried to reproduce the same in my environment and got the results successfully like below:

To create the Probe and associated Backend settings, I used the below command while creating probe via CLI:

$probe = New-AzApplicationGatewayProbeConfig -Name probe01 -Protocol Http -HostName 'XXX.com' -Path '/path/path.htm' -Interval 30 -Timeout 120 -UnhealthyThreshold 8

$poolSetting = New-AzApplicationGatewayBackendHttpSettings -Name poolsetting01 -Port  80 -Protocol Http -CookieBasedAffinity Disabled -Probe  $probe -RequestTimeout  80

enter image description here

I created the application gateway with all the required parameters like below:

$appgw = New-AzApplicationGateway -Name appgwtest -ResourceGroupName  appgw-rg -Location  'West US' -BackendAddressPools  $pool -Probes  $probe -BackendHttpSettingsCollection  $poolSetting -FrontendIpConfigurations  $fipconfig  -GatewayIpConfigurations  $gipconfig -FrontendPorts  $fp -HttpListeners  $listener -RequestRoutingRules  $rule -Sku  $sku

In the Portal, Application Gateway created successfully with Backend settings like below:

enter image description here

To add a new probe to an existing application gateway and set Backend Settings, please use the below commands:

$appgw =  Get-AzApplicationGateway -Name applicationgatewayname -ResourceGroupName ResourceGroupName

$probe = Add-AzApplicationGatewayProbeConfig -ApplicationGateway $appgw -Name probetest -Protocol Http -HostName 'XXX.com' -Path '/path/custompath.htm' -Interval 30 -Timeout 120 -UnhealthyThreshold 8

$appgw = Set-AzApplicationGatewayBackendHttpSettings -ApplicationGateway $appgw -Name $appgw.BackendHttpSettingsCollection.name -Port 80 -Protocol Http -CookieBasedAffinity Disabled -Probe $probe -RequestTimeout 120

Set-AzApplicationGateway -ApplicationGateway $appgw