@@ -1803,3 +1803,78 @@ function Test-VpnSiteLinkConnectionGetIkeSa
1803
1803
Clean - ResourceGroup $rgname
1804
1804
}
1805
1805
}
1806
+
1807
+ <#
1808
+ . SYNOPSIS
1809
+ Create a virtual hub and vpn gateway with custom asn and update them
1810
+ #>
1811
+ function Test-VirtualHubAndVpnGatewayWithCustomAsn
1812
+ {
1813
+ # Setup
1814
+ $rgName = Get-ResourceName
1815
+ $rglocation = Get-ProviderLocation ResourceManagement " West Central US"
1816
+ $virtualWanName = Get-ResourceName
1817
+ $virtualHubName = Get-ResourceName
1818
+ $vpnGatewayName = Get-ResourceName
1819
+
1820
+ try
1821
+ {
1822
+ # Create the resource group
1823
+ $resourceGroup = New-AzResourceGroup - Name $rgName - Location $rglocation
1824
+
1825
+ # Create the Virtual Wan
1826
+ $createdVirtualWan = New-AzVirtualWan - ResourceGroupName $rgName - Name $virtualWanName - Location $rglocation - AllowVnetToVnetTraffic - AllowBranchToBranchTraffic
1827
+ $virtualWan = Get-AzVirtualWan - ResourceGroupName $rgName - Name $virtualWanName
1828
+ Assert-AreEqual $rgName $virtualWan.ResourceGroupName
1829
+ Assert-AreEqual $virtualWanName $virtualWan.Name
1830
+ Assert-AreEqual $true $virtualWan.AllowVnetToVnetTraffic
1831
+ Assert-AreEqual $true $virtualWan.AllowBranchToBranchTraffic
1832
+
1833
+ # Create the Virtual Hub
1834
+ $createdVirtualHub = New-AzVirtualHub - ResourceGroupName $rgName - Name $virtualHubName - Location $rglocation - VirtualWan $virtualWan - AddressPrefix " 192.168.1.0/24" - VirtualRouterAsn 65000
1835
+ $virtualHub = Get-AzVirtualHub - ResourceGroupName $rgName - Name $virtualHubName
1836
+ Assert-AreEqual $rgName $virtualHub.ResourceGroupName
1837
+ Assert-AreEqual $virtualHubName $virtualHub.Name
1838
+ Assert-AreEqual " 192.168.1.0/24" $virtualHub.AddressPrefix
1839
+ Assert-AreEqual 65000 $virtualHub.VirtualRouterAsn
1840
+
1841
+ # Create the VpnGateway
1842
+ $createdVpnGateway = New-AzVpnGateway - ResourceGroupName $rgName - Name $vpnGatewayName - VirtualHub $virtualHub - VpnGatewayScaleUnit 3 - Asn 65100
1843
+ $vpnGateway = Get-AzVpnGateway - ResourceGroupName $rgName - Name $vpnGatewayName
1844
+ Assert-AreEqual $rgName $vpnGateway.ResourceGroupName
1845
+ Assert-AreEqual $vpnGatewayName $vpnGateway.Name
1846
+ Assert-AreEqual 65100 $vpnGateway.BgpSettings.Asn
1847
+
1848
+ # Update Virtual Hub
1849
+ $updatedVirtualHub = Update-AzVirtualHub - ResourceGroupName $rgName - Name $virtualHubName - VirtualRouterAsn 65001
1850
+ $virtualHub = Get-AzVirtualHub - ResourceGroupName $rgName - Name $virtualHubName
1851
+ Assert-AreEqual $rgName $virtualHub.ResourceGroupName
1852
+ Assert-AreEqual $virtualHubName $virtualHub.Name
1853
+ Assert-AreEqual 65001 $virtualHub.VirtualRouterAsn
1854
+
1855
+ # Update the VpnGateway
1856
+ $updatedVpnGateway = Update-AzVpnGateway - ResourceGroupName $rgName - Name $vpnGatewayName - Asn 65101
1857
+ $vpnGateway = Get-AzVpnGateway - ResourceGroupName $rgName - Name $vpnGatewayName
1858
+ Assert-AreEqual $rgName $vpnGateway.ResourceGroupName
1859
+ Assert-AreEqual $vpnGatewayName $vpnGateway.Name
1860
+ Assert-AreEqual 65101 $vpnGateway.BgpSettings.Asn
1861
+
1862
+ # Delete Vpn Gateway
1863
+ $delete = Remove-AzVpnGateway - ResourceGroupName $rgName - Name $vpnGatewayName - Force - PassThru
1864
+ Assert-AreEqual $True $delete
1865
+
1866
+ # Delete Virtual hub
1867
+ $delete = Remove-AzVirtualHub - ResourceGroupName $rgname - Name $virtualHubName - Force - PassThru
1868
+ Assert-AreEqual $True $delete
1869
+
1870
+ # Delete Virtual wan
1871
+ $delete = Remove-AzVirtualWan - InputObject $virtualWan - Force - PassThru
1872
+ Assert-AreEqual $True $delete
1873
+ }
1874
+ finally
1875
+ {
1876
+ Clean - ResourceGroup $rgname
1877
+ }
1878
+ }
1879
+
1880
+
0 commit comments