Skip to content

Commit 3aa7d78

Browse files
authored
Add the new switch parameter AllowActiveFTP to Firewall Command (#12430)
1 parent 6cecf64 commit 3aa7d78

File tree

9 files changed

+2194
-4
lines changed

9 files changed

+2194
-4
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,13 @@ public void TestAzureFirewallVirtualHubMultiPublicIPCRUD()
104104
{
105105
TestRunner.RunTestScript("Test-AzureFirewallVirtualHubMultiPublicIPCRUD");
106106
}
107+
108+
[Fact]
109+
[Trait(Category.AcceptanceType, Category.CheckIn)]
110+
[Trait(Category.Owner, NrpTeamAlias.azurefirewall)]
111+
public void TestAzureFirewallCRUDWithAllowActiveFTP()
112+
{
113+
TestRunner.RunTestScript("Test-AzureFirewallCRUDAllowActiveFTP");
114+
}
107115
}
108116
}

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,4 +1515,49 @@ function Test-AzureFirewallVirtualHubMultiPublicIPCRUD {
15151515
# Cleanup
15161516
Clean-ResourceGroup $rgname
15171517
}
1518+
}
1519+
1520+
<#
1521+
.SYNOPSIS
1522+
Tests AzureFirewall AllowActiveFTP
1523+
#>
1524+
function Test-AzureFirewallCRUDAllowActiveFTP {
1525+
$rgname = Get-ResourceGroupName
1526+
$azureFirewallName = Get-ResourceName
1527+
$resourceTypeParent = "Microsoft.Network/AzureFirewalls"
1528+
$location = Get-ProviderLocation $resourceTypeParent "eastus"
1529+
1530+
$vnetName = Get-ResourceName
1531+
$subnetName = "AzureFirewallSubnet"
1532+
$publicIpName = Get-ResourceName
1533+
1534+
try {
1535+
# Create the resource group
1536+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location
1537+
1538+
# Create the Virtual Network
1539+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
1540+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
1541+
1542+
# Create public ip
1543+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -Sku Standard
1544+
1545+
# Create AzureFirewall
1546+
$azureFirewall = New-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname -Location $location -AllowActiveFTP
1547+
1548+
# Verify
1549+
$azFirewall = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname
1550+
Assert-AreEqual true $azFirewall.AllowActiveFTP
1551+
1552+
# Reset the AllowActiveFTP flag
1553+
$azFirewall.AllowActiveFTP = $false
1554+
Set-AzFirewall -AzureFirewall $azFirewall
1555+
$azfw = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname
1556+
1557+
Assert-AreEqual false $azfw.AllowActiveFTP
1558+
}
1559+
finally {
1560+
# Cleanup
1561+
Clean-ResourceGroup $rgname
1562+
}
15181563
}

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

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

src/Network/Network/AzureFirewall/NewAzureFirewallCommand.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ public class NewAzureFirewallCommand : AzureFirewallBaseCmdlet
220220
HelpMessage = "The firewall policy attached to the firewall")]
221221
public string FirewallPolicyId { get; set; }
222222

223+
[Parameter(
224+
Mandatory = false,
225+
HelpMessage = "Allow Active FTP. By default it is false."
226+
)]
227+
public SwitchParameter AllowActiveFTP { get; set; }
228+
223229
public override void Execute()
224230
{
225231
// Old params provided - Get the virtual network, get the public IP address
@@ -310,6 +316,7 @@ private PSAzureFirewall CreateAzureFirewall()
310316
DNSEnableProxy = (this.EnableDnsProxy.IsPresent? "true" : null),
311317
DNSRequireProxyForNetworkRules = (this.DnsProxyNotRequiredForNetworkRule.IsPresent ? "false" : null),
312318
DNSServer = this.DnsServer,
319+
AllowActiveFTP = (this.AllowActiveFTP.IsPresent ? "true" : null),
313320
Sku = sku
314321
};
315322

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- `New-AzVirtualApplianceSkuProperty`
3737
* Onboard Application Gateway to Private Link Common Cmdlets
3838
* Onboard StorageSync to Private Link Common Cmdlets
39+
* Add `AllowActiveFTP` parameter to `AzureFirewall`
3940

