Skip to content

Commit f038b81

Browse files
Add new parameter to Azure Firewall (#28114)
Co-authored-by: Bhumika Kaur Matharu <[email protected]>
1 parent 13971a4 commit f038b81

File tree

9 files changed

+2340
-3
lines changed

9 files changed

+2340
-3
lines changed

src/Network/Network.Test/ScenarioTests/AzureFirewallTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ public void TestAzureFirewallCRUDEnableFatFlowLogging()
161161
TestRunner.RunTestScript("Test-AzureFirewallCRUDEnableFatFlowLogging");
162162
}
163163

164+
[Fact]
165+
[Trait(Category.AcceptanceType, Category.CheckIn)]
166+
[Trait(Category.Owner, NrpTeamAlias.azurefirewall)]
167+
public void TestAzureFirewallCRUDEnableDnstapLogging()
168+
{
169+
TestRunner.RunTestScript("Test-AzureFirewallCRUDEnableDnstapLogging");
170+
}
171+
164172
[Fact]
165173
[Trait(Category.AcceptanceType, Category.CheckIn)]
166174
[Trait(Category.Owner, NrpTeamAlias.azurefirewall)]

src/Network/Network.Test/ScenarioTests/AzureFirewallTests.ps1

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,50 @@ function Test-AzureFirewallCRUDEnableFatFlowLogging {
19231923
}
19241924
<#
19251925
.SYNOPSIS
1926+
Tests AzureFirewall EnableDnstapLogging
1927+
#>
1928+
function Test-AzureFirewallCRUDEnableDnstapLogging {
1929+
$rgname = Get-ResourceGroupName
1930+
$azureFirewallName = Get-ResourceName
1931+
$resourceTypeParent = "Microsoft.Network/AzureFirewalls"
1932+
$location = Get-ProviderLocation $resourceTypeParent "eastus"
1933+
1934+
$vnetName = Get-ResourceName
1935+
$subnetName = "AzureFirewallSubnet"
1936+
$publicIpName = Get-ResourceName
1937+
1938+
try {
1939+
# Create the resource group
1940+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location
1941+
1942+
# Create the Virtual Network
1943+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
1944+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
1945+
1946+
# Create public ip
1947+
$publicip = New-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $rgname -location $location -AllocationMethod Static -Sku Standard
1948+
1949+
# Create AzureFirewall
1950+
$azureFirewall = New-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname -Location $location -EnableDnstapLogging
1951+
1952+
# Verify
1953+
$azFirewall = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname
1954+
Assert-AreEqual true $azFirewall.EnableDnstapLogging
1955+
1956+
# Reset the EnableDnstapLogging flag
1957+
$azFirewall.EnableDnstapLogging = $false
1958+
Set-AzFirewall -AzureFirewall $azFirewall
1959+
$azfw = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname
1960+
1961+
Assert-AreEqual false $azfw.EnableDnstapLogging
1962+
}
1963+
finally {
1964+
# Cleanup
1965+
Clean-ResourceGroup $rgname
1966+
}
1967+
}
1968+
<#
1969+
.SYNOPSIS
19261970
Tests AzureFirewall with Multip IPs on Virtual Hub
19271971
#>
19281972
function Test-AzureFirewallVirtualHubPrivateIPAddress {

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.AzureFirewallTests/TestAzureFirewallCRUDEnableDnstapLogging.json

Lines changed: 2208 additions & 0 deletions
Large diffs are not rendered by default.

src/Network/Network/AzureFirewall/NewAzureFirewallCommand.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ public class NewAzureFirewallCommand : AzureFirewallBaseCmdlet
219219
)]
220220
public SwitchParameter EnableFatFlowLogging { get; set; }
221221

222+
[Parameter(
223+
Mandatory = false,
224+
HelpMessage = "Enable Dnstap Logging. By default it is false."
225+
)]
226+
public SwitchParameter EnableDnstapLogging { get; set; }
227+
222228
[Parameter(
223229
Mandatory = false,
224230
HelpMessage = "Enable UDP Log Optimization. By default it is false."
@@ -332,6 +338,7 @@ private PSAzureFirewall CreateAzureFirewall()
332338
HubIPAddresses = this.HubIPAddress,
333339
Zones = this.Zone == null ? null : this.Zone.ToList(),
334340
EnableFatFlowLogging = (this.EnableFatFlowLogging.IsPresent ? "True" : null),
341+
EnableDnstapLogging = (this.EnableDnstapLogging.IsPresent ? "True" : null),
335342
EnableUDPLogOptimization = (this.EnableUDPLogOptimization.IsPresent ? "True" : null)
336343
};
337344

@@ -359,6 +366,7 @@ private PSAzureFirewall CreateAzureFirewall()
359366
AllowActiveFTP = (this.AllowActiveFTP.IsPresent ? "true" : null),
360367
Sku = sku,
361368
EnableFatFlowLogging = (this.EnableFatFlowLogging.IsPresent ? "True" : null),
369+
EnableDnstapLogging = (this.EnableDnstapLogging.IsPresent ? "True" : null),
362370
EnableUDPLogOptimization = (this.EnableUDPLogOptimization.IsPresent ? "True" : null),
363371
RouteServerId = this.RouteServerId
364372
};

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
## Upcoming Release
2222
* Updated cmdlet `New-AzFirewallPolicyApplicationRule` to use HTTPS as the default protocol when creating a new FQDN Tag application rule.
23+
* Added `EnableDnstapLogging` parameter to `New-AzFirewall`
2324

