Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 19 additions & 5 deletions src/Network/Network.Test/ScenarioTests/CortexTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ function Test-CortexExpressRouteCRUD
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation

# Create the Virtual Wan
$createdVirtualWan = New-AzVirtualWan -ResourceGroupName $rgName -Name $virtualWanName -Location $rglocation
$createdVirtualWan = New-AzVirtualWan -ResourceGroupName $rgName -Name $virtualWanName -Location $rglocation -AllowVnetToVnetTraffic
$virtualWan = Get-AzVirtualWan -ResourceGroupName $rgName -Name $virtualWanName
Assert-AreEqual $rgName $virtualWan.ResourceGroupName
Assert-AreEqual $virtualWanName $virtualWan.Name
Expand Down Expand Up @@ -548,7 +548,10 @@ function Test-CortexExpressRouteCRUD
$vpnClientAddressSpaces = New-Object string[] 2
$vpnClientAddressSpaces[0] = "192.168.2.0/24"
$vpnClientAddressSpaces[1] = "192.168.3.0/24"
$createdP2SVpnGateway = New-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName -VirtualHub $virtualHub -VpnGatewayScaleUnit 1 -VpnClientAddressPool $vpnClientAddressSpaces -VpnServerConfiguration $vpnServerConfig1
$customDnsServers = New-Object string[] 2
$customDnsServers[0] = "7.7.7.7"
$customDnsServers[1] = "8.8.8.8"
$createdP2SVpnGateway = New-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName -VirtualHub $virtualHub -VpnGatewayScaleUnit 1 -VpnClientAddressPool $vpnClientAddressSpaces -VpnServerConfiguration $vpnServerConfig1 -CustomDnsServer $customDnsServers
Assert-AreEqual "Succeeded" $createdP2SVpnGateway.ProvisioningState

# Get the created P2SVpnGateway using Get-AzP2sVpnGateway
Expand All @@ -557,6 +560,9 @@ function Test-CortexExpressRouteCRUD
Assert-AreEqual $P2SvpnGatewayName $P2SVpnGateway.Name
Assert-AreEqual $vpnServerConfig1.Id $P2SVpnGateway.VpnServerConfiguration.Id
Assert-AreEqual "Succeeded" $P2SVpnGateway.ProvisioningState
Assert-AreEqual 2 @($P2SVpnGateway.CustomDnsServers).Count
Assert-AreEqual "7.7.7.7" $P2SVpnGateway.CustomDnsServers[0]
Assert-AreEqual "8.8.8.8" $P2SVpnGateway.CustomDnsServers[1]

# Get all associated VpnServerConfigurations at Wan level using Get-AzVirtualWanVpnServerConfiguration
$associatedVpnServerConfigs = Get-AzVirtualWanVpnServerConfiguration -Name $virtualWanName -ResourceGroupName $rgName
Expand Down Expand Up @@ -612,17 +618,25 @@ function Test-CortexExpressRouteCRUD
$VpnServerConfig2Get = Get-AzVpnServerConfiguration -ResourceGroupName $rgName -Name $VpnServerConfiguration2Name
Assert-AreEqual "TestRadiusServer3" $VpnServerConfig2Get.RadiusServerAddress

# Update existing P2SVpnGateway with new VpnClientAddressPool using Update-AzP2sVpnGateway
# Update existing P2SVpnGateway with new VpnClientAddressPool and CustomDnsServers using Update-AzP2sVpnGateway
$vpnClientAddressSpaces[1] = "192.168.4.0/24"
$updatedP2SVpnGateway = Update-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName -VpnClientAddressPool $vpnClientAddressSpaces
$updatedP2SVpnGateway = Update-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName -VpnClientAddressPool $vpnClientAddressSpaces -CustomDnsServer 9.9.9.9

