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
8 changes: 8 additions & 0 deletions src/Network/Network.Test/ScenarioTests/NatGatewayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,13 @@ public void TestVirtualNetworkSubnetConfigWithNatGateway()
{
TestRunner.RunTestScript("Test-VirtualNetworkSubnetConfigWithNatGateway");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.slbdev)]
public void TestNatGatewayNat64Parameter()
{
TestRunner.RunTestScript("Test-NatGatewayNat64Parameter");
}
}
}
72 changes: 72 additions & 0 deletions src/Network/Network.Test/ScenarioTests/NatGatewayTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,76 @@ function Test-VirtualNetworkSubnetConfigWithNatGateway
# Cleanup
Clean-ResourceGroup $rgname;
}
}

<#
.SYNOPSIS
Test Nat64 support in New-AzNatGateway and Set-AzNatGateway
#>
function Test-NatGatewayNat64Parameter
{
# Setup
$rgname = Get-ResourceGroupName;
$rglocation = Get-ProviderLocation ResourceManagement;
$rname = Get-ResourceName;
$location = Get-ProviderLocation "Microsoft.Network/networkWatchers" "East US 2 EUAP";

# Skip this scenario when Nat64 feature is unavailable in the current subscription.
if ((Get-NetworkTestMode) -ne 'Playback')
{
$nat64Feature = Get-AzProviderFeature -ProviderNamespace "Microsoft.Network" -FeatureName "EnableNat64OnNatGateway" -ErrorAction SilentlyContinue
if ($null -eq $nat64Feature -or $nat64Feature.RegistrationState -ne "Registered")
{
Write-Warning "Test skipped: feature Microsoft.Network/EnableNat64OnNatGateway is not registered for this subscription."
return
}
}

try
{
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation;

# Create NatGateway with Nat64 enabled
$vNatGateway = New-AzNatGateway -ResourceGroupName $rgname -Name $rname -Location $location -Sku StandardV2 -Nat64 Enabled;
Assert-NotNull $vNatGateway;
Assert-True { Check-CmdletReturnType "New-AzNatGateway" $vNatGateway };
Assert-AreEqual "Enabled" $vNatGateway.Nat64;

# Get NatGateway and validate Nat64
$vNatGateway = Get-AzNatGateway -ResourceGroupName $rgname -Name $rname;
Assert-NotNull $vNatGateway;
Assert-AreEqual "Enabled" $vNatGateway.Nat64;

# Update Nat64 via set by name
$vNatGateway = Set-AzNatGateway -ResourceGroupName $rgname -Name $rname -Nat64 Disabled;
Assert-NotNull $vNatGateway;
Assert-True { Check-CmdletReturnType "Set-AzNatGateway" $vNatGateway };
Assert-AreEqual "Disabled" $vNatGateway.Nat64;

# Update Nat64 via set by resource id
$vNatGateway = Set-AzNatGateway -ResourceId $vNatGateway.Id -Nat64 Enabled;
Assert-NotNull $vNatGateway;
Assert-AreEqual "Enabled" $vNatGateway.Nat64;

# Validate omitted Nat64 does not overwrite existing value
$vNatGateway = Set-AzNatGateway -InputObject $vNatGateway;
Assert-NotNull $vNatGateway;
Assert-AreEqual "Enabled" $vNatGateway.Nat64;

# Get NatGateway and validate final Nat64 value
$vNatGateway = Get-AzNatGateway -ResourceGroupName $rgname -Name $rname;
Assert-NotNull $vNatGateway;
Assert-AreEqual "Enabled" $vNatGateway.Nat64;

# Remove NatGateway
$job = Remove-AzNatGateway -ResourceGroupName $rgname -Name $rname -PassThru -Force -AsJob;
$job | Wait-Job;
$removeNatGateway = $job | Receive-Job;
Assert-AreEqual $true $removeNatGateway;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname;
}
}

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
--->

## Upcoming Release
* Added property 'Nat64' to NatGateway and support for it in the following cmdlets:
- `New-AzNatGateway`
- `Set-AzNatGateway`

