Skip to content

Add RemoteBgpCommunities property to the VirtualNetworkPeering resource #12370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public void TestVirtualNetworkSubnetCRUD()
TestRunner.RunTestScript("Test-subnetCRUD");
}

Copy link
Contributor Author

@jarango jarango Jul 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test has to be "skipped" because any test that uses the "Add-AzVirtualNetworkPeering" commandlet throws the following authentication error message:

"Authentication failed for auxiliary token: The '1' auxiliary tokens contains duplicates which are from the same tenant."

The only other test case that uses this commandlet is TestVirtualNetworkPeeringCRUD() and it is also marked as "skip" for the same reason.

I created a PS1 file with the exact same contents of this test and it passes when I execute it from a PowerShell console. So I can vouch for the correctness of the test and the corresponding powershell changes.

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Fact(Skip = "Authentication failed for auxiliary token: The '1' auxiliary tokens contains duplicates which are from the same tenant.")]
[Trait(Category.AcceptanceType, Category.LiveOnly)]
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
public void TestVirtualNetworkBgpCommunitiesCRUD()
{
Expand Down
50 changes: 35 additions & 15 deletions src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ function Test-bgpCommunitiesCRUD
{
# Setup
$rgname = Get-ResourceGroupName
$vnetName = Get-ResourceName
$vnet1Name = Get-ResourceName
$vnet2Name = Get-ResourceName
$peering1Name = Get-ResourceName
$peering2Name = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/virtualNetworks"
$location = Get-ProviderLocation $resourceTypeParent "eastus2euap"
Expand All @@ -221,20 +224,37 @@ function Test-bgpCommunitiesCRUD
# Create the resource group
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }

# Create q virtual network with a BGP community
New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -BgpCommunity 12076:30000

# Get the virtual network and verify that the community is set to the expected value
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname
Assert-AreEqual "12076:30000" $vnet.BgpCommunities.VirtualNetworkCommunity

# Update the virtual network with a different BGP community
$vnet.BgpCommunities.VirtualNetworkCommunity = "12076:30001"
$vnet | Set-AzVirtualNetwork

# Get the virtual network and verify that the community is set to the new value
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname
Assert-AreEqual "12076:30001" $vnet.BgpCommunities.VirtualNetworkCommunity
# Create two virtual networks with BGP communities
New-AzVirtualNetwork -Name $vnet1Name -ResourceGroupName $rgname -Location $location -AddressPrefix 10.1.0.0/16 -BgpCommunity 12076:20001
New-AzVirtualNetwork -Name $vnet2Name -ResourceGroupName $rgname -Location $location -AddressPrefix 10.2.0.0/16 -BgpCommunity 12076:20002

# Perform GET operations to retrieve both virtual networks and verify that the VirtualNetworkCommunity is set to the expected value
$vnet1 = Get-AzVirtualNetwork -Name $vnet1Name -ResourceGroupName $rgname
$vnet2 = Get-AzVirtualNetwork -Name $vnet2Name -ResourceGroupName $rgname
Assert-AreEqual "12076:20001" $vnet1.BgpCommunities.VirtualNetworkCommunity
Assert-AreEqual "12076:20002" $vnet2.BgpCommunities.VirtualNetworkCommunity

# Update the VirtualNetworkCommunity on both virtual networks
$vnet1.BgpCommunities.VirtualNetworkCommunity = "12076:20111"
$vnet2.BgpCommunities.VirtualNetworkCommunity = "12076:20222"
$vnet1 | Set-AzVirtualNetwork
$vnet2 | Set-AzVirtualNetwork

# Perform GET operations to retrieve both virtual networks and verify that the VirtualNetworkCommunity is set to the expected value
$vnet1 = Get-AzVirtualNetwork -Name $vnet1Name -ResourceGroupName $rgname
$vnet2 = Get-AzVirtualNetwork -Name $vnet2Name -ResourceGroupName $rgname
Assert-AreEqual "12076:20111" $vnet1.BgpCommunities.VirtualNetworkCommunity
Assert-AreEqual "12076:20222" $vnet2.BgpCommunities.VirtualNetworkCommunity

# Peer both virtual networks
Add-AzVirtualNetworkPeering -Name $peering1Name -VirtualNetwork $vnet1 -RemoteVirtualNetworkId $vnet2.Id
Add-AzVirtualNetworkPeering -Name $peering2Name -VirtualNetwork $vnet2 -RemoteVirtualNetworkId $vnet1.Id

# Perform GET operations to retrieve both virtual networks and validate the RemoteBgpCommunity property on the child peering resource
$vnet1 = Get-AzVirtualNetwork -Name $vnet1Name -ResourceGroupName $rgname
$vnet2 = Get-AzVirtualNetwork -Name $vnet2Name -ResourceGroupName $rgname
Assert-AreEqual "12076:20222" $vnet1.VirtualNetworkPeerings[0].RemoteBgpCommunities.VirtualNetworkCommunity
Assert-AreEqual "12076:20111" $vnet2.VirtualNetworkPeerings[0].RemoteBgpCommunities.VirtualNetworkCommunity
}
finally
{
Expand Down
1 change: 1 addition & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
--->

## Upcoming Release
* Added RemoteBgpCommunities property to the VirtualNetwork Peering Resource
* Fixed parameters swap in VWan HubVnet connection
* Added new cmdlets for Azure Network Virtual Appliance Sites
- `Get-AzVirtualApplianceSite`
Expand Down
11 changes: 10 additions & 1 deletion src/Network/Network/Models/PSVirtualNetworkPeering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class PSVirtualNetworkPeering : PSChildResource
[JsonProperty(Order = 1)]
public PSAddressSpace RemoteVirtualNetworkAddressSpace { get; set; }

[JsonProperty(Order = 1)]
public PSVirtualNetworkBgpCommunities RemoteBgpCommunities { get; set; }

[JsonProperty(Order = 1)]
[Ps1Xml(Target = ViewControl.Table)]
public string ProvisioningState { get; set; }
Expand All @@ -76,6 +79,12 @@ public string RemoteGatewaysText
public string RemoteVirtualNetworkAddressSpaceText
{
get { return JsonConvert.SerializeObject(RemoteVirtualNetworkAddressSpace, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}
}

[JsonIgnore]
public string RemoteBgpCommunitiesText
{
get { return JsonConvert.SerializeObject(RemoteBgpCommunities, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}
}
}
9 changes: 9 additions & 0 deletions src/Network/Network/Network.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,15 @@
<Label>RemoteVirtualNetworkAddressSpace</Label>
<PropertyName>RemoteVirtualNetworkAddressSpaceText</PropertyName>
</ListItem>
<ListItem>
<Label>RemoteBgpCommunities</Label>
<PropertyName>RemoteBgpCommunitiesText</PropertyName>
<ItemSelectionCondition>
<ScriptBlock>
!($_.RemoteBgpCommunities -eq $null)
</ScriptBlock>
</ItemSelectionCondition>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
Expand Down