Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions src/Network/Network/AzureFirewall/NewAzureFirewallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,46 @@ private PSAzureFirewall CreateAzureFirewall()
}
else
{

if (FirewallPolicyId != null && (this.ApplicationRuleCollection != null || this.NetworkRuleCollection != null || this.NatRuleCollection != null))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like something that should be enforced through parameter sets - FirewallPolicyId should not be in the same parameter sets that include ApplicationRUleCollection or NetworkRuleCollection

@saisujithreddym saisujithreddym Jan 31, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am having trouble with the mutual exclusion scenario @markcowl placing firewall policy id in one parameter set and rule collections in another did not achieve the desired result.

I have tried various combinations but could not get it done. Do you have an example where we can achieve mutual exclusion using paramter sets? I will keep exploring as well

@saisujithreddym saisujithreddym Feb 3, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have decided to fail the call from NRP when there are both the policy and the rule collections. This way we need not make changes on the PS when we try to support policy+collections in case, show a message which is common across multiple platforms and track the usage. Also I would like to make a PR against network january branch and not the master. I have created another PR: #11013 am closing this one

{
throw new ArgumentException("Firewall Policy and Rule Collections cannot coexist");
}

var sku = new PSAzureFirewallSku();
sku.Name = MNM.AzureFirewallSkuName.AZFWVNet;
sku.Tier = MNM.AzureFirewallSkuTier.Standard;
firewall = new PSAzureFirewall()
if (FirewallPolicyId != null)
{
Name = this.Name,
ResourceGroupName = this.ResourceGroupName,
Location = this.Location,
ApplicationRuleCollections = this.ApplicationRuleCollection?.ToList(),
NatRuleCollections = this.NatRuleCollection?.ToList(),
NetworkRuleCollections = this.NetworkRuleCollection?.ToList(),
ThreatIntelMode = this.ThreatIntelMode ?? MNM.AzureFirewallThreatIntelMode.Alert,
ThreatIntelWhitelist = this.ThreatIntelWhitelist,
PrivateRange = this.PrivateRange,
Sku = sku
};
firewall = new PSAzureFirewall()
{
Name = this.Name,
ResourceGroupName = this.ResourceGroupName,
Location = this.Location,
FirewallPolicy = FirewallPolicyId != null ? new MNM.SubResource(FirewallPolicyId) : null,
ThreatIntelMode = this.ThreatIntelMode ?? MNM.AzureFirewallThreatIntelMode.Alert,
ThreatIntelWhitelist = this.ThreatIntelWhitelist,
PrivateRange = this.PrivateRange,
Sku = sku
};
}
else
{
firewall = new PSAzureFirewall()
{
Name = this.Name,
ResourceGroupName = this.ResourceGroupName,
Location = this.Location,
ApplicationRuleCollections = this.ApplicationRuleCollection?.ToList(),
NatRuleCollections = this.NatRuleCollection?.ToList(),
NetworkRuleCollections = this.NetworkRuleCollection?.ToList(),
ThreatIntelMode = this.ThreatIntelMode ?? MNM.AzureFirewallThreatIntelMode.Alert,
ThreatIntelWhitelist = this.ThreatIntelWhitelist,
PrivateRange = this.PrivateRange,
Sku = sku
};
}


if (this.Zone != null)
{
Expand Down