Skip to content

Commit ff3bb79

Browse files
committed
Merge pull request #668 from kagamsft/dev
Cert and SET cmdlets bugfix.
2 parents 8201cb3 + 68d7175 commit ff3bb79

File tree

39 files changed

+8529
-997
lines changed

39 files changed

+8529
-997
lines changed

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/ApplicationGatewayTests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ function Test-ApplicationGatewayCRUD
5656
$poolSetting = New-AzureApplicationGatewayBackendHttpSettings -Name $poolSettingName -Port 80 -Protocol HTTP -CookieBasedAffinity Disabled
5757
$fp = New-AzureApplicationGatewayFrontendPort -Name $frontendPortName -Port 80
5858
$fipconfig = New-AzureApplicationGatewayFrontendIPConfig -Name $fipconfigName -PublicIPAddress $publicip
59-
$listener = New-AzureApplicationGatewayHttpListener -Name $listenerName -Protocol http -FrontendIpConfiguration $fipconfig -FrontendPort $fp
59+
$listener = New-AzureApplicationGatewayHttpListener -Name $listenerName -Protocol http -FrontendIPConfiguration $fipconfig -FrontendPort $fp
6060
$rule = New-AzureApplicationGatewayRequestRoutingRule -Name $ruleName -RuleType basic -BackendHttpSettings $poolSetting -HttpListener $listener -BackendAddressPool $pool
6161
$sku = New-AzureApplicationGatewaySku -Name Standard_Small -Tier Standard -Capacity 2
6262

63-
# $actual = New-AzureApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting -FrontendIpConfigurations $fipconfig -GatewayIpConfigurations $gipconfig -FrontendPorts $fp -HttpListeners $listener -RequestRoutingRules $rule -Sku $sku
64-
# $expected = Get-AzureApplicationGateway -Name $appgwName -ResourceGroupName $rgname
65-
# Compare-AzureApplicationGateway $actual $expected
63+
$actual = New-AzureApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting -FrontendIpConfigurations $fipconfig -GatewayIpConfigurations $gipconfig -FrontendPorts $fp -HttpListeners $listener -RequestRoutingRules $rule -Sku $sku
64+
$expected = Get-AzureApplicationGateway -Name $appgwName -ResourceGroupName $rgname
65+
Compare-AzureApplicationGateway $actual $expected
6666

67-
# Stop-AzureApplicationGateway -ApplicationGateway $expected
68-
# Remove-AzureApplicationGateway -Name $appgwName -ResourceGroupName $rgname
67+
Stop-AzureApplicationGateway -ApplicationGateway $expected
68+
Remove-AzureApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Force
6969
}
7070
finally
7171
{

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.ApplicationGatewayTests/TestApplicationGatewayCRUD.json

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

src/ResourceManager/Network/Commands.Network/ApplicationGateway/BackendAddressPool/AddAzureApplicationGatewayBackendAddressPoolCommand.cs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,46 +41,7 @@ public override void ExecuteCmdlet()
4141
throw new ArgumentException("Backend address pool with the specified name already exists");
4242
}
4343

44-
backendAddressPool = new PSApplicationGatewayBackendAddressPool();
45-
46-
backendAddressPool.Name = this.Name;
47-
48-
if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResourceId))
49-
{
50-
backendAddressPool.BackendIpConfigurations = new System.Collections.Generic.List<PSResourceId>();
51-
foreach (string id in this.BackendIPConfigurationIds)
52-
{
53-
var backendIpConfig = new PSResourceId();
54-
backendIpConfig.Id = id;
55-
backendAddressPool.BackendIpConfigurations.Add(backendIpConfig);
56-
}
57-
}
58-
else if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByIP))
59-
{
60-
backendAddressPool.BackendAddresses = new System.Collections.Generic.List<PSApplicationGatewayBackendAddress>();
61-
foreach (string ip in this.BackendIPAddresses)
62-
{
63-
var backendAddress = new PSApplicationGatewayBackendAddress();
64-
backendAddress.IpAddress = ip;
65-
backendAddressPool.BackendAddresses.Add(backendAddress);
66-
}
67-
}
68-
else
69-
{
70-
backendAddressPool.BackendAddresses = new System.Collections.Generic.List<PSApplicationGatewayBackendAddress>();
71-
foreach (string fqdn in this.BackendFqdns)
72-
{
73-
var backendAddress = new PSApplicationGatewayBackendAddress();
74-
backendAddress.Fqdn = fqdn;
75-
backendAddressPool.BackendAddresses.Add(backendAddress);
76-
}
77-
}
78-
79-
backendAddressPool.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
80-
this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
81-
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayBackendAddressPoolName,
82-
this.Name);
83-
44+
backendAddressPool = base.NewObject();
8445
this.ApplicationGateway.BackendAddressPools.Add(backendAddressPool);
8546

