@@ -781,6 +781,72 @@ function Test-CortexExpressRouteCRUD
781
781
$delete = Remove-AzVirtualWan - InputObject $virtualWan - Force - PassThru
782
782
Assert-AreEqual $True $delete
783
783
784
+ Clean - ResourceGroup $rgname
785
+ }
786
+ }
787
+
788
+ <#
789
+ . SYNOPSIS
790
+ Disconnect site to site vpn gateway BgpSettings
791
+ #>
792
+ function Test-BgpUpdateVpnGateway
793
+ {
794
+ param
795
+ (
796
+ $basedir = " .\"
797
+ )
798
+
799
+ # Setup
800
+ $rgname = Get-ResourceGroupName
801
+ $rglocation = " West Central US"
802
+
803
+ $virtualWanName = Get-ResourceName
804
+ $virtualHubName = Get-ResourceName
805
+ $VpnGatewayName = Get-ResourceName
806
+
807
+ try
808
+ {
809
+ # Create the resource group
810
+ New-AzResourceGroup - Name $rgname - Location $rglocation
811
+
812
+ # Create the Virtual Wan
813
+ New-AzVirtualWan - ResourceGroupName $rgName - Name $virtualWanName - Location $rglocation
814
+ $virtualWan = Get-AzVirtualWan - ResourceGroupName $rgName - Name $virtualWanName
815
+ Assert-AreEqual $virtualWanName $virtualWan.Name
816
+
817
+ # Create the Virtual Hub
818
+ New-AzVirtualHub - ResourceGroupName $rgName - Name $virtualHubName - Location $rglocation - AddressPrefix " 192.168.1.0/24" - VirtualWan $virtualWan
819
+ $virtualHub = Get-AzVirtualHub - ResourceGroupName $rgName - Name $virtualHubName
820
+ Assert-AreEqual $virtualHubName $virtualHub.Name
821
+ Assert-AreEqual $virtualWan.Id $virtualhub.VirtualWan.Id
822
+
823
+ # Create the VpnGateway
824
+ $createdVpnGateway = New-AzVpnGateway - ResourceGroupName $rgName - Name $vpnGatewayName - VirtualHub $virtualHub - VpnGatewayScaleUnit 2
825
+
826
+ # Get the created VpnGateway using Get-AzVpnGateway
827
+ $vpnGateway = Get-AzVpnGateway - ResourceGroupName $rgName - Name $vpnGatewayName
828
+
829
+ $addr1 = New-AzIpConfigurationBgpPeeringAddressObject - IpConfigurationId $vpnGateway.BgpSettings.BgpPeeringAddresses [0 ].IpConfigurationId - CustomAddress @ (" 169.254.22.5" )
830
+ $addr2 = New-AzIpConfigurationBgpPeeringAddressObject - IpConfigurationId $vpnGateway.BgpSettings.BgpPeeringAddresses [1 ].IpConfigurationId - CustomAddress @ (" 169.254.22.10" )
831
+ $createdVpnGateway = Update-AzVpnGateway - ResourceGroupName $rgName - Name $vpnGatewayName - BgpPeeringAddress @ ($addr1 , $addr2 )
832
+ $updatedvpnGateway = Get-AzVpnGateway - ResourceGroupName $rgName - Name $vpnGatewayName
833
+ Assert-AreEqual 1 @ ($updatedvpnGateway.BgpSettings.BGPPeeringAddresses [0 ]).Count
834
+ Assert-AreEqual 1 @ ($updatedvpnGateway.BgpSettings.BGPPeeringAddresses [1 ]).Count
835
+ }
836
+ finally
837
+ {
838
+ # Delete VpnGateway using Remove-AzVpnGateway
839
+ $delete = Remove-AzVpnGateway - Name $VpnGatewayName - ResourceGroupName $rgName - Force - PassThru
840
+ Assert-AreEqual $True $delete
841
+
842
+ # Delete Virtual hub
843
+ $delete = Remove-AzVirtualHub - ResourceGroupName $rgname - Name $virtualHubName - Force - PassThru
844
+ Assert-AreEqual $True $delete
845
+
846
+ # Delete Virtual wan
847
+ $delete = Remove-AzVirtualWan - InputObject $virtualWan - Force - PassThru
848
+ Assert-AreEqual $True $delete
849
+
784
850
Clean - ResourceGroup $rgname
785
851
}
786
852
}
0 commit comments