4041
## Version 3.1.0
4142
* Added support for AddressPrefixType parameter to `Remove-AzExpressRouteCircuitConnectionConfig`

src/Network/Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,7 @@ private static void Initialize()
12321232
{ "ThreatIntel.Whitelist.FQDNs", src.ThreatIntelWhitelist?.FQDNs?.Aggregate((result, item) => result + "," + item) },
12331233
{ "ThreatIntel.Whitelist.IpAddresses", src.ThreatIntelWhitelist?.IpAddresses?.Aggregate((result, item) => result + "," + item) },
12341234
{ "Network.SNAT.PrivateRanges", src.PrivateRange?.Aggregate((result, item) => result + "," + item) },
1235+
{ "Network.FTP.AllowActiveFTP", src.AllowActiveFTP },
12351236
{ "Network.DNS.EnableProxy", src.DNSEnableProxy },
12361237
{ "Network.DNS.RequireProxyForNetworkRules", src.DNSRequireProxyForNetworkRules },
12371238
{ "Network.DNS.Servers", src.DNSServer?.Aggregate((result, item) => result + "," + item) }
@@ -1279,6 +1280,7 @@ private static void Initialize()
12791280
{
12801281
dest.PrivateRange = null;
12811282
}
1283+
dest.AllowActiveFTP = src.AdditionalProperties?.SingleOrDefault(kvp => kvp.Key.Equals("Network.FTP.AllowActiveFTP", StringComparison.OrdinalIgnoreCase)).Value;
12821284
dest.DNSEnableProxy = src.AdditionalProperties?.SingleOrDefault(kvp => kvp.Key.Equals("Network.DNS.EnableProxy", StringComparison.OrdinalIgnoreCase)).Value;
12831285
dest.DNSRequireProxyForNetworkRules = src.AdditionalProperties?.SingleOrDefault(kvp => kvp.Key.Equals("Network.DNS.RequireProxyForNetworkRules", StringComparison.OrdinalIgnoreCase)).Value;
12841286
try

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

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

7979
public List<string> Zones { get; set; }
8080