8647
WriteObject(this.ApplicationGateway);

src/ResourceManager/Network/Commands.Network/ApplicationGateway/BackendAddressPool/AzureApplicationGatewayBackendAddressPoolBase.cs

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,51 @@ public class AzureApplicationGatewayBackendAddressPoolBase : NetworkBaseCmdlet
4343
ParameterSetName = "SetByFqdn",
4444
HelpMessage = "FQDNs of application gateway backend servers")]
4545
[ValidateNotNullOrEmpty]
46-
public List<string> BackendFqdns { get; set; }
47-
public override void ExecuteCmdlet()
46+
public List<string> BackendFqdns { get; set; }
47+
48+
public PSApplicationGatewayBackendAddressPool NewObject()
4849
{
49-
base.ExecuteCmdlet();
50+
var backendAddressPool = new PSApplicationGatewayBackendAddressPool();
51+
52+
backendAddressPool.Name = this.Name;
53+
54+
if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResourceId))
55+
{
56+
backendAddressPool.BackendIpConfigurations = new System.Collections.Generic.List<PSResourceId>();
57+
foreach (string id in this.BackendIPConfigurationIds)
58+
{
59+
var backendIpConfig = new PSResourceId();
60+
backendIpConfig.Id = id;
61+
backendAddressPool.BackendIpConfigurations.Add(backendIpConfig);
62+
}
63+
}
64+
else if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByIP))
65+
{
66+
backendAddressPool.BackendAddresses = new System.Collections.Generic.List<PSApplicationGatewayBackendAddress>();
67+
foreach (string ip in this.BackendIPAddresses)
68+
{
69+
var backendAddress = new PSApplicationGatewayBackendAddress();
70+
backendAddress.IpAddress = ip;
71+
backendAddressPool.BackendAddresses.Add(backendAddress);
72+
}
73+
}
74+
else
75+
{
76+
backendAddressPool.BackendAddresses = new System.Collections.Generic.List<PSApplicationGatewayBackendAddress>();
77+
foreach (string fqdn in this.BackendFqdns)
78+
{
79+
var backendAddress = new PSApplicationGatewayBackendAddress();
80+
backendAddress.Fqdn = fqdn;
81+
backendAddressPool.BackendAddresses.Add(backendAddress);
82+
}
83+
}
84+
85+
backendAddressPool.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
86+
this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
87+
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayBackendAddressPoolName,
88+
this.Name);
89+
90+
return backendAddressPool;
5091
}
5192
}
5293
}