$P2SVpnGateway = Get-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName
Assert-AreEqual $P2SvpnGatewayName $P2SVpnGateway.Name
Assert-AreEqual "Succeeded" $P2SVpnGateway.ProvisioningState
Assert-AreEqual $vpnServerConfig1.Id $P2SVpnGateway.VpnServerConfiguration.Id
$setVpnClientAddressSpacesString = [system.String]::Join(" ", $vpnClientAddressSpaces)
Assert-AreEqual $setVpnClientAddressSpacesString $P2SVpnGateway.P2SConnectionConfigurations[0].VpnClientAddressPool.AddressPrefixes

Assert-AreEqual 1 @($P2SVpnGateway.CustomDnsServers).Count
Assert-AreEqual "9.9.9.9" $P2SVpnGateway.CustomDnsServers[0]

# Update existing P2SVpnGateway to remove the CustomDnsServers
$P2SVpnGateway = Get-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName
Update-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName -CustomDnsServer @()
$P2SVpnGateway = Get-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName
Assert-AreEqual 0 @($P2SVpnGateway.CustomDnsServers).Count

$associatedVpnServerConfigs = Get-AzVirtualWanVpnServerConfiguration -ResourceId $virtualWan.Id
Assert-NotNull $associatedVpnServerConfigs
Assert-AreEqual 1 @($associatedVpnServerConfigs.VpnServerConfigurationResourceIds).Count
Expand Down
3 changes: 3 additions & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
* Add `EnableDnsProxy`, 'DnsProxyNotRequiredForNetworkRule' and 'DnsServer' parameters to `AzureFirewall`
- Updated cmdlet:
- New-AzFirewall
* Updated below commands for feature: Custom dns servers set/remove on VirtualWan P2SVpnGateway.
- Updated New-AzP2sVpnGateway: Added optional parameter -CustomDnsServer for customers to specify their dns servers to set on P2SVpnGateway, which can be used by Point to site clients.
- Updated Update-AzP2sVpnGateway: Added optional parameter -CustomDnsServer for customers to specify their dns servers to set on P2SVpnGateway, which can be used by Point to site clients.

## Version 2.5.0
* Updated cmdlets to enable connection on private IP for Virtual Network Gateway.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ public class NewAzureRmP2SVpnGatewayCommand : P2SVpnGatewayBaseCmdlet
[ValidateNotNullOrEmpty]
public string[] VpnClientAddressPool { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The list of Custom Dns Servers.")]
public string[] CustomDnsServer { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "A hashtable which represents resource tags.")]
Expand Down Expand Up @@ -227,6 +233,12 @@ public override void Execute()
p2sVpnGateway.VpnServerConfiguration = new PSResourceId() { Id = vpnServerConfigurationResolvedId };
p2sVpnGateway.VpnServerConfigurationLocation = string.IsNullOrWhiteSpace(this.VpnServerConfiguration.Location) ? string.Empty : this.VpnServerConfiguration.Location;

// Set the custom dns servers, if it is specified by customer.
if (CustomDnsServer != null && this.CustomDnsServer.Any())
{
p2sVpnGateway.CustomDnsServers = CustomDnsServer?.ToList();
}

ConfirmAction(
Properties.Resources.CreatingResourceMessage,
this.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ public class UpdateAzureRmP2SVpnGatewayCommand : P2SVpnGatewayBaseCmdlet
HelpMessage = "The scale unit for this P2SVpnGateway.")]
public uint VpnGatewayScaleUnit { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The list of Custom Dns Servers.")]
public string[] CustomDnsServer { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "A hashtable which represents resource tags.")]
Expand Down Expand Up @@ -219,6 +225,16 @@ public override void Execute()
}
}

// Set the custom dns servers, if it is specified by customer.
if (CustomDnsServer != null && this.CustomDnsServer.Any())
{
existingP2SVpnGateway.CustomDnsServers = CustomDnsServer?.ToList();
}
else
{
existingP2SVpnGateway.CustomDnsServers = null;
}

