<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Azure Firewall Policy Rules to CSV	</title>
	<atom:link href="https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/</link>
	<description>Remarks from a Cloud Architect encounters</description>
	<lastBuildDate>Thu, 23 May 2024 03:24:12 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>
		By: Prasant Chettri		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-28058</link>

		<dc:creator><![CDATA[Prasant Chettri]]></dc:creator>
		<pubDate>Thu, 23 May 2024 03:24:12 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-28058</guid>

					<description><![CDATA[1) I was trying to make the write to multiple collection in a nested look which was failing. 
2) CSV IP range does require space after comma unlike the firewall rule which works without a space and update on its own]]></description>
			<content:encoded><![CDATA[<p>1) I was trying to make the write to multiple collection in a nested look which was failing.<br />
2) CSV IP range does require space after comma unlike the firewall rule which works without a space and update on its own</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: prashant		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-27619</link>

		<dc:creator><![CDATA[prashant]]></dc:creator>
		<pubDate>Mon, 20 May 2024 04:46:03 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-27619</guid>

					<description><![CDATA[The import policy fails with 400 error]]></description>
			<content:encoded><![CDATA[<p>The import policy fails with 400 error</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Prasant Chettri		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-25518</link>

		<dc:creator><![CDATA[Prasant Chettri]]></dc:creator>
		<pubDate>Mon, 06 May 2024 22:07:36 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-25518</guid>

					<description><![CDATA[It looks like it may work for single Rule collection as it is building one rule collection and sub rules when I am parsing it. 

I have one rule collection group for network.7 rule collection for management, monitor, services etc and rules under each rule collection based on the priority]]></description>
			<content:encoded><![CDATA[<p>It looks like it may work for single Rule collection as it is building one rule collection and sub rules when I am parsing it. </p>
<p>I have one rule collection group for network.7 rule collection for management, monitor, services etc and rules under each rule collection based on the priority</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Prasant Chettri		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-25489</link>

		<dc:creator><![CDATA[Prasant Chettri]]></dc:creator>
		<pubDate>Mon, 06 May 2024 17:04:01 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-25489</guid>

					<description><![CDATA[Export works fine but the import script gives error building table. I added try fetch and it generates error right the foreach ($entry in $RulesfromCSV) when it is reading two sets of tables from excel for rule and rule collection and after that it breaks on all the following. 
Has anyone had any luck with import. I am starting with basic network rules that uses IP and IPgroups both?
foreach ($entry in $RulesfromCSV)
{
    $RuleParameter = @{
        Name = $entry.Name;
        protocols = $entry.protocols
        SourceAddresses = $entry.SourceAddresses
        DestinationAddresses = $entry.DestinationAddresses
        SourceIPGroups = $entry.SourceIPGroups
        DestinationIPGroups = $entry.DestinationIPGroups
        ActionType = $entry.ActionType
        DestinationPorts = $entry.DestinationPorts
    }
    try {
    $rule = New-AzFirewallPolicyNetworkRule @RuleParameter  -ErrorAction Stop   
    }
    catch {
        Write-Host &quot;2 - Error creating rule table based on excel data&quot;
    }
    $NetworkRuleCollection = @{
        RuleCollectionName = $entry.RuleCollectionName
        Priority = $entry.RulePriority
        ActionType = $entry.ActionType
        Rule       = $rules += $rule
    }
}]]></description>
			<content:encoded><![CDATA[<p>Export works fine but the import script gives error building table. I added try fetch and it generates error right the foreach ($entry in $RulesfromCSV) when it is reading two sets of tables from excel for rule and rule collection and after that it breaks on all the following.<br />
Has anyone had any luck with import. I am starting with basic network rules that uses IP and IPgroups both?<br />
foreach ($entry in $RulesfromCSV)<br />
{<br />
    $RuleParameter = @{<br />
        Name = $entry.Name;<br />
        protocols = $entry.protocols<br />
        SourceAddresses = $entry.SourceAddresses<br />
        DestinationAddresses = $entry.DestinationAddresses<br />
        SourceIPGroups = $entry.SourceIPGroups<br />
        DestinationIPGroups = $entry.DestinationIPGroups<br />
        ActionType = $entry.ActionType<br />
        DestinationPorts = $entry.DestinationPorts<br />
    }<br />
    try {<br />
    $rule = New-AzFirewallPolicyNetworkRule @RuleParameter  -ErrorAction Stop<br />
    }<br />
    catch {<br />
        Write-Host &#8220;2 &#8211; Error creating rule table based on excel data&#8221;<br />
    }<br />
    $NetworkRuleCollection = @{<br />
        RuleCollectionName = $entry.RuleCollectionName<br />
        Priority = $entry.RulePriority<br />
        ActionType = $entry.ActionType<br />
        Rule       = $rules += $rule<br />
    }<br />
}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Prasant Chettri		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-25486</link>

		<dc:creator><![CDATA[Prasant Chettri]]></dc:creator>
		<pubDate>Mon, 06 May 2024 16:57:15 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-25486</guid>

					<description><![CDATA[export works fine but import gives error building table. I added try fetch and it generates error right the foreach ($entry in $RulesfromCSV) when it is reading two sets of table from excel for rule and rule collection and after that it breaks on all the following. 
Has anyone had any luck with import. I am starting with basic network rules that uses IP and IPgroups both]]></description>
			<content:encoded><![CDATA[<p>export works fine but import gives error building table. I added try fetch and it generates error right the foreach ($entry in $RulesfromCSV) when it is reading two sets of table from excel for rule and rule collection and after that it breaks on all the following.<br />
Has anyone had any luck with import. I am starting with basic network rules that uses IP and IPgroups both</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Pantelis Apostolidis		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-23537</link>

		<dc:creator><![CDATA[Pantelis Apostolidis]]></dc:creator>
		<pubDate>Tue, 23 Apr 2024 05:57:02 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-23537</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-20900&quot;&gt;Larry Brandt&lt;/a&gt;.

Thank you so much for sharing Larry!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-20900">Larry Brandt</a>.</p>
<p>Thank you so much for sharing Larry!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Larry Brandt		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-20900</link>

		<dc:creator><![CDATA[Larry Brandt]]></dc:creator>
		<pubDate>Wed, 31 Jan 2024 22:10:46 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-20900</guid>

					<description><![CDATA[Thanks for this script.  I went ahead and poorly modified it to work for url logs as i was getting errors.  its not pretty, but it works.

#Provide Input. Firewall Policy Name, Firewall Policy Resource Group &#038; Firewall Policy Rule Collection Group Name
$fpname = &quot;policyname&quot;
$fprg = &quot;resourcegroupname&quot;
$fprcgname = &quot;DefaultApplicationRuleCollectionGroup&quot;
$sub = &quot;subscriptionname&quot;
$file = &quot;./urlrules.csv&quot;

Connect-AzAccount
Set-AzContext -subscription $sub
$fp = Get-AzFirewallPolicy -Name $fpname -ResourceGroupName $fprg
$rcg = Get-AzFirewallPolicyRuleCollectionGroup -Name $fprcgname -AzureFirewallPolicy $fp

$returnObj = @()
foreach ($rulecol in $rcg.Properties.RuleCollection) {

foreach ($rule in $rulecol.rules)
{
$combined = $null
foreach ($protocol in $rule.protocols)
{
if ($combined -ne $null)
{
$combined = $combined += &quot;,&quot;
}
$combined = $combined += ForEach-Object { $protocol.ProtocolType + &#039;:&#039; + $protocol.Port }
} 
    
$properties = [ordered]@{
    RuleCollectionName = $rulecol.Name;
    RulePriority = $rulecol.Priority;
    ActionType = $rulecol.Action.Type;
    RUleConnectionType = $rulecol.RuleCollectionType;
    Name = $rule.Name;
    SourceAddresses = $rule.SourceAddresses -join &quot;, &quot;;
    protocols = $combined;
    TargetFqdns = $rule.TargetFqdns -join &quot;, &quot;;
    TerminateTLS = $rule.TerminateTLS -join &quot;, &quot;;

}
$obj = New-Object psobject -Property $properties
$returnObj += $obj

}
#$returnObj
$returnObj &#124; Export-Csv $file -NoTypeInformation
}]]></description>
			<content:encoded><![CDATA[<p>Thanks for this script.  I went ahead and poorly modified it to work for url logs as i was getting errors.  its not pretty, but it works.</p>
<p>#Provide Input. Firewall Policy Name, Firewall Policy Resource Group &amp; Firewall Policy Rule Collection Group Name<br />
$fpname = &#8220;policyname&#8221;<br />
$fprg = &#8220;resourcegroupname&#8221;<br />
$fprcgname = &#8220;DefaultApplicationRuleCollectionGroup&#8221;<br />
$sub = &#8220;subscriptionname&#8221;<br />
$file = &#8220;./urlrules.csv&#8221;</p>
<p>Connect-AzAccount<br />
Set-AzContext -subscription $sub<br />
$fp = Get-AzFirewallPolicy -Name $fpname -ResourceGroupName $fprg<br />
$rcg = Get-AzFirewallPolicyRuleCollectionGroup -Name $fprcgname -AzureFirewallPolicy $fp</p>
<p>$returnObj = @()<br />
foreach ($rulecol in $rcg.Properties.RuleCollection) {</p>
<p>foreach ($rule in $rulecol.rules)<br />
{<br />
$combined = $null<br />
foreach ($protocol in $rule.protocols)<br />
{<br />
if ($combined -ne $null)<br />
{<br />
$combined = $combined += &#8220;,&#8221;<br />
}<br />
$combined = $combined += ForEach-Object { $protocol.ProtocolType + &#8216;:&#8217; + $protocol.Port }<br />
} </p>
<p>$properties = [ordered]@{<br />
    RuleCollectionName = $rulecol.Name;<br />
    RulePriority = $rulecol.Priority;<br />
    ActionType = $rulecol.Action.Type;<br />
    RUleConnectionType = $rulecol.RuleCollectionType;<br />
    Name = $rule.Name;<br />
    SourceAddresses = $rule.SourceAddresses -join &#8220;, &#8220;;<br />
    protocols = $combined;<br />
    TargetFqdns = $rule.TargetFqdns -join &#8220;, &#8220;;<br />
    TerminateTLS = $rule.TerminateTLS -join &#8220;, &#8220;;</p>
<p>}<br />
$obj = New-Object psobject -Property $properties<br />
$returnObj += $obj</p>
<p>}<br />
#$returnObj<br />
$returnObj | Export-Csv $file -NoTypeInformation<br />
}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Paul Arnold		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-15401</link>

		<dc:creator><![CDATA[Paul Arnold]]></dc:creator>
		<pubDate>Thu, 27 Apr 2023 20:53:55 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-15401</guid>

					<description><![CDATA[This was very useful. I had to add the Connect-AzAccount and Set-AzContext to the beginning since we have multiple subscriptions.
I set the $fprcgname to my Rule Collection Group within my Policy and it extracted the rules without issue. 
I have not tried the import function.
Thanks for sharing!]]></description>
			<content:encoded><![CDATA[<p>This was very useful. I had to add the Connect-AzAccount and Set-AzContext to the beginning since we have multiple subscriptions.<br />
I set the $fprcgname to my Rule Collection Group within my Policy and it extracted the rules without issue.<br />
I have not tried the import function.<br />
Thanks for sharing!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: James		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-14779</link>

		<dc:creator><![CDATA[James]]></dc:creator>
		<pubDate>Wed, 22 Mar 2023 11:36:59 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-14779</guid>

					<description><![CDATA[Unfortunately, only works with 1 Rule collection. 
Script pastes all rules in 1 Rule collection.

I hope you can fix this, will be very useful.]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, only works with 1 Rule collection.<br />
Script pastes all rules in 1 Rule collection.</p>
<p>I hope you can fix this, will be very useful.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Marek		</title>
		<link>https://www.cloudcorner.gr/microsoft/azure/azure-firewall-policy-rules-to-csv/#comment-14059</link>

		<dc:creator><![CDATA[Marek]]></dc:creator>
		<pubDate>Tue, 14 Feb 2023 06:57:31 +0000</pubDate>
		<guid isPermaLink="false">https://www.cloudcorner.gr/?p=3903#comment-14059</guid>

					<description><![CDATA[Hi 

i find your code. I have question.
This export ONLY DefaultNetworkRuleCollectionGroup.
If we have 10s on rule collection is there any way how to do this?]]></description>
			<content:encoded><![CDATA[<p>Hi </p>
<p>i find your code. I have question.<br />
This export ONLY DefaultNetworkRuleCollectionGroup.<br />
If we have 10s on rule collection is there any way how to do this?</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