## Version 7.25.1
* Onboarded `Microsoft.DataReplication/replicationVaults` to Private Link Common Cmdlets
Expand Down
8 changes: 8 additions & 0 deletions src/Network/Network/Common/NetworkResourceManagerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ private static void Initialize()
.ForMember(
dest => dest.PublicIPPrefixes,
opt => opt.MapFrom(src => src.PublicIpPrefixes)
)
.ForMember(
dest => dest.Nat64,
opt => opt.MapFrom(src => src.Nat64)
);
cfg.CreateMap<MNM.NatGateway, CNM.PSNatGateway>()
.ForMember(
Expand All @@ -271,6 +275,10 @@ private static void Initialize()
.ForMember(
dest => dest.PublicIpPrefixes,
opt => opt.MapFrom(src => src.PublicIPPrefixes)
)
.ForMember(
dest => dest.Nat64,
opt => opt.MapFrom(src => src.Nat64)
);
cfg.CreateMap<CNM.PSNatGatewaySku, MNM.NatGatewaySku>();
cfg.CreateMap<MNM.NatGatewaySku, CNM.PSNatGatewaySku>();
Expand Down
1 change: 1 addition & 0 deletions src/Network/Network/Models/PSNatGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public partial class PSNatGateway : PSTopLevelResource
public List<PSResourceId> PublicIpAddressesV6 { get; set; }
public List<PSResourceId> PublicIpPrefixesV6 { get; set; }
public PSResourceId SourceVirtualNetwork { get; set; }
public string Nat64 { get; set; }

[JsonIgnore]
public string SkuText
Expand Down
11 changes: 10 additions & 1 deletion src/Network/Network/NatGateway/NewAzureRMNatGatewayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ public partial class NewAzureRmNatGateway : NetworkBaseCmdlet
HelpMessage = "The id of the source virtual network using this nat gateway resource.")]
public PSResourceId SourceVirtualNetwork { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Whether Nat64 is enabled for the nat gateway resource. Allowed values are None, Enabled, and Disabled.")]
[ValidateNotNullOrEmpty]
[ValidateSet(MNM.Nat64State.None, MNM.Nat64State.Enabled, MNM.Nat64State.Disabled, IgnoreCase = true)]
[PSArgumentCompleter(MNM.Nat64State.None, MNM.Nat64State.Enabled, MNM.Nat64State.Disabled)]
public string Nat64 { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Do not ask for confirmation if you want to overwrite a resource")]
Expand Down Expand Up @@ -153,7 +161,8 @@ public override void Execute()
PublicIpPrefixes = vPublicIpPrefixes,
PublicIpAddressesV6 = vPublicIpAddressesV6,
PublicIpPrefixesV6 = vPublicIpPrefixesV6,
SourceVirtualNetwork = this.SourceVirtualNetwork
SourceVirtualNetwork = this.SourceVirtualNetwork,
Nat64 = this.Nat64
};

vNatGateway.Zones = this.Zone?.ToList();
Expand Down
14 changes: 14 additions & 0 deletions src/Network/Network/NatGateway/SetAzureRMNatGatewayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using MNM = Microsoft.Azure.Management.Network.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;

namespace Microsoft.Azure.Commands.Network
{
Expand Down Expand Up @@ -87,6 +88,14 @@ public class SetAzureNatGatewayCommand : NetworkBaseCmdlet
HelpMessage = "The id of the source virtual network using this nat gateway resource.")]
public PSResourceId SourceVirtualNetwork { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Whether Nat64 is enabled for the nat gateway resource. Allowed values are None, Enabled, and Disabled.")]
[ValidateNotNullOrEmpty]
[ValidateSet(MNM.Nat64State.None, MNM.Nat64State.Enabled, MNM.Nat64State.Disabled, IgnoreCase = true)]
[PSArgumentCompleter(MNM.Nat64State.None, MNM.Nat64State.Enabled, MNM.Nat64State.Disabled)]
public string Nat64 { get; set; }

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

Expand Down Expand Up @@ -182,6 +191,11 @@ public override void Execute()
this.InputObject.SourceVirtualNetwork = this.SourceVirtualNetwork;
}

if (this.IsParameterBound(c => c.Nat64))
{
this.InputObject.Nat64 = this.Nat64;
}

