Skip to content

Commit 56eb66a

Browse files
authored
Merge pull request Azure#9299 from khannarheams/netApril
Add Zones property to nat gateway
2 parents 861d2f7 + 3baf813 commit 56eb66a

File tree

8 files changed

+1123
-1081
lines changed

8 files changed

+1123
-1081
lines changed

src/Network/Network.Test/ScenarioTests/NatGatewayTests.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,20 @@ function Test-NatGatewayCRUDMinimalParameters
5252
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation;
5353

5454
# Create NatGateway
55-
$vNatGateway = New-AzNatGateway -ResourceGroupName $rgname -Name $rname -Location $location -Sku Standard;
55+
$vNatGateway = New-AzNatGateway -ResourceGroupName $rgname -Name $rname -Location $location -Sku Standard -Zone "1";
5656
Assert-NotNull $vNatGateway;
5757
Assert-True { Check-CmdletReturnType "New-AzNatGateway" $vNatGateway };
5858
Assert-AreEqual $rname $vNatGateway.Name;
59+
Assert-AreEqual $vNatGateway.Zones.Count 1;
60+
Assert-AreEqual $vNatGateway.Zones[0] "1";
5961

6062
# Get NatGateway
6163
$vNatGateway = Get-AzNatGateway -ResourceGroupName $rgname -Name $rname;
6264
Assert-NotNull $vNatGateway;
6365
Assert-True { Check-CmdletReturnType "Get-AzNatGateway" $vNatGateway };
6466
Assert-AreEqual $rname $vNatGateway.Name;
67+
Assert-AreEqual $vNatGateway.Zones.Count 1;
68+
Assert-AreEqual $vNatGateway.Zones[0] "1";
6569

6670
# Get all NatGateways in resource group
6771
$listNatGateway = Get-AzNatGateway -ResourceGroupName $rgname;
@@ -276,4 +280,4 @@ function Test-NatGatewayCRUDAllParameters
276280
# Cleanup
277281
Clean-ResourceGroup $rgname;
278282
}
279-
}
283+
}

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NatGatewayTests/TestNatGatewayCRUDAllParameters.json

Lines changed: 398 additions & 398 deletions
Large diffs are not rendered by default.

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NatGatewayTests/TestNatGatewayCRUDMinimalParameters.json

Lines changed: 237 additions & 237 deletions
Large diffs are not rendered by default.

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NatGatewayTests/TestNatGatewayWithSubnet.json

Lines changed: 440 additions & 440 deletions
Large diffs are not rendered by default.

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* Fixed displaying of VirtualNetworkTaps in NetworkInterfaceIpConfiguration
5151
* Fixed Cortex Get cmdlets for list all part
5252
* Fixed VirtualHub reference creation for ExpressRouteGateways, VpnGateway
53-
* Add Availability Zones support for Azure Firewall
53+
* Added support for Availability Zones in AzureFirewall and NatGateway
5454
* Added cmdlet Get-AzNetworkServiceTag
5555

5656
* Add support for multiple public IP addresses for Azure Firewall

src/Network/Network/Models/PSNatGateway.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public partial class PSNatGateway : PSTopLevelResource
2727
public string ProvisioningState { get; set; }
2828
[Ps1Xml(Label = "Sku Name", Target = ViewControl.Table, ScriptBlock = "$_.Sku.Name")]
2929
public PSNatGatewaySku Sku { get; set; }
30+
public List<string> Zones { get; set; }
3031
public List<PSResourceId> PublicIpAddresses { get; set; }
3132
public List<PSResourceId> PublicIpPrefixes { get; set; }
3233

src/Network/Network/NatGateway/NewAzureRMNatGatewayCommand.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ public partial class NewAzureRmNatGateway : NetworkBaseCmdlet
5050
HelpMessage = "The idle timeout of the nat gateway.")]
5151
public int IdleTimeoutInMinutes { get; set; } = 4;
5252

53+
[Parameter(
54+
Mandatory = false,
55+
HelpMessage = "A list of availability zones denoting the zone in which Nat Gateway should be deployed.")]
56+
[PSArgumentCompleter(
57+
"1",
58+
"2",
59+
"3"
60+
)]
61+
public string[] Zone { get; set; }
62+
5363
[Parameter(
5464
Mandatory = false,
5565
HelpMessage = "Name of a NAT gateway SKU.")]
@@ -120,6 +130,8 @@ public override void Execute()
120130
PublicIpPrefixes = vPublicIpPrefixes,
121131
};
122132

133+
vNatGateway.Zones = this.Zone?.ToList();
134+
123135
var vNatGatewayModel = NetworkResourceManagerProfile.Mapper.Map<MNM.NatGateway>(vNatGateway);
124136
vNatGatewayModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);
125137
var present = true;

src/Network/Network/help/New-AzNatGateway.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ Create new Nat Gateway resource with properties Public Ip Address/Public Ip Pref
1313
## SYNTAX
1414

1515
```
16-
New-AzNatGateway -ResourceGroupName <String> -Name <String> [-IdleTimeoutInMinutes <Int32>] [-Sku <String>]
17-
[-Location <String>] [-Tag <Hashtable>] [-PublicIpAddress <PSResourceId[]>] [-PublicIpPrefix <PSResourceId[]>]
18-
[-Force] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
16+
New-AzNatGateway -ResourceGroupName <String> -Name <String> [-IdleTimeoutInMinutes <Int32>] [-Zone <String[]>]
17+
[-Sku <String>] [-Location <String>] [-Tag <Hashtable>] [-PublicIpAddress <PSResourceId[]>]
18+
[-PublicIpPrefix <PSResourceId[]>] [-Force] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
19+
[-Confirm] [<CommonParameters>]
1920
```
2021

2122
## DESCRIPTION
@@ -42,6 +43,15 @@ PS C:> $publicipprefix = New-AzPublicIpPrefix -Name "prefix2" -ResourceGroupName
4243
PS C:> $natgateway = New-AzNatGateway -ResourceGroupName "natgateway_test" -Name "nat_gateway" -IdleTimeoutInMinutes 4 -Sku "Standard" -Location "eastus2" -PublicIpPrefix $publicipprefix
4344
```
4445

46+
### Example 3 : Create Nat Gateway with Public IP Address in Availability Zone 1
47+
```powershell
48+
PS C:> $pip = New-AzPublicIpAddress -Name "pip" -ResourceGroupName "natgateway_test" -Location "eastus2" -Sku "Standard" -IdleTimeoutInMinutes 4 -AllocationMethod "static"
49+
PS C:> $natgateway = New-AzNatGateway -ResourceGroupName "natgateway_test" -Name "nat_gateway" -IdleTimeoutInMinutes 4 -Sku "Standard" -Location "eastus2" -PublicIpAddress $pip -Zone "1"
50+
```
51+
52+
The first command creates standard Public IP Address.
53+
The second command creates NAT Gateway with Public IP Address in Availability Zone 1.
54+
4555
## PARAMETERS
4656

4757
### -AsJob
@@ -209,6 +219,21 @@ Accept pipeline input: False
209219
Accept wildcard characters: False
210220
```
211221
222+
### -Zone
223+
A list of availability zones denoting the zone in which Nat Gateway should be deployed.
224+
225+
```yaml
226+
Type: System.String[]
227+
Parameter Sets: (All)
228+
Aliases:
229+
230+
Required: False
231+
Position: Named
232+
Default value: None
233+
Accept pipeline input: False
234+
Accept wildcard characters: False
235+
```
236+
212237
### -Confirm
213238
Prompts you for confirmation before running the cmdlet.
214239

0 commit comments

Comments
 (0)