Skip to content

Commit 5e753d6

Browse files
wdehrichWill EhrichBethanyZhou
authored
Add edge zone parameter to load balancer cmdlet (#15271)
* Move source files from Generated directory * Move models * Code generation tool is deprecated. File are to be manually edited * Update load balancer cmdlet * Update changelog * UT is working * Refactor UT * Another UT refactor * Add test session record * Update help file * update changelog Co-authored-by: Will Ehrich <[email protected]> Co-authored-by: Beisi Zhou <[email protected]>
1 parent 7f8a6c1 commit 5e753d6

File tree

48 files changed

+1940
-718
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1940
-718
lines changed

src/Network/Network.Test/ScenarioTests/LoadBalancerTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,5 +272,13 @@ public void TestGatewayLoadBalancerConsumerLb()
272272
{
273273
TestRunner.RunTestScript("Test-GatewayLoadBalancer-ConsumerLb");
274274
}
275+
276+
[Fact]
277+
[Trait(Category.AcceptanceType, Category.CheckIn)]
278+
[Trait(Category.Owner, NrpTeamAlias.slbdev)]
279+
public void TestLoadBalancerInEdgeZone()
280+
{
281+
TestRunner.RunTestScript("Test-LoadBalancerInEdgeZone");
282+
}
275283
}
276284
}

src/Network/Network.Test/ScenarioTests/LoadBalancerTests.ps1

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,3 +2913,60 @@ function Test-CreateSubresourcesOnEmptyLoadBalancer
29132913
Clean-ResourceGroup $rgname
29142914
}
29152915
}
2916+
2917+
<#
2918+
.SYNOPSIS
2919+
Test creating a load balancer in an edge zone. Subscriptions need to be explicitly whitelisted for access to edge zones.
2920+
#>
2921+
function Test-LoadBalancerInEdgeZone
2922+
{
2923+
# Setup
2924+
$rgname = Get-ResourceGroupName
2925+
$vnetName = Get-ResourceName
2926+
$subnetName = Get-ResourceName
2927+
$publicIpName = Get-ResourceName
2928+
$domainNameLabel = Get-ResourceName
2929+
$lbName = Get-ResourceName
2930+
$frontendName = Get-ResourceName
2931+
$backendAddressPoolName = Get-ResourceName
2932+
$probeName = Get-ResourceName
2933+
$inboundNatRuleName = Get-ResourceName
2934+
$lbruleName = Get-ResourceName
2935+
$rglocation = "westus"
2936+
$location = "westus"
2937+
$edgeZone = "microsoftlosangeles1"
2938+
2939+
try
2940+
{
2941+
# Create the resource group
2942+
New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval"}
2943+
2944+
# Create the Virtual Network
2945+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
2946+
New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet -EdgeZone $edgeZone
2947+
2948+
# Create the publicip
2949+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel -EdgeZone $edgeZone
2950+
2951+
# Create LoadBalancer
2952+
$frontend = New-AzLoadBalancerFrontendIpConfig -Name $frontendName -PublicIpAddress $publicip
2953+
$backendAddressPool = New-AzLoadBalancerBackendAddressPoolConfig -Name $backendAddressPoolName
2954+
$probe = New-AzLoadBalancerProbeConfig -Name $probeName -RequestPath healthcheck.aspx -Protocol http -Port 80 -IntervalInSeconds 15 -ProbeCount 2
2955+
$inboundNatRule = New-AzLoadBalancerInboundNatRuleConfig -Name $inboundNatRuleName -FrontendIPConfiguration $frontend -Protocol Tcp -FrontendPort 3389 -BackendPort 3389 -IdleTimeoutInMinutes 15 -EnableFloatingIP
2956+
$lbrule = New-AzLoadBalancerRuleConfig -Name $lbruleName -FrontendIPConfiguration $frontend -BackendAddressPool $backendAddressPool -Probe $probe -Protocol Tcp -FrontendPort 80 -BackendPort 80 -IdleTimeoutInMinutes 15 -EnableFloatingIP -LoadDistribution SourceIP
2957+
New-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname -Location $location -FrontendIpConfiguration $frontend -BackendAddressPool $backendAddressPool -Probe $probe -InboundNatRule $inboundNatRule -LoadBalancingRule $lbrule -EdgeZone $edgeZone
2958+
2959+
$loadBalancer = Get-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname
2960+
Assert-AreEqual $loadBalancer.ExtendedLocation.Name $edgeZone
2961+
Assert-AreEqual $loadBalancer.ExtendedLocation.Type "EdgeZone"
2962+
}
2963+
catch [Microsoft.Azure.Commands.Network.Common.NetworkCloudException]
2964+
{
2965+
Assert-NotNull { $_.Exception.Message -match 'Resource type .* does not support edge zone .* in location .* The supported edge zones are .*' }
2966+
}
2967+
finally
2968+
{
2969+
# Cleanup
2970+
Clean-ResourceGroup $rgname
2971+
}
2972+
}

0 commit comments

Comments
 (0)