2425
## Version 7.18.0
2526
* Added a new command which creates an object for CaptureSetting, and added properties 'FileCount', 'FileSizeInBytes', and 'SessionTimeLimitInSeconds', which helps to configure the capture setting for packet capture as well as support for it for the following cmdlets:

src/Network/Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,7 @@ private static void Initialize()
19571957
{ "Network.DNS.EnableProxy", src.DNSEnableProxy },
19581958
{ "Network.DNS.Servers", src.DNSServer?.Aggregate((result, item) => result + "," + item) },
19591959
{ "Network.AdditionalLogs.EnableFatFlowLogging", src.EnableFatFlowLogging },
1960+
{ "Network.AdditionalLogs.EnableDnstapLogging", src.EnableDnstapLogging },
19601961
{ "Network.Logging.EnableUDPLogOptimization", src.EnableUDPLogOptimization },
19611962
{ "Network.RouteServerInfo.RouteServerID", src.RouteServerId },
19621963
}.Where(kvp => kvp.Value != null).ToDictionary(key => key.Key, val => val.Value); // TODO: remove after backend code is refactored
@@ -2040,6 +2041,7 @@ private static void Initialize()
20402041
dest.AllowActiveFTP = src.AdditionalProperties?.SingleOrDefault(kvp => kvp.Key.Equals("Network.FTP.AllowActiveFTP", StringComparison.OrdinalIgnoreCase)).Value;
20412042
dest.DNSEnableProxy = src.AdditionalProperties?.SingleOrDefault(kvp => kvp.Key.Equals("Network.DNS.EnableProxy", StringComparison.OrdinalIgnoreCase)).Value;
20422043
dest.EnableFatFlowLogging = src.AdditionalProperties?.SingleOrDefault(kvp => kvp.Key.Equals("Network.AdditionalLogs.EnableFatFlowLogging", StringComparison.OrdinalIgnoreCase)).Value;
2044+
dest.EnableDnstapLogging = src.AdditionalProperties?.SingleOrDefault(kvp => kvp.Key.Equals("Network.AdditionalLogs.EnableDnstapLogging", StringComparison.OrdinalIgnoreCase)).Value;
20432045
dest.EnableUDPLogOptimization = src.AdditionalProperties?.SingleOrDefault(kvp => kvp.Key.Equals("Network.Logging.EnableUDPLogOptimization", StringComparison.OrdinalIgnoreCase)).Value;
20442046
dest.RouteServerId = src.AdditionalProperties?.SingleOrDefault(kvp => kvp.Key.Equals("Network.RouteServerInfo.RouteServerID", StringComparison.OrdinalIgnoreCase)).Value;
20452047
try

src/Network/Network/Models/AzureFirewall/PSAzureFirewall.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public string[] PrivateRange
8787

8888
public string EnableFatFlowLogging { get; set; }
8989

90+
public string EnableDnstapLogging { get; set; }
91+
9092
public string EnableUDPLogOptimization { get; set; }
9193

9294
public string RouteServerId { get; set; }