src/ResourceManager/Network/Commands.Network/ApplicationGateway/BackendAddressPool/NewAzureApplicationGatewayBackendAddressPoolCommand.cs

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,7 @@ public class NewAzureApplicationGatewayBackendAddressPoolCommand : AzureApplicat
2424
public override void ExecuteCmdlet()
2525
{
2626
base.ExecuteCmdlet();
27-
28-
var backendAddressPool = new PSApplicationGatewayBackendAddressPool();
29-
30-
backendAddressPool.Name = this.Name;
31-
32-
if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResourceId))
33-
{
34-
backendAddressPool.BackendIpConfigurations = new System.Collections.Generic.List<PSResourceId>();
35-
foreach (string id in this.BackendIPConfigurationIds)
36-
{
37-
var backendIpConfig = new PSResourceId();
38-
backendIpConfig.Id = id;
39-
backendAddressPool.BackendIpConfigurations.Add(backendIpConfig);
40-
}
41-
}
42-
else if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByIP))
43-
{
44-
backendAddressPool.BackendAddresses = new System.Collections.Generic.List<PSApplicationGatewayBackendAddress>();
45-
foreach (string ip in this.BackendIPAddresses)
46-
{
47-
var backendAddress = new PSApplicationGatewayBackendAddress();
48-
backendAddress.IpAddress = ip;
49-
backendAddressPool.BackendAddresses.Add(backendAddress);
50-
}
51-
}
52-
else
53-
{
54-
backendAddressPool.BackendAddresses = new System.Collections.Generic.List<PSApplicationGatewayBackendAddress>();
55-
foreach (string fqdn in this.BackendFqdns)
56-
{
57-
var backendAddress = new PSApplicationGatewayBackendAddress();
58-
backendAddress.Fqdn = fqdn;
59-
backendAddressPool.BackendAddresses.Add(backendAddress);
60-
}
61-
}
62-
63-
backendAddressPool.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
64-
this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
65-
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayBackendAddressPoolName,
66-
this.Name);
67-
68-
WriteObject(backendAddressPool);
27+
WriteObject(base.NewObject());
6928
}
7029
}
7130
}

src/ResourceManager/Network/Commands.Network/ApplicationGateway/BackendAddressPool/SetAzureApplicationGatewayBackendAddressPoolCommand.cs

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,47 +40,10 @@ public override void ExecuteCmdlet()
4040
throw new ArgumentException("Backend address pool with the specified name does not exist");
4141
}
4242

43-
backendAddressPool = new PSApplicationGatewayBackendAddressPool();
43+
var newbackendAddressPool = base.NewObject();
4444

45-
backendAddressPool.Name = this.Name;
46-
47-
if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResourceId))
48-
{
49-
backendAddressPool.BackendIpConfigurations = new System.Collections.Generic.List<PSResourceId>();
50-
foreach (string id in this.BackendIPConfigurationIds)
51-
{
52-
var backendIpConfig = new PSResourceId();
53-
backendIpConfig.Id = id;
54-
backendAddressPool.BackendIpConfigurations.Add(backendIpConfig);
55-
}
56-
}
57-
else if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByIP))
58-
{
59-
backendAddressPool.BackendAddresses = new System.Collections.Generic.List<PSApplicationGatewayBackendAddress>();
60-
foreach (string ip in this.BackendIPAddresses)
61-
{
62-
var backendAddress = new PSApplicationGatewayBackendAddress();
63-
backendAddress.IpAddress = ip;
64-
backendAddressPool.BackendAddresses.Add(backendAddress);
65-
}
66-
}
67-
else
68-
{
69-
backendAddressPool.BackendAddresses = new System.Collections.Generic.List<PSApplicationGatewayBackendAddress>();
70-
foreach (string fqdn in this.BackendFqdns)
71-
{
72-
var backendAddress = new PSApplicationGatewayBackendAddress();
73-
backendAddress.Fqdn = fqdn;
74-
backendAddressPool.BackendAddresses.Add(backendAddress);
75-
}
76-
}
77-
78-
backendAddressPool.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
79-
this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
80-
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayBackendAddressPoolName,
81-
this.Name);
82-
83-
this.ApplicationGateway.BackendAddressPools.Add(backendAddressPool);
45+
this.ApplicationGateway.BackendAddressPools.Remove(backendAddressPool);
46+
this.ApplicationGateway.BackendAddressPools.Add(newbackendAddressPool);
8447

8548
WriteObject(this.ApplicationGateway);
8649
}

src/ResourceManager/Network/Commands.Network/ApplicationGateway/BackendHttpSettings/AddAzureApplicationGatewayBackendHttpSettingsCommand.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,7 @@ public override void ExecuteCmdlet()
4141
throw new ArgumentException("Backend http settings with the specified name already exists");
4242
}
4343

44-
backendHttpSettings = new PSApplicationGatewayBackendHttpSettings();
45-
backendHttpSettings.Name = this.Name;
46-
backendHttpSettings.Port = this.Port;
47-
backendHttpSettings.Protocol = this.Protocol;
48-
backendHttpSettings.CookieBasedAffinity = this.CookieBasedAffinity;
49-
backendHttpSettings.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
50-
this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
51-
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewaybackendHttpSettingsName,
52-
this.Name);
53-
44+
backendHttpSettings = base.NewObject();
5445
this.ApplicationGateway.BackendHttpSettingsCollection.Add(backendHttpSettings);
5546

