Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion src/Network/Network.Test/Network.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.3.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="212.2116.33552" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
<PackageReference Include="Microsoft.Azure.Insights" Version="0.16.0-preview" />
Expand Down
2 changes: 2 additions & 0 deletions src/Network/Network.Test/ScenarioTests/CortexTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,8 @@ function Test-VpnConnectionPacketCapture

$createdVpnConnection = New-AzVpnConnection -ResourceGroupName $rgName -ParentResourceName $vpnGatewayName -Name $vpnConnectionName -VpnSite $createdVpnSite -VpnSiteLinkConnection @($vpnSiteLinkConnection1, $vpnSiteLinkConnection2)

Reset-AzVpnSiteLinkConnection -InputObject $vpnSiteLinkConnection1

#create SAS URL
if ((Get-NetworkTestMode) -ne 'Playback')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ function Test-VirtualNetworkGatewayConnectionWithActiveActiveGateway

$connection1 = Get-AzVirtualNetworkGatewayConnection -ResourceGroupName $rgname -name $vnetConnectionName1
Assert-NotNull $connection1.TunnelConnectionStatus

# Reset VirtualNetworkGatewayConnection
Reset-AzVirtualNetworkGatewayConnection -InputObject $connection1

# Delete VirtualNetworkGatewayConnections
$delete = Remove-AzVirtualNetworkGatewayConnection -ResourceGroupName $actual.ResourceGroupName -name $vnetConnectionName1 -PassThru -Force
Expand Down Expand Up @@ -859,3 +862,4 @@ function Test-VirtualNetworkGatewayConnectionGetIkeSa
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Network/Network/Az.Network.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
'Set-AzLocalNetworkGateway',
'Get-AzVirtualNetworkGatewayConnection',
'Get-AzVirtualNetworkGatewayConnectionIkeSa',
'Reset-AzVirtualNetworkGatewayConnection',
'Get-AzVirtualNetworkGatewayConnectionSharedKey',
'New-AzVirtualNetworkGatewayConnection',
'Remove-AzVirtualNetworkGatewayConnection',
Expand Down Expand Up @@ -425,6 +426,7 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
'Get-AzVpnGatewayNatRule', 'Start-AzVpnConnectionPacketCapture',
'Stop-AzVpnConnectionPacketCapture', 'New-AzVpnSite',
'New-AzVpnSiteLink', 'New-AzVpnSiteLinkConnection', 'Get-AzVpnSite',
'Reset-AzVpnSiteLinkConnection',
'Update-AzVpnSite', 'Remove-AzVpnSite', 'New-AzVpnConnection',
'Get-AzVpnConnection', 'Update-AzVpnConnection',
'Remove-AzVpnConnection', 'New-AzVirtualHubVnetConnection',
Expand Down
4 changes: 4 additions & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
- Updated New-AzVpnServerConfiguration and Update-AzVpnServerConfiguration to allow multiple authentication parameters to be set.
* Updated `New-AzVpnGateway` and `New-AzP2sVpnGateway` cmdlet:
- Added parameter EnableRoutingPreferenceInternetFlag
* Added new cmdlet to reset a Virtual Network Gateway Connection.
- `Reset-AzVirtualNetworkGatewayConnection`
* Added new cmdlet to reset a Vpn Site Link Connection.
- `Reset-VpnSiteLinkConnection`

## Version 4.4.0
* Fixed issue in remove peering and connection cmdlet for ExpressRouteCircuit scenario
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
namespace Microsoft.Azure.Commands.Network.Cortex.VpnConnection
{
using System;
using System.Management.Automation;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.Network.Models;

[Cmdlet(
VerbsCommon.Reset,
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VpnSiteLinkConnection",
DefaultParameterSetName = "ByName"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
DefaultParameterSetName = "ByName"),
DefaultParameterSetName = "ByName",
SupportsShouldProcess = true),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OutputType(typeof(void))]

