Skip to content

Commit 0e38c74

Browse files
committed
ApplicationGateway Ssl Policy, Get AvailableSslOption, Redirect, Azure Websites and backendhealth nic fix
1 parent 65a956c commit 0e38c74

File tree

38 files changed

+1045
-20
lines changed

38 files changed

+1045
-20
lines changed

src/ResourceManager/Network/AzureRM.Network.psd1

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ CmdletsToExport = 'Add-AzureRmApplicationGatewayAuthenticationCertificate',
7777
'New-AzureRmApplicationGatewayAuthenticationCertificate',
7878
'Remove-AzureRmApplicationGatewayAuthenticationCertificate',
7979
'Set-AzureRmApplicationGatewayAuthenticationCertificate',
80-
'Get-AzureRmApplicationGatewayAvailableWafRuleSets',
80+
'Get-AzureRmApplicationGatewayAvailableWafRuleSets',
81+
'Get-AzureRmApplicationGatewayAvailableSslOptions',
8182
'Add-AzureRmApplicationGatewayBackendAddressPool',
8283
'Get-AzureRmApplicationGatewayBackendAddressPool',
8384
'New-AzureRmApplicationGatewayBackendAddressPool',
@@ -125,13 +126,20 @@ CmdletsToExport = 'Add-AzureRmApplicationGatewayAuthenticationCertificate',
125126
'New-AzureRmApplicationGatewayProbeConfig',
126127
'Remove-AzureRmApplicationGatewayProbeConfig',
127128
'Set-AzureRmApplicationGatewayProbeConfig',
129+
'New-AzureRmApplicationGatewayProbeHealthResponseMatch',
128130
'Remove-AzureRmApplicationGateway',
129131
'Add-AzureRmApplicationGatewayRequestRoutingRule',
130132
'Get-AzureRmApplicationGatewayRequestRoutingRule',
131133
'New-AzureRmApplicationGatewayRequestRoutingRule',
132134
'Remove-AzureRmApplicationGatewayRequestRoutingRule',
133-
'Set-AzureRmApplicationGatewayRequestRoutingRule',
134-
'Set-AzureRmApplicationGateway', 'Get-AzureRmApplicationGatewaySku',
135+
'Set-AzureRmApplicationGatewayRequestRoutingRule',
136+
'Add-AzureRmApplicationGatewayRedirectConfiguration',
137+
'Get-AzureRmApplicationGatewayRedirectConfiguration',
138+
'New-AzureRmApplicationGatewayRedirectConfiguration',
139+
'Remove-AzureRmApplicationGatewayRedirectConfiguration',
140+
'Set-AzureRmApplicationGatewayRedirectConfiguration',
141+
'Set-AzureRmApplicationGateway',
142+
'Get-AzureRmApplicationGatewaySku',
135143
'New-AzureRmApplicationGatewaySku',
136144
'Set-AzureRmApplicationGatewaySku',
137145
'Add-AzureRmApplicationGatewaySslCertificate',
@@ -143,6 +151,7 @@ CmdletsToExport = 'Add-AzureRmApplicationGatewayAuthenticationCertificate',
143151
'New-AzureRmApplicationGatewaySslPolicy',
144152
'Remove-AzureRmApplicationGatewaySslPolicy',
145153
'Set-AzureRmApplicationGatewaySslPolicy',
154+
'Get-AzureRmApplicationGatewaySslPredefinedPolicy',
146155
'Start-AzureRmApplicationGateway', 'Stop-AzureRmApplicationGateway',
147156
'Add-AzureRmApplicationGatewayUrlPathMapConfig',
148157
'Get-AzureRmApplicationGatewayUrlPathMapConfig',
@@ -297,7 +306,8 @@ CmdletsToExport = 'Add-AzureRmApplicationGatewayAuthenticationCertificate',
297306
# VariablesToExport = @()
298307

299308
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
300-
AliasesToExport = 'List-AzureRmApplicationGatewayAvailableWafRuleSets'
309+
AliasesToExport = 'List-AzureRmApplicationGatewayAvailableWafRuleSets',
310+
'List-AzureRmApplicationGatewayAvailableSslOptions'
301311

