Microsoft/Azure
하나의 VM을 여러 Application Gateway의 Backend Pool에 추가(PowerShell)
megapain
2021. 8. 6. 16:35
하나의 VM을 여러 Application Gateway의 Backend Pool에 추가하는 PowerShell Script입니다.
VM NIC의 ApplicationGatewayBackendAddressPools에 Application Gateway의 BackendPool을 추가하는 방식입니다.
$appgw1 = Get-AzApplicationGateway -ResourceGroupName $APPGWRG1 -Name $APPGWNAME1
$backendPool1 = Get-AzApplicationGatewayBackendAddressPool -Name $BACKENDPOOLNAME1 -ApplicationGateway $appgw1
$appgw2 = Get-AzApplicationGateway -ResourceGroupName $APPGWRG2 -Name $APPGWNAME2
$backendPool2 = Get-AzApplicationGatewayBackendAddressPool -Name $BACKENDPOOLNAME2 -ApplicationGateway $appgw2
$vm = Get-AzVM -ResourceGroupName $VMRG -Name $VMNAME
$nic = Get-AzNetworkInterface -ResourceId $vm.NetworkProfile.NetworkInterfaces[0].Id
$nic.IpConfigurations[0].ApplicationGatewayBackendAddressPools.Add($backendpool1)
$nic.IpConfigurations[0].ApplicationGatewayBackendAddressPools.Add($backendpool2)
$nic | set-AzNetworkInterface