5647
WriteObject(this.ApplicationGateway);

src/ResourceManager/Network/Commands.Network/ApplicationGateway/BackendHttpSettings/AzureApplicationGatewayBackendHttpSettingsBase.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,19 @@ public class AzureApplicationGatewayBackendHttpSettingsBase : NetworkBaseCmdlet
4646
[ValidateSet("Enabled", "Disabled", IgnoreCase = true)]
4747
[ValidateNotNullOrEmpty]
4848
public string CookieBasedAffinity { get; set; }
49+
50+
public PSApplicationGatewayBackendHttpSettings NewObject()
51+
{
52+
var backendHttpSettings = new PSApplicationGatewayBackendHttpSettings();
53+
backendHttpSettings.Name = this.Name;
54+
backendHttpSettings.Port = this.Port;
55+
backendHttpSettings.Protocol = this.Protocol;
56+
backendHttpSettings.CookieBasedAffinity = this.CookieBasedAffinity;
57+
backendHttpSettings.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
58+
this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
59+
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewaybackendHttpSettingsName,
60+
this.Name);
61+
return backendHttpSettings;
62+
}
4963
}
5064
}

src/ResourceManager/Network/Commands.Network/ApplicationGateway/BackendHttpSettings/NewAzureApplicationGatewayBackendHttpSettingsCommand.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,8 @@ public class NewAzureApplicationGatewayBackendHttpSettingsCommand : AzureApplica
2323
{
2424
public override void ExecuteCmdlet()
2525
{
26-
base.ExecuteCmdlet();
27-
28-
var backendHttpSettings = new PSApplicationGatewayBackendHttpSettings();
29-
backendHttpSettings.Name = this.Name;
30-
backendHttpSettings.Port = this.Port;
31-
backendHttpSettings.Protocol = this.Protocol;
32-
backendHttpSettings.CookieBasedAffinity = this.CookieBasedAffinity;
33-
backendHttpSettings.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
34-
this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
35-
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewaybackendHttpSettingsName,
36-
this.Name);
37-
38-
WriteObject(backendHttpSettings);
26+
base.ExecuteCmdlet();
27+
WriteObject(base.NewObject());
3928
}
4029
}
4130
}

src/ResourceManager/Network/Commands.Network/ApplicationGateway/BackendHttpSettings/SetAzureApplicationGatewayBackendHttpSettingsCommand.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,18 @@ public override void ExecuteCmdlet()
3333
{
3434
base.ExecuteCmdlet();
3535

36-
var backendHttpSettings = this.ApplicationGateway.BackendHttpSettingsCollection.SingleOrDefault
36+
var oldBackendHttpSettings = this.ApplicationGateway.BackendHttpSettingsCollection.SingleOrDefault
3737
(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));
3838

39-
if (backendHttpSettings == null)
39+
if (oldBackendHttpSettings == null)
4040
{
4141
throw new ArgumentException("Backend http settings with the specified name does not exist");
4242
}
4343

44-
backendHttpSettings = new PSApplicationGatewayBackendHttpSettings();
45-
backendHttpSettings.Name = this.Name;
46-
backendHttpSettings.Port = this.Port;
47-
backendHttpSettings.Protocol = this.Protocol;
48-
backendHttpSettings.CookieBasedAffinity = this.CookieBasedAffinity;
49-
backendHttpSettings.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
50-
this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
51-
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewaybackendHttpSettingsName,
52-
this.Name);
53-
54-
this.ApplicationGateway.BackendHttpSettingsCollection.Add(backendHttpSettings);
44+
var newBackendHttpSettings = base.NewObject();
45+
46+
this.ApplicationGateway.BackendHttpSettingsCollection.Remove(oldBackendHttpSettings);
47+
this.ApplicationGateway.BackendHttpSettingsCollection.Add(newBackendHttpSettings);
5548

5649
WriteObject(this.ApplicationGateway);
5750
}

0 commit comments

Comments
 (0)