Skip to content

Commit 74c3674

Browse files
authored
[Network] Fix bug of missing SyncMode and Vnet property in PSBackendAddressPool (#23722)
* [Network] Fix bug of missing SyncMode and Vnet property in PSBackendAddressPool * update changeLog.md
1 parent 2476133 commit 74c3674

File tree

6 files changed

+2882
-334
lines changed

6 files changed

+2882
-334
lines changed

src/Network/Network.Test/ScenarioTests/LoadBalancerBackendPoolTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,13 @@ public void TestManagedIpBasedLoadBalancerBackendPoolCreate()
112112
{
113113
TestRunner.RunTestScript("Test-ManagedIpBasedLoadBalancerBackendPoolCreate");
114114
}
115+
116+
[Fact]
117+
[Trait(Category.AcceptanceType, Category.CheckIn)]
118+
[Trait(Category.Owner, NrpTeamAlias.slbdev)]
119+
public void TestManagedIpBasedLoadBalancerBackendPoolUpdate()
120+
{
121+
TestRunner.RunTestScript("Test-ManagedIpBasedLoadBalancerBackendPoolUpdate");
122+
}
115123
}
116124
}

src/Network/Network.Test/ScenarioTests/LoadBalancerBackendPoolTests.ps1

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,89 @@ function Test-ManagedIpBasedLoadBalancerBackendPoolCreate
726726
$create1 = $lb | New-AzLoadBalancerBackendAddressPool -Name $backendPool1 -SyncMode "Automatic" -VirtualNetworkId $vnet.Id
727727

728728
Assert-NotNull $create1
729+
Assert-True { $create1.SyncMode -eq "Automatic"}
730+
Assert-AreEqual $create1.VirtualNetwork.Id $vnet.Id
729731

730732
## create by Name without ip's
731733
$create2 = New-AzLoadBalancerBackendAddressPool -ResourceGroupName $rgname -LoadBalancerName $lbName -Name $backendPool2 -SyncMode "Automatic" -VirtualNetworkId $vnet.Id
732734

