Skip to content

Commit ac5bb1b

Browse files
authored
Gateway Loadbalancer Get Nic bug fix (#21002)
* fix * fix * fix * fix * fix * fix
1 parent 2fe67db commit ac5bb1b

File tree

6 files changed

+2352
-14
lines changed

6 files changed

+2352
-14
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ function Test-NetworkInterface-GatewayLoadBalancerConsumer
320320
$publicipConsumer = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpConsumerName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel
321321

322322
# Create the ipconfiguration
323-
$ipconfig1 = New-AzNetworkInterfaceIpConfig -Name $ipconfigConsumerName -Subnet $vnet.Subnets[0] -PublicIpAddress $publicipConsumer -GatewayLoadBalancerId $frontendProvider.Id
323+
$ipconfig1 = New-AzNetworkInterfaceIpConfig -Name $ipconfigConsumerName -Subnet $vnet.Subnets[0] -PublicIpAddress $publicipConsumer -GatewayLoadBalancerId $frontendProvider.Id
324324

325325
# Create NetworkInterface
326326
$nicConsumer = New-AzNetworkInterface -Name $nicConsumerName -ResourceGroupName $rgname -Location $location -IpConfiguration $ipconfig1 -Tag @{ testtag = "testval" }
327327

328-
# Create NetworkInterface
328+
# Get NetworkInterface
329329
$expectedNicConsumer = Get-AzNetworkInterface -Name $nicName -ResourceGroupName $rgname
330330

331331
# Verification

src/Network/Network.Test/ScenarioTests/NetworkInterfaceTestsGenerated.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,13 @@ public void TestNetworkInterfaceGetEffectiveRouteTable()
7676
{
7777
TestRunner.RunTestScript(string.Format("Test-NetworkInterfaceGetEffectiveRouteTable -baseDir '{0}'", System.AppDomain.CurrentDomain.BaseDirectory));
7878
}
79+
80+
[Fact]
81+
[Trait(Category.AcceptanceType, Category.CheckIn)]
82+
[Trait(Category.Owner, NrpTeamAlias.slbdev)]
83+
public void TestNetworkInterfaceGatewayLoadBalancerConsumer()
84+
{
85+
TestRunner.RunTestScript(string.Format("Test-NetworkInterfaceGatewayLoadBalancerConsumer"));
86+
}
7987
}
8088
}

src/Network/Network.Test/ScenarioTests/NetworkInterfaceTestsGenerated.ps1

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,69 @@ function Test-NetworkInterfaceIpConfigurationCRUDMinimalParameters
365365
}
366366
}
367367

368+
<#
369+
.SYNOPSIS
370+
Tests creating new simple public networkinterface with Gateway Loadbalancer.
371+
#>
372+
function Test-NetworkInterfaceGatewayLoadBalancerConsumer
373+
{
374+
# Setup
375+
$rgname = Get-ResourceGroupName;
376+
377+
$vnetProviderName = Get-ResourceName;
378+
$subnetProviderName = Get-ResourceName;
379+
$lbProviderName = Get-ResourceName;
380+
$frontendProviderName = Get-ResourceName;
381+
382+
$vnetConsumerName = Get-ResourceName;
383+
$subnetConsumerName = Get-ResourceName;
384+
$publicIpConsumerName = Get-ResourceName;
385+
$nicConsumerName = Get-ResourceName;
386+
$ipconfigConsumerName = Get-ResourceName;
387+
$domainNameLabel = Get-ResourceName;
388+
$rglocation = Get-ProviderLocation ResourceManagement;
389+
$resourceTypeParent = "Microsoft.Network/networkInterfaces";
390+
$location = Get-ProviderLocation $resourceTypeParent;
391+
392+
try
393+
{
394+
# Create the resource group
395+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" };
396+
397+
# Create Provider Virtual Network
398+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetProviderName -AddressPrefix "10.0.1.0/24";
399+
$vnet = New-AzVirtualNetwork -Name $vnetProviderName -ResourceGroupName $rgname -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
400+
401+
# Create Provider LoadBalancer
402+
$frontendProvider = New-AzLoadBalancerFrontendIpConfig -Name $frontendProviderName -Subnet $vnet.Subnets[0];
403+
$lbProvider = New-AzLoadBalancer -Name $lbProviderName -ResourceGroupName $rgname -Location $location -FrontendIpConfiguration $frontendProvider -Sku "Gateway";
404+
405+
# Create Consumer Virtual Network
406+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetConsumerName -AddressPrefix "10.0.1.0/24";
407+
$vnet = New-AzVirtualNetwork -Name $vnetConsumerName -ResourceGroupName $rgname -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
408+
409+
# Create Consumer publicip
410+
$publicipConsumer = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpConsumerName -Sku "Standard" -location $location -AllocationMethod Static;
411+
412+
# Create the ipconfiguration
413+
$ipconfig1 = New-AzNetworkInterfaceIpConfig -Name $ipconfigConsumerName -Subnet $vnet.Subnets[0] -PublicIpAddress $publicipConsumer -GatewayLoadBalancerId $frontendProvider.Id;
414+
415+
# Create NetworkInterface
416+
$nicConsumer = New-AzNetworkInterface -Name $nicConsumerName -ResourceGroupName $rgname -Location $location -IpConfiguration $ipconfig1 -Tag @{ testtag = "testval" };
417+
418+
# Get NetworkInterface
419+
$expectedNicConsumer = Get-AzNetworkInterface -Name $nicConsumerName -ResourceGroupName $rgname;
420+
421+
# Verification
422+
Assert-AreEqual $frontendProvider.Id $expectedNicConsumer.ipconfigurations[0].GatewayLoadBalancer.Id;
423+
}
424+
finally
425+
{
426+
# Cleanup
427+
Clean-ResourceGroup $rgname;
428+
}
429+
}
430+
368431
<#
369432
.SYNOPSIS
370433
Test creating new NetworkInterfaceIpConfiguration

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NetworkInterfaceTestsGenerated/TestNetworkInterfaceGatewayLoadBalancerConsumer.json

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

