Skip to content

Commit

Permalink
Add edge zone parameter to create network interface cmdlet
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Ehrich committed Jun 9, 2021
1 parent eba1de6 commit 4a811ce
Show file tree
Hide file tree
Showing 6 changed files with 318 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public void TestNetworkInterfaceVmss()

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
public void TestNetworkInterfaceInEdgeZone()
{
TestRunner.RunTestScript("Test-NetworkInterfaceInEdgeZone");
Expand Down
44 changes: 24 additions & 20 deletions src/Network/Network.Test/ScenarioTests/NetworkInterfaceTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1154,35 +1154,39 @@ function Test-NetworkInterfaceVmss

<#
.SYNOPSIS
Test that network interface can be put in an edge zone.
Test that network interface can be put in an edge zone. Subscriptions need to be explicitly whitelisted for access to edge zones.
#>
function Test-NetworkInterfaceInEdgeZone
{
$ResourceGroup = Get-ResourceGroupName;
$LocationName = "westus";
$EdgeZone = "microsoftlosangeles1";
$VMName = "MyVM";
$resourceGroup = Get-ResourceGroupName
$locationName = "westus"
$edgeZone = "microsoftlosangeles1"

try
{
New-AzResourceGroup -Name $ResourceGroup -Location $LocationName -Force;

$NetworkName = "MyNet";
$NICName = "MyNIC";
$SubnetName = "MySubnet";
$SubnetAddressPrefix = "10.0.0.0/24";
$VnetAddressPrefix = "10.0.0.0/16";

$SingleSubnet = New-AzVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix $SubnetAddressPrefix;
$Vnet = New-AzVirtualNetwork -Name $NetworkName -ResourceGroupName $ResourceGroup -Location $LocationName -EdgeZone $EdgeZone -AddressPrefix $VnetAddressPrefix -Subnet $SingleSubnet;
New-AzNetworkInterface -Name $NICName -ResourceGroupName $ResourceGroup -Location $LocationName -EdgeZone $EdgeZone -SubnetId $Vnet.Subnets[0].Id;

$NIC = Get-AzNetworkInterface -Name $NICName -ResourceGroupName $ResourceGroup
Assert-AreEqual $NIC.ExtendedLocation.Name $EdgeZone
New-AzResourceGroup -Name $resourceGroup -Location $locationName -Force

$networkName = "MyNet"
$nicName = "MyNIC"
$subnetName = "MySubnet"
$subnetAddressPrefix = "10.0.0.0/24"
$vnetAddressPrefix = "10.0.0.0/16"

$singleSubnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix $subnetAddressPrefix
$vnet = New-AzVirtualNetwork -Name $networkName -ResourceGroupName $resourceGroup -Location $locationName -EdgeZone $edgeZone -AddressPrefix $vnetAddressPrefix -Subnet $singleSubnet
New-AzNetworkInterface -Name $nicName -ResourceGroupName $resourceGroup -Location $locationName -EdgeZone $edgeZone -SubnetId $vnet.Subnets[0].Id

$nic = Get-AzNetworkInterface -Name $nicName -ResourceGroupName $resourceGroup
Assert-AreEqual $nic.ExtendedLocation.Name $edgeZone
Assert-AreEqual $nic.ExtendedLocation.Type "EdgeZone"
}
catch [Microsoft.Azure.Commands.Network.Common.NetworkCloudException]
{
Assert-NotNull { $_.Exception.Message -match 'Resource type .* does not support edge zone .* in location .* The supported edge zones are .*' }
}
finally
{
# Cleanup
Clean-ResourceGroup $ResourceGroup;
Clean-ResourceGroup $resourceGroup
}
}
Loading

0 comments on commit 4a811ce

Please sign in to comment.