733735
Assert-NotNull $create2
736+
Assert-True { $create2.SyncMode -eq "Automatic"}
737+
Assert-AreEqual $create2.VirtualNetwork.Id $vnet.Id
738+
}
739+
finally {
740+
# Cleanup
741+
Clean-ResourceGroup $rgname
742+
}
743+
}
744+
745+
<#
746+
.SYNOPSIS
747+
Tests Set-AzLoadBalancerBackendAddressPool
748+
#>
749+
function Test-ManagedIpBasedLoadBalancerBackendPoolUpdate
750+
{
751+
752+
# Setup
753+
$rgname = Get-ResourceGroupName
754+
$vnetName = Get-ResourceName
755+
$subnetName = Get-ResourceName
756+
$publicIpName = Get-ResourceName
757+
$domainNameLabel = Get-ResourceName
758+
$lbName = Get-ResourceName
759+
$frontendName = Get-ResourceName
760+
$backendAddressPoolName = Get-ResourceName
761+
$rglocation = Get-ProviderLocation ResourceManagement
762+
$resourceTypeParent = "Microsoft.Network/loadBalancers"
763+
$location = Get-ProviderLocation $resourceTypeParent
764+
765+
$testIpAddress1 = "10.0.0.5"
766+
$testIpAddress2 = "10.0.0.6"
767+
768+
$backendAddressConfigName1 = Get-ResourceName
769+
$backendAddressConfigName2 = Get-ResourceName
770+
771+
$backendPool1 = Get-ResourceName
772+
773+
try
774+
{
775+
# Create the resource group
776+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval"}
777+
778+
# Create pip
779+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -DomainNameLabel $domainNameLabel -SKU Standard
780+
781+
# Create fip
782+
$frontend = New-AzLoadBalancerFrontendIpConfig -Name $frontendName -PublicIpAddress $publicip
783+
784+
# Create the Virtual Network
785+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
786+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
787+
788+
# Create Standard Azure load balancer
789+
$lb = New-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname -Location $location -SKU Standard -FrontendIPConfiguration $frontend
790+
791+
$unmodified = $lb | New-AzLoadBalancerBackendAddressPool -Name $backendPool1 -SyncMode "Automatic" -VirtualNetworkId $vnet.Id
792+
Assert-NotNull $unmodified
793+
Assert-True { $unmodified.SyncMode -eq "Automatic"}
794+
Assert-AreEqual $unmodified.VirtualNetwork.Id $vnet.Id
795+
796+
$lb = Get-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname
797+
Assert-True { $lb.BackendAddressPools[0].SyncMode -eq "Automatic"}
798+
Assert-AreEqual $lb.BackendAddressPools[0].VirtualNetwork.Id $vnet.Id
799+
800+
$pool = Get-AzLoadBalancerBackendAddressPool -ResourceGroupName $rgname -LoadBalancerName $lbName -Name $backendPool1
801+
Assert-True { $pool.SyncMode -eq "Automatic"}
802+
Assert-AreEqual $pool.VirtualNetwork.Id $vnet.Id
803+
804+
$lb2 = Set-AzLoadBalancer -LoadBalancer $lb
805+
Assert-NotNull $lb2
806+
Assert-True { $lb2.BackendAddressPools[0].SyncMode -eq "Automatic"}
807+
Assert-AreEqual $lb2.BackendAddressPools[0].VirtualNetwork.Id $vnet.Id
808+
809+
$pool2 = Set-AzLoadBalancerBackendAddressPool -InputObject $pool
810+
Assert-True { $pool2.SyncMode -eq "Automatic"}
811+
Assert-AreEqual $pool2.VirtualNetwork.Id $vnet.Id
734812
}
735813
finally {
736814
# Cleanup

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.LoadBalancerBackendPoolTests/TestManagedIpBasedLoadBalancerBackendPoolCreate.json

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

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.LoadBalancerBackendPoolTests/TestManagedIpBasedLoadBalancerBackendPoolUpdate.json

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

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
## Upcoming Release
2222
* Fixed a few minor issues
23+
* Fixed missing properties in PSBackendAddressPool
2324

2425
## Version 7.1.0
2526
* Added DefaultOutboundAccess parameter on subnet creation

src/Network/Network/Generated/Models/PSBackendAddressPool.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public partial class PSBackendAddressPool : PSChildResource
4646
public PSResourceId OutboundRule { get; set; }
4747
[JsonProperty(Order = 1)]
4848
public List<PSTunnelInterface> TunnelInterfaces { get; set; }
49+
[JsonProperty(Order = 1)]
50+
public string SyncMode { get; set; }
51+
[JsonProperty(Order = 1)]
52+
public SubResource VirtualNetwork { get; set; }
4953

5054
[JsonIgnore]
5155
public string BackendIpConfigurationsText
@@ -77,6 +81,18 @@ public string TunnelInterfacesText
7781
get { return JsonConvert.SerializeObject(TunnelInterfaces, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
7882
}
7983

84+
[JsonIgnore]
85+
public string SyncModeText
86+
{
87+
get { return JsonConvert.SerializeObject(SyncMode, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
88+
}
89+
90+
[JsonIgnore]
91+
public string VirtualNetworkText
92+
{
93+
get { return JsonConvert.SerializeObject(VirtualNetwork, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
94+
}
95+
8096
public bool ShouldSerializeTunnelInterfaces()
8197
{
8298
return !string.IsNullOrEmpty(this.Name);
@@ -91,5 +107,15 @@ public bool ShouldSerializeLoadBalancingRules()
91107
{
92108
return !string.IsNullOrEmpty(this.Name);
93109
}
110+
111+
public bool ShouldSerializeSyncMode()
112+
{
113+
return !string.IsNullOrEmpty(this.Name);
114+
}
115+
116+
public bool ShouldSerializeVirtualNetwork()
117+
{
118+
return !string.IsNullOrEmpty(this.Name);
119+
}
94120
}
95121
}

0 commit comments

Comments
 (0)