src/Network/Network/Models/PSNetworkInterfaceIpConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class PSNetworkInterfaceIPConfiguration : PSIPConfiguration
4848

4949
[JsonProperty(Order = 2)]
5050
[Ps1Xml(Target = ViewControl.Table)]
51-
public PSFrontendIPConfiguration GatewayLoadBalancer { get; set; }
51+
public PSResourceId GatewayLoadBalancer { get; set; }
5252

5353
[JsonIgnore]
5454
public string LoadBalancerBackendAddressPoolsText
@@ -89,7 +89,7 @@ public string PrivateLinkConnectionPropertiesText
8989
[JsonIgnore]
9090
public string GatewayLoadBalancerText
9191
{
92-
get { return JsonConvert.SerializeObject(PrivateLinkConnectionProperties, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
92+
get { return JsonConvert.SerializeObject(GatewayLoadBalancer, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
9393
}
9494

9595
public bool ShouldSerializeLoadBalancerBackendAddressPools()
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
"Module","ClassName","Target","Severity","ProblemId","Description","Remediation"
2-
"Az.Network","Microsoft.Azure.Commands.Network.Automation.GetAzureRmDdosProtectionPlan","Get-AzDdosProtectionPlan","0","3010","The property 'PublicIpAddresses' of type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan' has been removed.","Add the property 'PublicIpAddresses' back to type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan'."
3-
"Az.Network","Microsoft.Azure.Commands.Network.Automation.GetAzureRmDdosProtectionPlan","Get-AzDdosProtectionPlan","0","3010","The property 'PublicIpAddressesText' of type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan' has been removed.","Add the property 'PublicIpAddressesText' back to type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan'."
4-
"Az.Network","Microsoft.Azure.Commands.Network.NewAzureRmDdosProtectionPlan","New-AzDdosProtectionPlan","0","3010","The property 'PublicIpAddresses' of type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan' has been removed.","Add the property 'PublicIpAddresses' back to type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan'."
5-
"Az.Network","Microsoft.Azure.Commands.Network.NewAzureRmDdosProtectionPlan","New-AzDdosProtectionPlan","0","3010","The property 'PublicIpAddressesText' of type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan' has been removed.","Add the property 'PublicIpAddressesText' back to type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan'."
6-
"Az.Network","Microsoft.Azure.Commands.Network.GetAzureNetworkWatcherPacketCaptureCommand","Get-AzNetworkWatcherPacketCapture","0","3030","The generic type for 'property TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ","Change the generic type for 'property TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'."
7-
"Az.Network","Microsoft.Azure.Commands.Network.NewAzureNetworkWatcherPacketCaptureCommand","New-AzNetworkWatcherPacketCapture","0","3030","The generic type for 'property TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ","Change the generic type for 'property TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'."
8-
"Az.Network","Microsoft.Azure.Commands.Network.NewAzureNetworkWatcherPacketCaptureCommand","New-AzNetworkWatcherPacketCapture","0","3030","The generic type for 'parameter TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ","Change the generic type for 'parameter TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'."
9-
"Az.Network","Microsoft.Azure.Commands.Network.NewAzureNetworkWatcherPacketCaptureCommandV2","New-AzNetworkWatcherPacketCaptureV2","0","3030","The generic type for 'property TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ","Change the generic type for 'property TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'."
10-
"Az.Network","Microsoft.Azure.Commands.Network.NewAzureNetworkWatcherPacketCaptureCommandV2","New-AzNetworkWatcherPacketCaptureV2","0","3030","The generic type for 'parameter TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ","Change the generic type for 'parameter TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'."
1+
Module,ClassName,Target,Severity,ProblemId,Description,Remediation
2+
Az.Network,Microsoft.Azure.Commands.Network.Automation.GetAzureRmDdosProtectionPlan,Get-AzDdosProtectionPlan,0,3010,The property 'PublicIpAddresses' of type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan' has been removed.,Add the property 'PublicIpAddresses' back to type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan'.
3+
Az.Network,Microsoft.Azure.Commands.Network.Automation.GetAzureRmDdosProtectionPlan,Get-AzDdosProtectionPlan,0,3010,The property 'PublicIpAddressesText' of type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan' has been removed.,Add the property 'PublicIpAddressesText' back to type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan'.
4+
Az.Network,Microsoft.Azure.Commands.Network.NewAzureRmDdosProtectionPlan,New-AzDdosProtectionPlan,0,3010,The property 'PublicIpAddresses' of type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan' has been removed.,Add the property 'PublicIpAddresses' back to type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan'.
5+
Az.Network,Microsoft.Azure.Commands.Network.NewAzureRmDdosProtectionPlan,New-AzDdosProtectionPlan,0,3010,The property 'PublicIpAddressesText' of type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan' has been removed.,Add the property 'PublicIpAddressesText' back to type 'Microsoft.Azure.Commands.Network.Models.PSDdosProtectionPlan'.
6+
Az.Network,Microsoft.Azure.Commands.Network.GetAzureNetworkWatcherPacketCaptureCommand,Get-AzNetworkWatcherPacketCapture,0,3030,The generic type for 'property TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ,Change the generic type for 'property TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'.
7+
Az.Network,Microsoft.Azure.Commands.Network.NewAzureNetworkWatcherPacketCaptureCommand,New-AzNetworkWatcherPacketCapture,0,3030,The generic type for 'property TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ,Change the generic type for 'property TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'.
8+
Az.Network,Microsoft.Azure.Commands.Network.NewAzureNetworkWatcherPacketCaptureCommand,New-AzNetworkWatcherPacketCapture,0,3030,The generic type for 'parameter TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ,Change the generic type for 'parameter TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'.
9+
Az.Network,Microsoft.Azure.Commands.Network.NewAzureNetworkWatcherPacketCaptureCommandV2,New-AzNetworkWatcherPacketCaptureV2,0,3030,The generic type for 'property TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ,Change the generic type for 'property TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'.
10+
Az.Network,Microsoft.Azure.Commands.Network.NewAzureNetworkWatcherPacketCaptureCommandV2,New-AzNetworkWatcherPacketCaptureV2,0,3030,The generic type for 'parameter TotalBytesPerSession' has been changed from 'System.Nullable`1[System.Int32]' to 'System.Nullable`1[System.UInt32]'. ,Change the generic type for 'parameter TotalBytesPerSession' back to 'System.Nullable`1[System.Int32]'.
11+
Az.Network,Microsoft.Azure.Commands.Network.GetAzureNetworkInterfaceCommand,Get-AzNetworkInterface,0,3030,The generic type for 'property GatewayLoadBalancer' has been changed from 'PSFrontendIPConfiguration' to 'PSResourceId'. ,Change the generic type for 'parameter GatewayLoadBalancer' back to 'PSFrontendIPConfiguration'.
12+
Az.Network,Microsoft.Azure.Commands.Network.NewAzureNetworkInterfaceCommand,New-AzNetworkInterface,0,3030,The generic type for 'property GatewayLoadBalancer' has been changed from 'PSFrontendIPConfiguration' to 'PSResourceId'. ,Change the generic type for 'parameter GatewayLoadBalancer' back to 'PSFrontendIPConfiguration'.

0 commit comments

Comments
 (0)