@@ -211,7 +211,10 @@ function Test-bgpCommunitiesCRUD
211
211
{
212
212
# Setup
213
213
$rgname = Get-ResourceGroupName
214
- $vnetName = Get-ResourceName
214
+ $vnet1Name = Get-ResourceName
215
+ $vnet2Name = Get-ResourceName
216
+ $peering1Name = Get-ResourceName
217
+ $peering2Name = Get-ResourceName
215
218
$rglocation = Get-ProviderLocation ResourceManagement
216
219
$resourceTypeParent = " Microsoft.Network/virtualNetworks"
217
220
$location = Get-ProviderLocation $resourceTypeParent " eastus2euap"
@@ -221,20 +224,37 @@ function Test-bgpCommunitiesCRUD
221
224
# Create the resource group
222
225
$resourceGroup = New-AzResourceGroup - Name $rgname - Location $rglocation - Tags @ { testtag = " testval" }
223
226
224
- # Create q virtual network with a BGP community
225
- New-AzVirtualNetwork - Name $vnetName - ResourceGroupName $rgname - Location $location - AddressPrefix 10.0 .0.0 / 16 - BgpCommunity 12076 :30000
226
-
227
- # Get the virtual network and verify that the community is set to the expected value
228
- $vnet = Get-AzVirtualNetwork - Name $vnetName - ResourceGroupName $rgname
229
- Assert-AreEqual " 12076:30000" $vnet.BgpCommunities.VirtualNetworkCommunity
230
-
231
- # Update the virtual network with a different BGP community
232
- $vnet.BgpCommunities.VirtualNetworkCommunity = " 12076:30001"
233
- $vnet | Set-AzVirtualNetwork
234
-
235
- # Get the virtual network and verify that the community is set to the new value
236
- $vnet = Get-AzVirtualNetwork - Name $vnetName - ResourceGroupName $rgname
237
- Assert-AreEqual " 12076:30001" $vnet.BgpCommunities.VirtualNetworkCommunity
227
+ # Create two virtual networks with BGP communities
228
+ New-AzVirtualNetwork - Name $vnet1Name - ResourceGroupName $rgname - Location $location - AddressPrefix 10.1 .0.0 / 16 - BgpCommunity 12076 :20001
229
+ New-AzVirtualNetwork - Name $vnet2Name - ResourceGroupName $rgname - Location $location - AddressPrefix 10.2 .0.0 / 16 - BgpCommunity 12076 :20002
230
+
231
+ # Perform GET operations to retrieve both virtual networks and verify that the VirtualNetworkCommunity is set to the expected value
232
+ $vnet1 = Get-AzVirtualNetwork - Name $vnet1Name - ResourceGroupName $rgname
233
+ $vnet2 = Get-AzVirtualNetwork - Name $vnet2Name - ResourceGroupName $rgname
234
+ Assert-AreEqual " 12076:20001" $vnet1.BgpCommunities.VirtualNetworkCommunity
235
+ Assert-AreEqual " 12076:20002" $vnet2.BgpCommunities.VirtualNetworkCommunity
236
+
237
+ # Update the VirtualNetworkCommunity on both virtual networks
238
+ $vnet1.BgpCommunities.VirtualNetworkCommunity = " 12076:20111"
239
+ $vnet2.BgpCommunities.VirtualNetworkCommunity = " 12076:20222"
240
+ $vnet1 | Set-AzVirtualNetwork
241
+ $vnet2 | Set-AzVirtualNetwork
242
+
243
+ # Perform GET operations to retrieve both virtual networks and verify that the VirtualNetworkCommunity is set to the expected value
244
+ $vnet1 = Get-AzVirtualNetwork - Name $vnet1Name - ResourceGroupName $rgname
245
+ $vnet2 = Get-AzVirtualNetwork - Name $vnet2Name - ResourceGroupName $rgname
246
+ Assert-AreEqual " 12076:20111" $vnet1.BgpCommunities.VirtualNetworkCommunity
247
+ Assert-AreEqual " 12076:20222" $vnet2.BgpCommunities.VirtualNetworkCommunity
248
+
249
+ # Peer both virtual networks
250
+ Add-AzVirtualNetworkPeering - Name $peering1Name - VirtualNetwork $vnet1 - RemoteVirtualNetworkId $vnet2.Id
251
+ Add-AzVirtualNetworkPeering - Name $peering2Name - VirtualNetwork $vnet2 - RemoteVirtualNetworkId $vnet1.Id
252
+
253
+ # Perform GET operations to retrieve both virtual networks and validate the RemoteBgpCommunity property on the child peering resource
254
+ $vnet1 = Get-AzVirtualNetwork - Name $vnet1Name - ResourceGroupName $rgname
255
+ $vnet2 = Get-AzVirtualNetwork - Name $vnet2Name - ResourceGroupName $rgname
256
+ Assert-AreEqual " 12076:20222" $vnet1.VirtualNetworkPeerings [0 ].RemoteBgpCommunities.VirtualNetworkCommunity
257
+ Assert-AreEqual " 12076:20111" $vnet2.VirtualNetworkPeerings [0 ].RemoteBgpCommunities.VirtualNetworkCommunity
238
258
}
239
259
finally
240
260
{
0 commit comments