Skip to content

Commit 9e05424

Browse files
committed
add SqlSetting property to azure firewall policy and corresponding property creation cmdlet
1 parent 2fc1680 commit 9e05424

File tree

7 files changed

+90
-4
lines changed

7 files changed

+90
-4
lines changed

src/Network/Network/Az.Network.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
511511
'New-AzFirewallPolicyIntrusionDetectionBypassTraffic',
512512
'New-AzFirewallPolicyIntrusionDetectionSignatureOverride',
513513
'New-AzFirewallPolicyThreatIntelWhitelist',
514-
'New-AzFirewallPolicyDnsSetting', 'New-AzVirtualRouter',
514+
'New-AzFirewallPolicyDnsSetting', 'New-AzFirewallPolicySqlSetting',
515+
'New-AzVirtualRouter',
515516
'Remove-AzVirtualRouter', 'Get-AzVirtualRouter',
516517
'Update-AzVirtualRouter', 'Add-AzVirtualRouterPeer',
517518
'Update-AzVirtualRouterPeer', 'Remove-AzVirtualRouterPeer',

src/Network/Network/AzureFirewallPolicy/NewAzureFirewallPolicyCommand.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,17 @@ public class NewAzureFirewallPolicyCommand : AzureFirewallPolicyBaseCmdlet
7373
HelpMessage = "The base policy to inherit from")]
7474
public string BasePolicy { get; set; }
7575

76-
[Parameter(
76+
[Parameter(
7777
Mandatory = false,
7878
HelpMessage = "The DNS Setting")]
7979
public PSAzureFirewallPolicyDnsSettings DnsSetting { get; set; }
8080

81+
[Parameter(
82+
Mandatory = false,
83+
HelpMessage = "The SQL related setting"
84+
)]
85+
public PSAzureFirewallPolicySqlSettings SqlSetting { get; set; }
86+
8187
[Parameter(
8288
Mandatory = false,
8389
ValueFromPipelineByPropertyName = true,
@@ -143,7 +149,7 @@ public override void Execute()
143149

144150
base.Execute();
145151

146-
var present = NetworkBaseCmdlet.IsResourcePresent(() => GetAzureFirewallPolicy(this.ResourceGroupName, this.Name));
152+
var present = NetworkBaseCmdlet.IsResourcePresent(() => GetAzureFirewallPolicy(this.ResourceGroupName, this.Name));
147153
ConfirmAction(
148154
Force.IsPresent,
149155
string.Format(Properties.Resources.OverwritingResource, Name),
@@ -165,7 +171,9 @@ private PSAzureFirewallPolicy CreateAzureFirewallPolicy()
165171
ThreatIntelWhitelist = this.ThreatIntelWhitelist,
166172
BasePolicy = BasePolicy != null ? new Microsoft.Azure.Management.Network.Models.SubResource(BasePolicy) : null,
167173
DnsSettings = this.DnsSetting,
168-
Sku = new PSAzureFirewallPolicySku {
174+
SqlSettings = this.SqlSetting,
175+
Sku = new PSAzureFirewallPolicySku
176+
{
169177
Tier = this.SkuTier ?? MNM.FirewallPolicySkuTier.Standard
170178
},
171179
IntrusionDetection = this.IntrusionDetection,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 System.Management.Automation;
16+
using Microsoft.Azure.Commands.Network.Models;
17+
using System.Linq;
18+
19+
namespace Microsoft.Azure.Commands.Network
20+
{
21+
[Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "FirewallPolicySqlSetting", SupportsShouldProcess = true), OutputType(typeof(PSAzureFirewallPolicySqlSettings))]
22+
public class NewAzureFirewallSqlSettingCommand : NetworkBaseCmdlet
23+
{
24+
25+
[Parameter(
26+
Mandatory = false,
27+
HelpMessage = "Allow SQL server redirect mode traffic. By default this type of traffic is not allowed."
28+
)]
29+
public SwitchParameter AllowSqlRedirect { get; set; }
30+
31+
public override void Execute()
32+
{
33+
base.Execute();
34+
35+
var sqlSetting = new PSAzureFirewallPolicySqlSettings
36+
{
37+
AllowSqlRedirect = this.AllowSqlRedirect.IsPresent ? true : (bool?)null,
38+
};
39+
40+
WriteObject(sqlSetting);
41+
}
42+
43+
}
44+
}

src/Network/Network/ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
--->
2020

2121
## Upcoming Release
22+
* Added new property `SqlSetting` for Azure Firewall Policy cmdlets
23+
- `Get-AzFirewallPolicy`
24+
- `New-AzFirewallPolicy`
25+
* Added new to create new `SqlSetting` object for creating Azure Firewall Policy
26+
- `New-AzFirewallPolicySqlSetting`
2227

2328
## Version 4.14.0
2429
* Used case-insensitive comparison for ResourceId (Set/New-NetworkWatcherFlowLog)

src/Network/Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,13 +1340,15 @@ private static void Initialize()
13401340

13411341
// Azure Firewall Policies
13421342
// CNM to MNM
1343+
cfg.CreateMap<CNM.PSAzureFirewallPolicySqlSettings, MNM.FirewallPolicySQL>();
13431344
cfg.CreateMap<CNM.PSAzureFirewallPolicyRuleCollectionGroup, MNM.FirewallPolicyRuleCollectionGroup>();
13441345
cfg.CreateMap<CNM.PSAzureFirewallPolicy, MNM.FirewallPolicy>().ForCtorParam("dnsSettings", opt =>
13451346
{
13461347
opt.MapFrom(src => src.DnsSettings == null ? null : new MNM.DnsSettings(src.DnsSettings.Servers, src.DnsSettings.EnableProxy, null));
13471348
});
13481349

13491350
// MNM to CNM
1351+
cfg.CreateMap<MNM.FirewallPolicySQL, CNM.PSAzureFirewallPolicySqlSettings>();
13501352
cfg.CreateMap<MNM.FirewallPolicyRuleCollectionGroup, CNM.PSAzureFirewallPolicyRuleCollectionGroup>();
13511353
cfg.CreateMap<MNM.FirewallPolicy, CNM.PSAzureFirewallPolicy>();
13521354

src/Network/Network/Models/AzureFirewallPolicy/PSAzureFirewallPolicy.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class PSAzureFirewallPolicy : PSTopLevelResource
4444

4545
public PSAzureFirewallPolicyDnsSettings DnsSettings { get; set; }
4646

47+
public PSAzureFirewallPolicySqlSettings SqlSettings { get; set; }
48+
4749
public PSAzureFirewallPolicyIntrusionDetection IntrusionDetection { get; set; }
4850

4951
public PSAzureFirewallPolicyTransportSecurity TransportSecurity { get; set; }
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
//
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+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
16+
using System.Collections.Generic;
17+
18+
namespace Microsoft.Azure.Commands.Network.Models
19+
{
20+
public class PSAzureFirewallPolicySqlSettings
21+
{
22+
public bool? AllowSqlRedirect { get; set; }
23+
}
24+
}

0 commit comments

Comments
 (0)