public class ResetAzVpnSiteLinkConnectionCommand : VpnLinkConnectionBaseCmdlet
{
[Parameter(
ParameterSetName = "ByName",
Mandatory = true,
HelpMessage = "The resource group name.")]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

[Alias("GrandParentName")]
[Parameter(
ParameterSetName = "ByName",
Mandatory = true,
HelpMessage = "The Vpn gateway name.")]
[ResourceNameCompleter("Microsoft.Network/vpnGateways", "ResourceGroupName")]
[ValidateNotNullOrEmpty]
public string VpnGatewayName { get; set; }

[Alias("ParentName")]
[Parameter(
ParameterSetName = "ByName",
Mandatory = true,
HelpMessage = "The Vpn connection name.")]
[ResourceNameCompleter("Microsoft.Network/connections", "GrandParentResourceName")]
[ValidateNotNullOrEmpty]
public string VpnConnectionName { get; set; }

[Alias("ResourceName", "VpnSiteLinkConnectionName")]
[Parameter(
ParameterSetName = "ByName",
Mandatory = true,
HelpMessage = "The Vpn site link connection name.")]
[ResourceNameCompleter("Microsoft.Network/connections", "ParentResourceName")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Alias("VpnSiteLinkConnection")]
[Parameter(
ParameterSetName = "ByInputObject",
Mandatory = true,
ValueFromPipeline = true,
HelpMessage = "The Vpn site link connection object.")]
[ValidateNotNullOrEmpty]
public PSVpnSiteLinkConnection InputObject { get; set; }

[Parameter(
ParameterSetName = "ByResourceId",
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The Azure resource ID of the Vpn site link connection for which IKE SAs needs to be fetched.")]
[ValidateNotNullOrEmpty]
public string ResourceId { get; set; }

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

public override void Execute()
{
var parsedResourceId = new ResourceIdentifier();

if (!ParameterSetName.Equals("ByName"))
{
if (ParameterSetName.Equals("ByResourceId"))
{
parsedResourceId = new ResourceIdentifier(this.ResourceId);
}
else if (ParameterSetName.Equals("ByInputObject"))
{
parsedResourceId = new ResourceIdentifier(this.InputObject.Id);
}

this.ResourceGroupName = parsedResourceId.ResourceGroupName;
var resources = parsedResourceId.ParentResource.Split(new[] { '/' }, 4, StringSplitOptions.RemoveEmptyEntries);
this.VpnGatewayName = resources[1];
this.VpnConnectionName = resources[3];
this.Name = parsedResourceId.ResourceName;
}

base.Execute();

if (this.IsVpnConnectionPresent(this.ResourceGroupName, this.VpnGatewayName, this.VpnConnectionName))
{
this.VpnLinkConnectionClient.ResetConnection(this.ResourceGroupName, this.VpnGatewayName, this.VpnConnectionName, this.Name);
}
else
{
throw new PSArgumentException(Properties.Resources.ResourceNotFound, this.Name);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.Azure.Management.Network;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;

namespace Microsoft.Azure.Commands.Network.Cortex.VpnConnection
{
public class VpnLinkConnectionBaseCmdlet : VpnConnectionBaseCmdlet
{
public IVpnLinkConnectionsOperations VpnLinkConnectionClient
{
get
{
return NetworkClient.NetworkManagementClient.VpnLinkConnections;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Network/Network/Network.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.2.2" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.3.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="212.2116.33552" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.Network
{
using System.Collections.Generic;
using System.Management.Automation;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.Network.Models;
using Newtonsoft.Json;

[Cmdlet("Reset", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualNetworkGatewayConnection", DefaultParameterSetName = "ByName"), OutputType(typeof(void))]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
[Cmdlet("Reset", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualNetworkGatewayConnection", DefaultParameterSetName = "ByName"), OutputType(typeof(void))]
[Cmdlet("Reset", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualNetworkGatewayConnection", DefaultParameterSetName = "ByName", SupportsShouldProcess = true), OutputType(typeof(void))]

@akshatkale Akshat Kale (akshatkale) Feb 24, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

public class ResetAzVirtualNetworkGatewayConnectionCommand : VirtualNetworkGatewayConnectionBaseCmdlet
{
[Alias("ResourceName", "ConnectionName")]
[Parameter(
ParameterSetName = "ByName",
Mandatory = true,
HelpMessage = "The virtual network gateway connection name which needs to be reset.")]
[ResourceNameCompleter("Microsoft.Network/connections", "ResourceGroupName")]
[ValidateNotNullOrEmpty]
public virtual string Name { get; set; }

[Parameter(
ParameterSetName = "ByName",
Mandatory = true,
HelpMessage = "The resource group name.")]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty]
public virtual string ResourceGroupName { get; set; }

[Parameter(
ParameterSetName = "ByInputObject",
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The virtual network gateway connection object which needs to be reset.")]
[ValidateNotNullOrEmpty]
public PSVirtualNetworkGatewayConnection InputObject { get; set; }

[Parameter(
ParameterSetName = "ByResourceId",
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The Azure resource ID of the Virtual Network Gateway Connection which needs to be reset.")]
[ValidateNotNullOrEmpty]
public string ResourceId { get; set; }

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

public override void Execute()
{
if (ParameterSetName.Equals("ByInputObject"))
{
this.ResourceGroupName = this.InputObject.ResourceGroupName;
this.Name = this.InputObject.Name;
}
else
{
if (ParameterSetName.Equals("ByResourceId"))
{
var parsedResourceId = new ResourceIdentifier(ResourceId);
Name = parsedResourceId.ResourceName;
ResourceGroupName = parsedResourceId.ResourceGroupName;
}
}

base.Execute();

if (this.IsVirtualNetworkGatewayConnectionPresent(this.ResourceGroupName, this.Name))
{
this.VirtualNetworkGatewayConnectionClient.ResetConnection(this.ResourceGroupName, this.Name);
}
else
{
throw new PSArgumentException(Properties.Resources.ResourceNotFound, this.Name);
}
}
}
}
Loading