Skip to content

Commit 6cecf64

Browse files
authored
Add RemoteBgpCommunities property to the VirtualNetworkPeering resource (#12370)
* Skip test due to Auxilary '1' authentication error.
1 parent 5d8291a commit 6cecf64

File tree

5 files changed

+57
-18
lines changed

5 files changed

+57
-18
lines changed

src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public void TestVirtualNetworkSubnetCRUD()
5050
TestRunner.RunTestScript("Test-subnetCRUD");
5151
}
5252

53-
[Fact]
54-
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
[Fact(Skip = "Authentication failed for auxiliary token: The '1' auxiliary tokens contains duplicates which are from the same tenant.")]
54+
[Trait(Category.AcceptanceType, Category.LiveOnly)]
5555
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
5656
public void TestVirtualNetworkBgpCommunitiesCRUD()
5757
{

src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.ps1

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ function Test-bgpCommunitiesCRUD
211211
{
212212
# Setup
213213
$rgname = Get-ResourceGroupName
214-
$vnetName = Get-ResourceName
214+
$vnet1Name = Get-ResourceName
215+
$vnet2Name = Get-ResourceName
216+
$peering1Name = Get-ResourceName
217+
$peering2Name = Get-ResourceName
215218
$rglocation = Get-ProviderLocation ResourceManagement
216219
$resourceTypeParent = "Microsoft.Network/virtualNetworks"
217220
$location = Get-ProviderLocation $resourceTypeParent "eastus2euap"
@@ -221,20 +224,37 @@ function Test-bgpCommunitiesCRUD
221224
# Create the resource group
222225
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
223226

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
238258
}
239259
finally
240260
{

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
--->
2020

2121
## Upcoming Release
22+
* Added RemoteBgpCommunities property to the VirtualNetwork Peering Resource
2223
* Fixed parameters swap in VWan HubVnet connection
2324
* Added new cmdlets for Azure Network Virtual Appliance Sites
2425
- `Get-AzVirtualApplianceSite`

src/Network/Network/Models/PSVirtualNetworkPeering.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public class PSVirtualNetworkPeering : PSChildResource
5656
[JsonProperty(Order = 1)]
5757
public PSAddressSpace RemoteVirtualNetworkAddressSpace { get; set; }
5858

59+
[JsonProperty(Order = 1)]
60+
public PSVirtualNetworkBgpCommunities RemoteBgpCommunities { get; set; }
61+
5962
[JsonProperty(Order = 1)]
6063
[Ps1Xml(Target = ViewControl.Table)]
6164
public string ProvisioningState { get; set; }
@@ -76,6 +79,12 @@ public string RemoteGatewaysText
7679
public string RemoteVirtualNetworkAddressSpaceText
7780
{
7881
get { return JsonConvert.SerializeObject(RemoteVirtualNetworkAddressSpace, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
79-
}
82+
}
83+
84+
[JsonIgnore]
85+
public string RemoteBgpCommunitiesText
86+
{
87+
get { return JsonConvert.SerializeObject(RemoteBgpCommunities, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
88+
}
8089
}
8190
}

src/Network/Network/Network.format.ps1xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,15 @@
13751375
<Label>RemoteVirtualNetworkAddressSpace</Label>
13761376
<PropertyName>RemoteVirtualNetworkAddressSpaceText</PropertyName>
13771377
</ListItem>
1378+
<ListItem>
1379+
<Label>RemoteBgpCommunities</Label>
1380+
<PropertyName>RemoteBgpCommunitiesText</PropertyName>
1381+
<ItemSelectionCondition>
1382+
<ScriptBlock>
1383+
!($_.RemoteBgpCommunities -eq $null)
1384+
</ScriptBlock>
1385+
</ItemSelectionCondition>
1386+
</ListItem>
13781387
</ListItems>
13791388
</ListEntry>
13801389
</ListEntries>

0 commit comments

Comments
 (0)