Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ public void VirtualNetworkGatewayRouteApiTest()
TestRunner.RunTestScript("Test-VirtualNetworkGatewayBgpRouteApi");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.brooklynft_subset3)]
public void VirtualNetworkGatewayEffectiveRouteApiTest()
{
TestRunner.RunTestScript("Test-VirtualNetworkGatewayEffectiveRouteApi");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.brooklynft_subset3)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,54 @@ function Test-VirtualNetworkGatewayBgpRouteApi
}
}

<#
.SYNOPSIS
Virtual network gateway effective route API test
#>
function Test-VirtualNetworkGatewayEffectiveRouteApi
{
# Setup
$rgname = Get-ResourceGroupName
$gwname = Get-ResourceName
$domainNameLabel = Get-ResourceName
$vnetName = Get-ResourceName
$publicIpName = Get-ResourceName
$vnetGatewayConfigName = Get-ResourceName
$rgLocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/virtualNetworkGateways"
$location = Get-ProviderLocation $resourceTypeParent

try
{
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation
$subnet = New-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix 10.0.0.0/24
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname
$subnet = Get-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel
$vnetIpConfig = New-AzVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet
$gw = New-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $gwname -location $location -IpConfigurations $vnetIpConfig -GatewayType Vpn -VpnType RouteBased -GatewaySku Standard
$gw = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $gwname

$job = Get-AzVirtualNetworkGatewayEffectiveRoute -ResourceGroupName $rgname -VirtualNetworkGatewayName $gwname -AsJob
$job | Wait-Job
$effectiveRoutes = $job | Receive-Job

if($effectiveRoutes -and $effectiveRoutes.Length -gt 0)
{
forEach($route in $effectiveRoutes)
{
Assert-NotNull $route.LocalAddress "LocalAddress should not be null"
Assert-NotNull $route.NextHopType "NextHopType should not be null"
}
}
}
finally
{
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Virtual network gateway P2S API test
Expand Down
1 change: 1 addition & 0 deletions src/Network/Network/Az.Network.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
'Get-AzVirtualNetworkGateway',
'Get-AzVirtualNetworkGatewayAdvertisedRoute',
'Get-AzVirtualNetworkGatewayBGPPeerStatus',
'Get-AzVirtualNetworkGatewayEffectiveRoute',
'Get-AzVirtualNetworkGatewayConnection',
'Get-AzVirtualNetworkGatewayConnectionIkeSa',
'Get-AzVirtualNetworkGatewayConnectionSharedKey',
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 new cmdlet `Get-AzVirtualNetworkGatewayEffectiveRoute` to retrieve effective routes for a Virtual Network Gateway

## Version 7.25.1
* Onboarded `Microsoft.DataReplication/replicationVaults` to Private Link Common Cmdlets
Expand Down
2 changes: 2 additions & 0 deletions src/Network/Network/Common/NetworkResourceManagerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,7 @@ private static void Initialize()
});
cfg.CreateMap<CNM.PSBGPPeerStatus, MNM.BgpPeerStatus>();
cfg.CreateMap<CNM.PSGatewayRoute, MNM.GatewayRoute>();
cfg.CreateMap<CNM.PSGatewayEffectiveRoute, MNM.GatewayEffectiveRoute>();
cfg.CreateMap<CNM.PSVpnClientConnectionHealthDetail, MNM.VpnClientConnectionHealthDetail>()
.ForMember(
dest => dest.PublicIPAddress,
Expand Down Expand Up @@ -1394,6 +1395,7 @@ private static void Initialize()
cfg.CreateMap<MNM.BgpSettings, CNM.PSBgpSettings>();
cfg.CreateMap<MNM.BgpPeerStatus, CNM.PSBGPPeerStatus>();
cfg.CreateMap<MNM.GatewayRoute, CNM.PSGatewayRoute>();
cfg.CreateMap<MNM.GatewayEffectiveRoute, CNM.PSGatewayEffectiveRoute>();
cfg.CreateMap<MNM.VpnClientConnectionHealthDetail, CNM.PSVpnClientConnectionHealthDetail>()
.ForMember(
dest => dest.PublicIpAddress,
Expand Down
38 changes: 38 additions & 0 deletions src/Network/Network/Generated/Models/PSGatewayEffectiveRoute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.Common.Attributes;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.Network.Models
{
public partial class PSGatewayEffectiveRoute
{
[Ps1Xml(Target = ViewControl.Table)]
public string LocalAddress { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public List<string> AddressPrefixes { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public string NextHopIpAddress { get; set; }

/// <summary>
/// Gets or sets the next hop type. Possible values include: 'Tunnel', 'VirtualNetwork'.
/// </summary>
[Ps1Xml(Target = ViewControl.Table)]
public string NextHopType { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using AutoMapper;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Network;
using System.Collections.Generic;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualNetworkGatewayEffectiveRoute"), OutputType(typeof(PSGatewayEffectiveRoute))]
public class GetVirtualNetworkGatewayEffectiveRouteCommand : VirtualNetworkGatewayBaseCmdlet
{
[Alias("ResourceName")]
[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Virtual network gateway name")]
[ResourceNameCompleter("Microsoft.Network/virtualNetworkGateways", "ResourceGroupName")]
[ValidateNotNullOrEmpty]
public virtual string VirtualNetworkGatewayName { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Virtual network gateway resource group's name")]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty]
public virtual string ResourceGroupName { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

public override void Execute()
{
base.Execute();

List<PSGatewayEffectiveRoute> effectiveRoutes = new List<PSGatewayEffectiveRoute>();
foreach (var route in this.VirtualNetworkGatewayClient.GetEffectiveRoutes(this.ResourceGroupName, this.VirtualNetworkGatewayName).Value)
{
effectiveRoutes.Add(NetworkResourceManagerProfile.Mapper.Map<PSGatewayEffectiveRoute>(route));
}

WriteObject(effectiveRoutes, true);
}
}
}
Loading