81+
public string AllowActiveFTP { get; set; }
82+
8183
[JsonIgnore]
8284
public string IpConfigurationsText
8385
{

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ New-AzFirewall -Name <String> -ResourceGroupName <String> -Location <String>
2020
[-NatRuleCollection <PSAzureFirewallNatRuleCollection[]>]
2121
[-NetworkRuleCollection <PSAzureFirewallNetworkRuleCollection[]>] [-ThreatIntelMode <String>]
2222
[-ThreatIntelWhitelist <PSAzureFirewallThreatIntelWhitelist>] [-PrivateRange <String[]>] [-EnableDnsProxy]
23-
[-DnsProxyNotRequiredForNetworkRule] [-DnsServer <String[]>] [-Tag <Hashtable>] [-Force] [-AsJob]
23+
[-DnsProxyNotRequiredForNetworkRule] [-DnsServer <String[]>] [-AllowActiveFTP] [-Tag <Hashtable>] [-Force] [-AsJob]
2424
[-Zone <String[]>] [-Sku <String>] [-VirtualHubId <String>] [-HubIPAddresses <PSAzureFirewallHubIpAddresses>]
2525
[-FirewallPolicyId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
2626
[<CommonParameters>]
@@ -33,7 +33,7 @@ New-AzFirewall -Name <String> -ResourceGroupName <String> -Location <String> -Vi
3333
[-NatRuleCollection <PSAzureFirewallNatRuleCollection[]>]
3434
[-NetworkRuleCollection <PSAzureFirewallNetworkRuleCollection[]>] [-ThreatIntelMode <String>]
3535
[-ThreatIntelWhitelist <PSAzureFirewallThreatIntelWhitelist>] [-PrivateRange <String[]>] [-EnableDnsProxy]
36-
[-DnsProxyNotRequiredForNetworkRule] [-DnsServer <String[]>] [-Tag <Hashtable>] [-Force] [-AsJob]
36+
[-DnsProxyNotRequiredForNetworkRule] [-DnsServer <String[]>] [-AllowActiveFTP] [-Tag <Hashtable>] [-Force] [-AsJob]
3737
[-Zone <String[]>] [-Sku <String>] [-VirtualHubId <String>] [-HubIPAddresses <PSAzureFirewallHubIpAddresses>]
3838
[-FirewallPolicyId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
3939
[<CommonParameters>]
@@ -47,7 +47,7 @@ New-AzFirewall -Name <String> -ResourceGroupName <String> -Location <String> -Vi
4747
[-NatRuleCollection <PSAzureFirewallNatRuleCollection[]>]
4848
[-NetworkRuleCollection <PSAzureFirewallNetworkRuleCollection[]>] [-ThreatIntelMode <String>]
4949
[-ThreatIntelWhitelist <PSAzureFirewallThreatIntelWhitelist>] [-PrivateRange <String[]>] [-EnableDnsProxy]
50-
[-DnsProxyNotRequiredForNetworkRule] [-DnsServer <String[]>] [-Tag <Hashtable>] [-Force] [-AsJob]
50+
[-DnsProxyNotRequiredForNetworkRule] [-DnsServer <String[]>] [-AllowActiveFTP] [-Tag <Hashtable>] [-Force] [-AsJob]
5151
[-Zone <String[]>] [-Sku <String>] [-VirtualHubId <String>] [-HubIPAddresses <PSAzureFirewallHubIpAddresses>]
5252
[-FirewallPolicyId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
5353
[<CommonParameters>]
@@ -229,7 +229,7 @@ This example creates a Firewall attached to virtual network "vnet" in the same r
229229
DNS Proxy is enabled for this firewall and 2 DNS Servers are provided. Also Require DNS Proxy for Network rules is set
230230
so if there are any Network rules with FQDNs then DNS proxy will be used for them too.
231231

232-
### 14: Create a Firewall with multiple IPs. The Firewall can be associated with the Virtual Hub
232+
### 15: Create a Firewall with multiple IPs. The Firewall can be associated with the Virtual Hub
233233
```
234234
$rgName = "resourceGroupName"
235235
$vHub = Get-AzVirtualHub -Name "hub"
@@ -242,6 +242,16 @@ $fw=New-AzFirewall -Name "azFw" -ResourceGroupName $rgName -Location westus -Sku
242242
This example creates a Firewall attached to virtual hub "hub" in the same resource group as the firewall.
243243
The Firewall will be assigned 2 public IPs that are created implicitly.
244244

245+
### 16: Create a Firewall with Allow Active FTP.
246+
```
247+
$rgName = "resourceGroupName"
248+
$vnet = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name "vnet"
249+
$pip = Get-AzPublicIpAddress -ResourceGroupName $rgName -Name "publicIpName"
250+
New-AzFirewall -Name "azFw" -ResourceGroupName $rgName -Location centralus -VirtualNetwork $vnet -PublicIpAddress $pip -AllowActiveFTP
251+
```
252+
253+
This example creates a Firewall with allow active FTP flag.
254+
245255
## PARAMETERS
246256

247257
### -ApplicationRuleCollection
@@ -323,6 +333,22 @@ Accept wildcard characters: False
323333
Enable DNS Proxy. By default it is disabled.
324334
325335
336+
```yaml
337+
Type: SwitchParameter
338+
Parameter Sets: (All)
339+
Aliases:
340+
341+
Required: False
342+
Position: Named
343+
Default value: None
344+
Accept pipeline input: False
345+
Accept wildcard characters: False
346+
```
347+
348+
### -AllowActiveFTP
349+
Allows Active FTP on the Firewall. By default it is disabled.
350+
351+
326352
```yaml
327353
Type: SwitchParameter
328354
Parameter Sets: (All)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ Set-AzFirewall -AzureFirewall $azFw
145145

146146
This example updates the destination of an existing rule within a rule collection of an Azure Firewall. This allows you to automatically update your rules when IP addresses change dynamically.
147147

148+
### 11: Allow Active FTP on Azure Firewall
149+
```
150+
$azFw = Get-AzFirewall -Name "AzureFirewall" -ResourceGroupName "rg"
151+
$azFw.AllowActiveFTP = $true
152+
153+
$azFw | Set-AzFirewall
154+
```
155+
156+
In this example, Active FTP is allowed on the Firewall.
157+
148158
## PARAMETERS
149159

150160
### -AsJob

0 commit comments

Comments
 (0)