302312
# DSC resources to export from this module
303313
# DscResourcesToExport = @()

src/ResourceManager/Network/Commands.Network/ApplicationGateway/ApplicationGatewayChildResourceHelper.cs

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,27 +195,54 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
195195
{
196196
urlPathMap.Id = string.Empty;
197197

198-
urlPathMap.DefaultBackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
198+
if (null != urlPathMap.DefaultBackendAddressPool)
199+
{
200+
urlPathMap.DefaultBackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
199201
urlPathMap.DefaultBackendAddressPool.Id,
200202
applicationGateway.ResourceGroupName,
201203
applicationGateway.Name);
202-
203-
urlPathMap.DefaultBackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
204+
}
205+
if (null != urlPathMap.DefaultBackendHttpSettings)
206+
{
207+
urlPathMap.DefaultBackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
204208
urlPathMap.DefaultBackendHttpSettings.Id,
205209
applicationGateway.ResourceGroupName,
206210
applicationGateway.Name);
211+
}
212+
if (null != urlPathMap.DefaultRedirectConfiguration)
213+
{
214+
215+
urlPathMap.DefaultRedirectConfiguration.Id = NormalizeApplicationGatewayNameChildResourceIds(
216+
urlPathMap.DefaultRedirectConfiguration.Id,
217+
applicationGateway.ResourceGroupName,
218+
applicationGateway.Name);
219+
}
207220

208221
foreach (var pathRule in urlPathMap.PathRules)
209222
{
210-
pathRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
223+
if (null != pathRule.BackendAddressPool)
224+
{
225+
pathRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
211226
pathRule.BackendAddressPool.Id,
212227
applicationGateway.ResourceGroupName,
213228
applicationGateway.Name);
229+
}
214230

215-
pathRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
231+
if (null != pathRule.BackendHttpSettings)
232+
{
233+
pathRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
216234
pathRule.BackendHttpSettings.Id,
217235
applicationGateway.ResourceGroupName,
218236
applicationGateway.Name);
237+
}
238+
239+
if (null != pathRule.RedirectConfiguration)
240+
{
241+
pathRule.RedirectConfiguration.Id = NormalizeApplicationGatewayNameChildResourceIds(
242+
pathRule.RedirectConfiguration.Id,
243+
applicationGateway.ResourceGroupName,
244+
applicationGateway.Name);
245+
}
219246
}
220247
}
221248
}
@@ -255,6 +282,31 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
255282
applicationGateway.ResourceGroupName,
256283
applicationGateway.Name);
257284
}
285+
286+
if (null != requestRoutingRule.RedirectConfiguration)
287+
{
288+
requestRoutingRule.RedirectConfiguration.Id = NormalizeApplicationGatewayNameChildResourceIds(
289+
requestRoutingRule.RedirectConfiguration.Id,
290+
applicationGateway.ResourceGroupName,
291+
applicationGateway.Name);
292+
}
293+
}
294+
295+
// Normalize RedirectConfiguration
296+
if (applicationGateway.RedirectConfigurations != null)
297+
{
298+
foreach (var redirectConfiguration in applicationGateway.RedirectConfigurations)
299+
{
300+
redirectConfiguration.Id = string.Empty;
301+
302+
if (null != redirectConfiguration.TargetListener)
303+
{
304+
redirectConfiguration.TargetListener.Id = NormalizeApplicationGatewayNameChildResourceIds(
305+
redirectConfiguration.TargetListener.Id,
306+
applicationGateway.ResourceGroupName,
307+
applicationGateway.Name);
308+
}
309+
}
258310
}
259311
}
260312
}

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,28 @@ public class AzureApplicationGatewayBackendHttpSettingsBase : NetworkBaseCmdlet
7777
[ValidateNotNullOrEmpty]
7878
public List<PSApplicationGatewayAuthenticationCertificate> AuthenticationCertificates { get; set; }
7979