src/Network/Network/help/New-AzFirewall.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ New-AzFirewall -Name <String> -ResourceGroupName <String> -Location <String>
2323
[-ThreatIntelWhitelist <PSAzureFirewallThreatIntelWhitelist>] [-PrivateRange <String[]>] [-EnableDnsProxy]
2424
[-DnsServer <String[]>] [-Tag <Hashtable>] [-Force] [-AsJob] [-Zone <String[]>] [-SkuName <String>]
2525
[-SkuTier <String>] [-VirtualHubId <String>] [-HubIPAddress <PSAzureFirewallHubIpAddresses>]
26-
[-FirewallPolicyId <String>] [-AllowActiveFTP] [-EnableFatFlowLogging] [-EnableUDPLogOptimization]
26+
[-FirewallPolicyId <String>] [-AllowActiveFTP] [-EnableFatFlowLogging] [-EnableDnstapLogging] [-EnableUDPLogOptimization]
2727
[-RouteServerId <String>] [-MinCapacity <Int32>] [-MaxCapacity <Int32>]
2828
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
2929
[<CommonParameters>]
@@ -39,7 +39,7 @@ New-AzFirewall -Name <String> -ResourceGroupName <String> -Location <String> -Vi
3939
[-ThreatIntelWhitelist <PSAzureFirewallThreatIntelWhitelist>] [-PrivateRange <String[]>] [-EnableDnsProxy]
4040
[-DnsServer <String[]>] [-Tag <Hashtable>] [-Force] [-AsJob] [-Zone <String[]>] [-SkuName <String>]
4141
[-SkuTier <String>] [-VirtualHubId <String>] [-HubIPAddress <PSAzureFirewallHubIpAddresses>]
42-
[-FirewallPolicyId <String>] [-AllowActiveFTP] [-EnableFatFlowLogging] [-EnableUDPLogOptimization]
42+
[-FirewallPolicyId <String>] [-AllowActiveFTP] [-EnableFatFlowLogging] [-EnableDnstapLogging] [-EnableUDPLogOptimization]
4343
[-RouteServerId <String>] [-MinCapacity <Int32>] [-MaxCapacity <Int32>]
4444
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
4545
[<CommonParameters>]
@@ -55,7 +55,7 @@ New-AzFirewall -Name <String> -ResourceGroupName <String> -Location <String> -Vi
5555
[-ThreatIntelWhitelist <PSAzureFirewallThreatIntelWhitelist>] [-PrivateRange <String[]>] [-EnableDnsProxy]
5656
[-DnsServer <String[]>] [-Tag <Hashtable>] [-Force] [-AsJob] [-Zone <String[]>] [-SkuName <String>]
5757
[-SkuTier <String>] [-VirtualHubId <String>] [-HubIPAddress <PSAzureFirewallHubIpAddresses>]
58-
[-FirewallPolicyId <String>] [-AllowActiveFTP] [-EnableFatFlowLogging] [-EnableUDPLogOptimization]
58+
[-FirewallPolicyId <String>] [-AllowActiveFTP] [-EnableFatFlowLogging] [-EnableDnstapLogging] [-EnableUDPLogOptimization]
5959
[-RouteServerId <String>] [-MinCapacity <Int32>] [-MaxCapacity <Int32>]
6060
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
6161
[<CommonParameters>]
@@ -381,6 +381,21 @@ Accept pipeline input: False
381381
Accept wildcard characters: False
382382
```
383383
384+
### -EnableDnstapLogging
385+
Enable Dnstap Logging. By default it is false.
386+
387+
```yaml
388+
Type: System.Management.Automation.SwitchParameter
389+
Parameter Sets: (All)
390+
Aliases:
391+
392+
Required: False
393+
Position: Named
394+
Default value: None
395+
Accept pipeline input: False
396+
Accept wildcard characters: False
397+
```
398+
384399
### -EnableUDPLogOptimization
385400
Enable UDP Log Optimization. By default it is false.
386401

src/Network/Network/help/Set-AzFirewall.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,55 @@ If user wants to start the service again but with Availability Zones, the Zones
250250
The new VNet and Public IP must be in the same resource group as the Firewall. Again, for changes to be reflected in cloud,
251251
Set-AzFirewall must be called.
252252

253+
### Example 16: Enable Dnstap Logging on Azure Firewall
254+
```powershell
255+
$azFw = Get-AzFirewall -Name "ps184" -ResourceGroupName "ps774"
256+
$azFw.EnableDnstapLogging = $true
257+
258+
$azFw | Set-AzFirewall
259+
```
260+
261+
```output
262+
AllowActiveFTP : null
263+
ApplicationRuleCollections : Count = 0
264+
ApplicationRuleCollectionsText : "[]"
265+
DNSEnableProxy : null
266+
DNSServer : null
267+
DNSServersText : "null"
268+
Etag : "W/\"7533fa1b-8588-400d-857c-6bc372e14f1b\""
269+
FirewallPolicy : null
270+
HubIPAddresses : null
271+
Id : "/subscriptions/aeb5b02a-0f18-45a4-86d6-81808115cacf/resourceGroups/ps774/providers/Microsoft.Network/azureFirewalls/ps184"
272+
EnableDnstapLogging : "true"
273+
IpConfigurations : Count = 0
274+
IpConfigurationsText : "[]"
275+
Location : "eastus"
276+
ManagementIpConfiguration : null
277+
ManagementIpConfigurationText : "null"
278+
Name : "ps184"
279+
NatRuleCollections : Count = 0
280+
NatRuleCollectionsText : "[]"
281+
NetworkRuleCollections : Count = 0
282+
NetworkRuleCollectionsText : "[]"
283+
PrivateRange : null
284+
PrivateRangeText : "null"
285+
ProvisioningState : "Succeeded"
286+
ResourceGroupName : "ps774"
287+
ResourceGuid : null
288+
Sku : {Microsoft.Azure.Commands.Network.Models.PSAzureFirewallSku}
289+
Tag : null
290+
TagsTable : null
291+
ThreatIntelMode : "Alert"
292+
ThreatIntelWhitelist : {Microsoft.Azure.Commands.Network.Models.PSAzureFirewallThreatIntelWhitelist}
293+
ThreatIntelWhitelistText : "{\r\n \"FQDNs\": null,\r\n \"IpAddresses\": null\r\n}"
294+
Type : "Microsoft.Network/azureFirewalls"
295+
VirtualHub : null
296+
Zones : Count = 0
297+
privateRange : null
298+
```
299+
300+
In this example, Enable Dnstap Logging is enabled on the Firewall.
301+
253302
## PARAMETERS
254303

255304
### -AsJob

0 commit comments

Comments
 (0)