Skip to content

Commit a6354aa

Browse files
wdehrichWill Ehrich
andauthored
Add edge zone parameter to create network interface cmdlet (#15184)
* Add edge zone parameter to create network interface cmdlet * Regenerate new network interface help file Co-authored-by: Will Ehrich <[email protected]>
1 parent 6583cb9 commit a6354aa

File tree

7 files changed

+319
-246
lines changed

7 files changed

+319
-246
lines changed

src/Network/Network.Test/ScenarioTests/NetworkInterfaceTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public void TestNetworkInterfaceVmss()
133133

134134
[Fact]
135135
[Trait(Category.AcceptanceType, Category.CheckIn)]
136+
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
136137
public void TestNetworkInterfaceInEdgeZone()
137138
{
138139
TestRunner.RunTestScript("Test-NetworkInterfaceInEdgeZone");

src/Network/Network.Test/ScenarioTests/NetworkInterfaceTests.ps1

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,35 +1154,39 @@ function Test-NetworkInterfaceVmss
11541154

11551155
<#
11561156
.SYNOPSIS
1157-
Test that network interface can be put in an edge zone.
1157+
Test that network interface can be put in an edge zone. Subscriptions need to be explicitly whitelisted for access to edge zones.
11581158
#>
11591159
function Test-NetworkInterfaceInEdgeZone
11601160
{
1161-
$ResourceGroup = Get-ResourceGroupName;
1162-
$LocationName = "westus";
1163-
$EdgeZone = "microsoftlosangeles1";
1164-
$VMName = "MyVM";
1161+
$resourceGroup = Get-ResourceGroupName
1162+
$locationName = "westus"
1163+
$edgeZone = "microsoftlosangeles1"
11651164

11661165
try
11671166
{
1168-
New-AzResourceGroup -Name $ResourceGroup -Location $LocationName -Force;
1169-
1170-
$NetworkName = "MyNet";
1171-
$NICName = "MyNIC";
1172-
$SubnetName = "MySubnet";
1173-
$SubnetAddressPrefix = "10.0.0.0/24";
1174-
$VnetAddressPrefix = "10.0.0.0/16";
1175-
1176-
$SingleSubnet = New-AzVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix $SubnetAddressPrefix;
1177-
$Vnet = New-AzVirtualNetwork -Name $NetworkName -ResourceGroupName $ResourceGroup -Location $LocationName -EdgeZone $EdgeZone -AddressPrefix $VnetAddressPrefix -Subnet $SingleSubnet;
1178-
New-AzNetworkInterface -Name $NICName -ResourceGroupName $ResourceGroup -Location $LocationName -EdgeZone $EdgeZone -SubnetId $Vnet.Subnets[0].Id;
1179-
1180-
$NIC = Get-AzNetworkInterface -Name $NICName -ResourceGroupName $ResourceGroup
1181-
Assert-AreEqual $NIC.ExtendedLocation.Name $EdgeZone
1167+
New-AzResourceGroup -Name $resourceGroup -Location $locationName -Force
1168+
1169+
$networkName = "MyNet"
1170+
$nicName = "MyNIC"
1171+
$subnetName = "MySubnet"
1172+
$subnetAddressPrefix = "10.0.0.0/24"
1173+
$vnetAddressPrefix = "10.0.0.0/16"
1174+
1175+
$singleSubnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix $subnetAddressPrefix
1176+
$vnet = New-AzVirtualNetwork -Name $networkName -ResourceGroupName $resourceGroup -Location $locationName -EdgeZone $edgeZone -AddressPrefix $vnetAddressPrefix -Subnet $singleSubnet
1177+
New-AzNetworkInterface -Name $nicName -ResourceGroupName $resourceGroup -Location $locationName -EdgeZone $edgeZone -SubnetId $vnet.Subnets[0].Id
1178+
1179+
$nic = Get-AzNetworkInterface -Name $nicName -ResourceGroupName $resourceGroup
1180+
Assert-AreEqual $nic.ExtendedLocation.Name $edgeZone
1181+
Assert-AreEqual $nic.ExtendedLocation.Type "EdgeZone"
1182+
}
1183+
catch [Microsoft.Azure.Commands.Network.Common.NetworkCloudException]
1184+
{
1185+
Assert-NotNull { $_.Exception.Message -match 'Resource type .* does not support edge zone .* in location .* The supported edge zones are .*' }
11821186
}
11831187
finally
11841188
{
11851189
# Cleanup
1186-
Clean-ResourceGroup $ResourceGroup;
1190+
Clean-ResourceGroup $resourceGroup
11871191
}
11881192
}

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NetworkInterfaceTests/TestNetworkInterfaceInEdgeZone.json

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

src/Network/Network/Models/PSNetworkInterface.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
namespace Microsoft.Azure.Commands.Network.Models
1616
{
1717
using Microsoft.Azure.Management.Internal.Network.Common;
18-
using Microsoft.Azure.Management.Network.Models;
1918
using Newtonsoft.Json;
2019
using System.Collections.Generic;
2120
using WindowsAzure.Commands.Common.Attributes;
@@ -25,6 +24,7 @@ public class PSNetworkInterface : PSTopLevelResource, INetworkInterfaceReference
2524
public PSResourceId VirtualMachine { get; set; }
2625

2726
public PSExtendedLocation ExtendedLocation { get; set; }
27+
2828
public List<PSNetworkInterfaceIPConfiguration> IpConfigurations { get; set; }
2929

3030
public List<PSNetworkInterfaceTapConfiguration> TapConfigurations { get; set; }
@@ -88,6 +88,12 @@ public string PrivateEndpointText
8888
get { return JsonConvert.SerializeObject(PrivateEndpoint, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
8989
}
9090

91+
[JsonIgnore]
92+
public string ExtendedLocationText
93+
{
94+
get { return JsonConvert.SerializeObject(ExtendedLocation, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
95+
}
96+
9197
public bool ShouldSerializeIpConfigurations()
9298
{
9399
return !string.IsNullOrEmpty(this.Name);

src/Network/Network/Network.format.ps1xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,6 +1822,10 @@
18221822
<Label>MacAddress</Label>
18231823
<PropertyName>MacAddress</PropertyName>
18241824
</ListItem>
1825+
<ListItem>
1826+
<Label>ExtendedLocation</Label>
1827+
<PropertyName>ExtendedLocationText</PropertyName>
1828+
</ListItem>
18251829
</ListItems>
18261830
</ListEntry>
18271831
</ListEntries>

src/Network/Network/NetworkInterface/NewAzureNetworkInterfaceCommand.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public class NewAzureNetworkInterfaceCommand : NetworkInterfaceBaseCmdlet
5656

5757
[Parameter(
5858
Mandatory = false,
59-
ValueFromPipelineByPropertyName = true)]
59+
ValueFromPipelineByPropertyName = true,
60+
HelpMessage = "The edge zone of the network interface")]
6061
public string EdgeZone { get; set; }
6162

6263
[Parameter(
@@ -275,7 +276,7 @@ private PSNetworkInterface CreateNetworkInterface()
275276
networkInterface.Name = this.Name;
276277

277278
networkInterface.Location = this.Location;
278-
if (this.EdgeZone != null)
279+
if (!string.IsNullOrEmpty(EdgeZone))
279280
{
280281
networkInterface.ExtendedLocation = new PSExtendedLocation(this.EdgeZone);
281282
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Accept wildcard characters: False
202202
```
203203
204204
### -EdgeZone
205-
{{ Fill EdgeZone Description }}
205+
The edge zone of the network interface
206206
207207
```yaml
208208
Type: System.String

0 commit comments

Comments
 (0)