80+
[Parameter(
81+
Mandatory = false,
82+
HelpMessage = "Whether to pick host header should be picked from the host name of the backend server. Default value is false")]
83+
public SwitchParameter PickHostNameFromBackendAddress { get; set; }
84+
85+
[Parameter(
86+
Mandatory = false,
87+
HelpMessage = "Cookie name to use for the affinity cookie")]
88+
[ValidateNotNullOrEmpty]
89+
public string AffinityCookieName { get; set; }
90+
91+
[Parameter(
92+
Mandatory = false,
93+
HelpMessage = "Whether the probe is enabled. Default value is false")]
94+
public SwitchParameter ProbeEnabled { get; set; }
95+
96+
[Parameter(
97+
Mandatory = false,
98+
HelpMessage = "Path which should be used as a prefix for all HTTP requests. Null means no path will be prefixed. Default value is null")]
99+
[ValidateNotNullOrEmpty]
100+
public string Path { get; set; }
101+
80102
public override void ExecuteCmdlet()
81103
{
82104
base.ExecuteCmdlet();
@@ -122,11 +144,22 @@ public PSApplicationGatewayBackendHttpSettings NewObject()
122144
});
123145
}
124146
}
147+
backendHttpSettings.PickHostNameFromBackendAddress = this.PickHostNameFromBackendAddress;
148+
if (this.AffinityCookieName != null)
149+
{
150+
backendHttpSettings.AffinityCookieName = this.AffinityCookieName;
151+
}
152+
backendHttpSettings.ProbeEnabled = this.ProbeEnabled;
153+
if (this.Path != null)
154+
{
155+
backendHttpSettings.Path = this.Path;
156+
}
125157

126158
backendHttpSettings.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
127159
this.NetworkClient.NetworkManagementClient.SubscriptionId,
128160
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewaybackendHttpSettingsName,
129161
this.Name);
162+
130163
return backendHttpSettings;
131164
}
132165
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using AutoMapper;
16+
using Microsoft.Azure.Commands.Common.Authentication;
17+
using Microsoft.Azure.Commands.Network.Models;
18+
using Microsoft.Azure.Management.Network;
19+
using Microsoft.WindowsAzure.Commands.Common;
20+
using System.IO;
21+
using System.Management.Automation;
22+
using System.Reflection;
23+
24+
namespace Microsoft.Azure.Commands.Network
25+
{
26+
[Cmdlet(VerbsCommon.Get, "AzureRmApplicationGatewayAvailableSslOptions"),
27+
OutputType(typeof(PSApplicationGatewayAvailableSslOptions))]
28+
[Alias("List-AzureRmApplicationGatewayAvailableSslOptions")]
29+
public class GetAzureApplicationGatewayAvailableSslOptions : ApplicationGatewayBaseCmdlet
30+
{
31+
public override void ExecuteCmdlet()
32+
{
33+
base.ExecuteCmdlet();
34+
35+
var availableSslOptions = this.ApplicationGatewayClient.AvailableSslOptions();
36+
var psAvailableSslOptions = Mapper.Map<PSApplicationGatewayAvailableSslOptions>(availableSslOptions);
37+
WriteObject(psAvailableSslOptions);
38+
}
39+
}
40+
}
41+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Network
16+
{
17+
using AutoMapper;
18+
using Microsoft.Azure.Commands.Network.Models;
19+
using Microsoft.Azure.Management.Network;
20+
using System.Collections.Generic;
21+
using System.Management.Automation;
22+
23+
[Cmdlet(VerbsCommon.Get, "AzureRmApplicationGatewaySslPredefinedPolicy"),
24+
OutputType(typeof(PSApplicationGatewaySslPredefinedPolicy), typeof(IEnumerable<PSApplicationGatewaySslPredefinedPolicy>))]
25+
[Alias("Get-AzureRmApplicationGatewaySslPredefinedPolicy")]
26+
public class GetAzureApplicationGatewaySslPredefinedPolicy : ApplicationGatewayBaseCmdlet
27+
{
28+
[Parameter(
29+
Mandatory = false,
30+
HelpMessage = "Name of the ssl predefined policy")]
31+
[ValidateNotNullOrEmpty]
32+
public string PredefinedPolicyName { get; set; }
33+
34+
public override void ExecuteCmdlet()
35+
{
36+
base.ExecuteCmdlet();
37+
if (this.PredefinedPolicyName != null)
38+
{
39+
var policy = this.ApplicationGatewayClient.GetSslPredefinedPolicy(this.PredefinedPolicyName);
40+
var psPolicy = Mapper.Map<PSApplicationGatewaySslPredefinedPolicy>(policy);
41+
WriteObject(psPolicy);
42+
}
43+
else
44+
{
45+
var policies = this.ApplicationGatewayClient.ListAvailableSslPredefinedPolicies();
46+
var psPolicies = new List<PSApplicationGatewaySslPolicy>();
47+
foreach (var policy in policies)
48+
{
49+
psPolicies.Add(Mapper.Map<PSApplicationGatewaySslPolicy>(policy));
50+
}
51+
52+
WriteObject(psPolicies);
53+
}
54+
}
55+
}
56+
}
57+