// Map to the sdk object
var vNatGatewayModel = NetworkResourceManagerProfile.Mapper.Map<MNM.NatGateway>(this.InputObject);
vNatGatewayModel.Tags = TagsConversionHelper.CreateTagDictionary(this.InputObject.Tag, validate: true);
Expand Down
8 changes: 0 additions & 8 deletions src/Network/Network/Network.generated.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -6347,10 +6347,6 @@
<TableColumnHeader>
<Alignment>Left</Alignment>
<Label>Sku Name</Label>
</TableColumnHeader>
<TableColumnHeader>
<Alignment>Left</Alignment>
<Label>SourceVirtualNetwork</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
Expand Down Expand Up @@ -6379,10 +6375,6 @@
<TableColumnItem>
<Alignment>Left</Alignment>
<ScriptBlock>$_.Sku.Name</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<Alignment>Left</Alignment>
<PropertyName>SourceVirtualNetworkText</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
Expand Down
36 changes: 34 additions & 2 deletions src/Network/Network/help/New-AzNatGateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ Create new Nat Gateway resource with properties Public Ip Address/Public Ip Pref
New-AzNatGateway -ResourceGroupName <String> -Name <String> [-IdleTimeoutInMinutes <Int32>] [-Zone <String[]>]
[-Sku <String>] [-Location <String>] [-Tag <Hashtable>] [-PublicIpAddress <PSResourceId[]>]
[-PublicIpAddressV6 <PSResourceId[]>] [-PublicIpPrefix <PSResourceId[]>] [-PublicIpPrefixV6 <PSResourceId[]>]
[-SourceVirtualNetwork <PSResourceId>] [-Force] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
[-SourceVirtualNetwork <PSResourceId>] [-Nat64 <String>] [-Force] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -145,6 +146,37 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Nat64
Whether Nat64 is enabled for the nat gateway resource. Allowed values are None, Enabled, and Disabled.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:
Accepted values: None, Enabled, Disabled

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction
{{ Fill ProgressAction Description }}

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

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PublicIpAddress
An array of public ip addresses associated with the nat gateway resource.

Expand Down
43 changes: 37 additions & 6 deletions src/Network/Network/help/Set-AzNatGateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ Update Nat Gateway Resource with Public Ip Address, Public Ip Prefix and IdleTim
```
Set-AzNatGateway -ResourceGroupName <String> -Name <String> [-PublicIpAddress <PSResourceId[]>]
[-PublicIpAddressV6 <PSResourceId[]>] [-PublicIpPrefix <PSResourceId[]>] [-PublicIpPrefixV6 <PSResourceId[]>]
[-SourceVirtualNetwork <PSResourceId>] [-AsJob] [-IdleTimeoutInMinutes <Int32>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[-SourceVirtualNetwork <PSResourceId>] [-Nat64 <String>] [-AsJob] [-IdleTimeoutInMinutes <Int32>]
[-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

### SetByResourceIdParameterSet
```
Set-AzNatGateway -ResourceId <String> [-PublicIpAddress <PSResourceId[]>] [-PublicIpAddressV6 <PSResourceId[]>]
[-PublicIpPrefix <PSResourceId[]>] [-PublicIpPrefixV6 <PSResourceId[]>] [-SourceVirtualNetwork <PSResourceId>]
[-AsJob] [-IdleTimeoutInMinutes <Int32>] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
[-Nat64 <String>] [-AsJob] [-IdleTimeoutInMinutes <Int32>] [-DefaultProfile <IAzureContextContainer>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### SetByInputObjectParameterSet
```
Set-AzNatGateway -InputObject <PSNatGateway> [-PublicIpAddress <PSResourceId[]>]
[-PublicIpAddressV6 <PSResourceId[]>] [-PublicIpPrefix <PSResourceId[]>] [-PublicIpPrefixV6 <PSResourceId[]>]
[-SourceVirtualNetwork <PSResourceId>] [-AsJob] [-IdleTimeoutInMinutes <Int32>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[-SourceVirtualNetwork <PSResourceId>] [-Nat64 <String>] [-AsJob] [-IdleTimeoutInMinutes <Int32>]
[-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

Expand Down Expand Up @@ -129,6 +129,37 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Nat64
Whether Nat64 is enabled for the nat gateway resource. Allowed values are None, Enabled, and Disabled.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:
Accepted values: None, Enabled, Disabled

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction
{{ Fill ProgressAction Description }}

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

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PublicIpAddress
An array of public ip addresses associated with the nat gateway resource.

Expand Down
Loading