//// Resolve the VpnServerConfiguration, if specified
string vpnServerConfigurationResourceGroupName = string.Empty;
string vpnServerConfigurationName = string.Empty;
Expand Down
8 changes: 8 additions & 0 deletions src/Network/Network/Models/Cortex/PSP2SVpnGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class PSP2SVpnGateway : PSTopLevelResource
[Ps1Xml(Label = "Provisioning State", Target = ViewControl.Table)]
public string ProvisioningState { get; set; }

public List<string> CustomDnsServers { get; set; }

[JsonIgnore]
public string VpnClientConnectionHealthText
{
Expand All @@ -50,5 +52,11 @@ public string P2SConnectionConfigurationsText
{
get { return JsonConvert.SerializeObject(P2SConnectionConfigurations, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string CustomDnsServersText
{
get { return JsonConvert.SerializeObject(CustomDnsServers, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}
}
}
2 changes: 1 addition & 1 deletion src/Network/Network/Network.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PsModuleName>Network</PsModuleName>
Expand Down
66 changes: 40 additions & 26 deletions src/Network/Network/help/New-AzP2sVpnGateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,48 @@ Create a new P2SVpnGateway under VirtualHub for point to site connectivity.
```
New-AzP2sVpnGateway -ResourceGroupName <String> -Name <String> -VpnGatewayScaleUnit <UInt32>
-VirtualHubName <String> [-VpnServerConfiguration <PSVpnServerConfiguration>] -VpnClientAddressPool <String[]>
[-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-CustomDnsServer <String[]>] [-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### ByVirtualHubNameByVpnServerConfigurationResourceId
```
New-AzP2sVpnGateway -ResourceGroupName <String> -Name <String> -VpnGatewayScaleUnit <UInt32>
-VirtualHubName <String> -VpnServerConfigurationId <String> -VpnClientAddressPool <String[]>
[-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-CustomDnsServer <String[]>] [-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### ByVirtualHubObjectByVpnServerConfigurationObject
```
New-AzP2sVpnGateway -ResourceGroupName <String> -Name <String> -VpnGatewayScaleUnit <UInt32>
-VirtualHub <PSVirtualHub> [-VpnServerConfiguration <PSVpnServerConfiguration>]
-VpnClientAddressPool <String[]> [-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
-VpnClientAddressPool <String[]> [-CustomDnsServer <String[]>] [-Tag <Hashtable>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### ByVirtualHubObjectByVpnServerConfigurationResourceId
```
New-AzP2sVpnGateway -ResourceGroupName <String> -Name <String> -VpnGatewayScaleUnit <UInt32>
-VirtualHub <PSVirtualHub> -VpnServerConfigurationId <String> -VpnClientAddressPool <String[]>
[-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-CustomDnsServer <String[]>] [-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### ByVirtualHubResourceIdByVpnServerConfigurationObject
```
New-AzP2sVpnGateway -ResourceGroupName <String> -Name <String> -VpnGatewayScaleUnit <UInt32>
-VirtualHubId <String> [-VpnServerConfiguration <PSVpnServerConfiguration>] -VpnClientAddressPool <String[]>
[-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-CustomDnsServer <String[]>] [-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### ByVirtualHubResourceIdByVpnServerConfigurationResourceId
```
New-AzP2sVpnGateway -ResourceGroupName <String> -Name <String> -VpnGatewayScaleUnit <UInt32>
-VirtualHubId <String> -VpnServerConfigurationId <String> -VpnClientAddressPool <String[]> [-Tag <Hashtable>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
-VirtualHubId <String> -VpnServerConfigurationId <String> -VpnClientAddressPool <String[]>
[-CustomDnsServer <String[]>] [-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -108,7 +109,7 @@ The **New-AzP2sVpnGateway** cmdlet enables you to create a new P2SVpnGateway und
Run cmdlet in the background

```yaml
Type: SwitchParameter
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Expand All @@ -119,11 +120,24 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -CustomDnsServer
The list of Custom Dns Servers.```yaml
Copy link
Collaborator

Choose a reason for hiding this comment

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

please move ```yaml to next line

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Type: System.String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

```yaml
Type: IAzureContextContainer
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Parameter Sets: (All)
Aliases: AzContext, AzureRmContext, AzureCredential

Expand All @@ -138,7 +152,7 @@ Accept wildcard characters: False
The resource name.

```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases: ResourceName, P2SVpnGatewayName

Expand All @@ -153,7 +167,7 @@ Accept wildcard characters: False
The resource name.

```yaml
Type: String
Type: System.String
Parameter Sets: (All)
Aliases:

Expand All @@ -168,7 +182,7 @@ Accept wildcard characters: False
A hashtable which represents resource tags.

```yaml
Type: Hashtable
Type: System.Collections.Hashtable
Parameter Sets: (All)
Aliases:

Expand All @@ -183,7 +197,7 @@ Accept wildcard characters: False
The VirtualHub this P2SVpnGateway needs to be associated with.

```yaml
Type: PSVirtualHub
Type: Microsoft.Azure.Commands.Network.Models.PSVirtualHub
Parameter Sets: ByVirtualHubObjectByVpnServerConfigurationObject, ByVirtualHubObjectByVpnServerConfigurationResourceId
Aliases:

Expand All @@ -198,7 +212,7 @@ Accept wildcard characters: False
The Id of the VirtualHub this P2SVpnGateway needs to be associated with.

```yaml
Type: String
Type: System.String
Parameter Sets: ByVirtualHubResourceIdByVpnServerConfigurationObject, ByVirtualHubResourceIdByVpnServerConfigurationResourceId
Aliases:

Expand All @@ -213,7 +227,7 @@ Accept wildcard characters: False
The Id of the VirtualHub this P2SVpnGateway needs to be associated with.

```yaml
Type: String
Type: System.String
Parameter Sets: ByVirtualHubNameByVpnServerConfigurationObject, ByVirtualHubNameByVpnServerConfigurationResourceId
Aliases:

Expand All @@ -228,7 +242,7 @@ Accept wildcard characters: False
P2S VpnClient AddressPool for this P2SVpnGateway P2SConnectionConfiguration.

```yaml
Type: String[]
Type: System.String[]
Parameter Sets: (All)
Aliases:

Expand All @@ -243,7 +257,7 @@ Accept wildcard characters: False
The scale unit for this P2SVpnGateway.

```yaml
Type: UInt32
Type: System.UInt32
Parameter Sets: (All)
Aliases:

Expand All @@ -258,7 +272,7 @@ Accept wildcard characters: False
The VpnServerConfiguration to be attached to this P2SVpnGateway.

```yaml
Type: PSVpnServerConfiguration
Type: Microsoft.Azure.Commands.Network.Models.PSVpnServerConfiguration
Parameter Sets: ByVirtualHubNameByVpnServerConfigurationObject, ByVirtualHubObjectByVpnServerConfigurationObject, ByVirtualHubResourceIdByVpnServerConfigurationObject
Aliases:

Expand All @@ -273,7 +287,7 @@ Accept wildcard characters: False
The id of Vpn server configuration object this P2SVpnGateway will be attached to.

```yaml
Type: String
Type: System.String
Parameter Sets: ByVirtualHubNameByVpnServerConfigurationResourceId, ByVirtualHubObjectByVpnServerConfigurationResourceId, ByVirtualHubResourceIdByVpnServerConfigurationResourceId
Aliases:

Expand All @@ -288,7 +302,7 @@ Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.

```yaml
Type: SwitchParameter
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Expand All @@ -304,7 +318,7 @@ Shows what would happen if the cmdlet runs.
The cmdlet is not run.

```yaml
Type: SwitchParameter
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Expand Down
Loading