src/ResourceManager/Network/Commands.Network/ApplicationGateway/NewAzureApplicationGatewayCommand.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ public class NewAzureApplicationGatewayCommand : ApplicationGatewayBaseCmdlet
129129
HelpMessage = "The list of request routing rule")]
130130
public List<PSApplicationGatewayRequestRoutingRule> RequestRoutingRules { get; set; }
131131

132+
[Parameter(
133+
Mandatory = true,
134+
ValueFromPipelineByPropertyName = true,
135+
HelpMessage = "The list of redirect configuration")]
136+
public List<PSApplicationGatewayRedirectConfiguration> RedirectConfigurations { get; set; }
137+
132138
[Parameter(
133139
Mandatory = false,
134140
ValueFromPipelineByPropertyName = true,
@@ -234,6 +240,11 @@ private PSApplicationGateway CreateApplicationGateway()
234240
applicationGateway.RequestRoutingRules = this.RequestRoutingRules;
235241
}
236242

243+
if (this.RedirectConfigurations != null)
244+
{
245+
applicationGateway.RedirectConfigurations = this.RedirectConfigurations;
246+
}
247+
237248
if (this.WebApplicationFirewallConfiguration != null)
238249
{
239250
applicationGateway.WebApplicationFirewallConfiguration = this.WebApplicationFirewallConfiguration;

src/ResourceManager/Network/Commands.Network/ApplicationGateway/PathRule/AzureApplicationGatewayPathRuleConfigBase.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ public class AzureApplicationGatewayPathRuleConfigBase : NetworkBaseCmdlet
5656
[ValidateNotNullOrEmpty]
5757
public PSApplicationGatewayBackendHttpSettings BackendHttpSettings { get; set; }
5858

59+
[Parameter(
60+
ParameterSetName = "SetByResourceId",
61+
HelpMessage = "ID of the application gateway RedirectConfiguration")]
62+
[ValidateNotNullOrEmpty]
63+
public string RedirectConfigurationId { get; set; }
64+
65+
[Parameter(
66+
ParameterSetName = "SetByResource",
67+
HelpMessage = "Application gateway RedirectConfiguration")]
68+
[ValidateNotNullOrEmpty]
69+
public PSApplicationGatewayRedirectConfiguration RedirectConfiguration { get; set; }
70+
5971
public override void ExecuteCmdlet()
6072
{
6173
base.ExecuteCmdlet();
@@ -70,6 +82,10 @@ public override void ExecuteCmdlet()
7082
{
7183
this.BackendHttpSettingsId = this.BackendHttpSettings.Id;
7284
}
85+
if (RedirectConfiguration != null)
86+
{
87+
this.RedirectConfigurationId = this.RedirectConfiguration.Id;
88+
}
7389
}
7490
}
7591

@@ -92,6 +108,12 @@ public PSApplicationGatewayPathRule NewObject()
92108
pathRule.BackendHttpSettings.Id = this.BackendHttpSettingsId;
93109
}
94110

111+
if (!string.IsNullOrEmpty(this.RedirectConfigurationId))
112+
{
113+
pathRule.RedirectConfiguration = new PSResourceId();
114+
pathRule.RedirectConfiguration.Id = this.RedirectConfigurationId;
115+
}
116+
95117
return pathRule;
96118
}
97119
}

0 commit comments

Comments
 (0)