Microsoft/Azure

Azure VMSS의 Load Balancer를 Application Gateway로 변경

megapain 2020. 12. 10. 20:43

참고 자료

 

Azure VMSS의 Load Balancer를 Application Gateway로 변경하는 방법과 반대로 Application Gateway를 Load Balancer로 변경하는 방법입니다.

생각보다 간단한데, 자료를 찾기가 어려웠습니다.

 

Azure VMSS의 Load Balancer를 Application Gataeway로 변경

# Get the current model of the scale set and store it in a local PowerShell object named $vmss
$vmss=Get-AzVmss -ResourceGroupName "myResourceGroup" -Name "myScaleSet"

# Create a local PowerShell object for the new desired IP configuration, which includes the reference to the application gateway
$ipconf = New-AzVmssIPConfig "myNic" -ApplicationGatewayBackendAddressPoolsId /subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/backendAddressPools/{applicationGatewayBackendAddressPoolName} -SubnetId $vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0].Subnet.Id –Name $vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0].Name

# Replace the existing IP configuration in the local PowerShell object (which contains the references to the current Azure Load Balancer) with the new IP configuration
$vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0] = $ipconf

# Update the model of the scale set with the new configuration in the local PowerShell object
Update-AzVmss -ResourceGroupName "myResourceGroup" -Name "myScaleSet" -virtualMachineScaleSet $vmss

 

Azure VMSS의 Application Gateway를 Load Balancer로 변경

# Create a local PowerShell object for the new desired IP configuration, which includes the reference to the application gateway
$ipconf = New-AzVmssIPConfig "myNic2" -LoadBalancerBackendAddressPoolsId /subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{loadBalancerBackendPoolName} -SubnetId $vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0].Subnet.Id –Name $vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0].Name

# Replace the existing IP configuration in the local PowerShell object (which contains the references to the current Azure Load Balancer) with the new IP configuration
$vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0] = $ipconf

# Update the model of the scale set with the new configuration in the local PowerShell object
Update-AzVmss -ResourceGroupName "myResourceGroup" -Name "myScaleSet" -virtualMachineScaleSet $vmss

 

아래는 Cloud shell에서 VMSS의 Applicaton Gateway를 Load Balancer로 변경하는 화면 캡처입니다. 

Cloud shell에서 명령 실행

 

위 명령을 실행하고 난 후, VMSS에서 인스턴스를 업그레이드(Upgrade) 해야 실제로 반영됩니다.

VMSS instance upgrade

 

-끝-