Skip to content

Commit fae92de

Browse files
authored
Azure Firewall Autoscale Configuration Support (#26257)
* Azure Firewall Autoscale Configuration Support * Help files with new parameters * add validation
1 parent 923c041 commit fae92de

File tree

11 files changed

+2882
-43
lines changed

11 files changed

+2882
-43
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,13 @@ public void TestAllocateByopipAzureHubFirewall()
225225
{
226226
TestRunner.RunTestScript("Test-InvokeAzureAllocateByopipHubFirewall");
227227
}
228+
229+
[Fact]
230+
[Trait(Category.AcceptanceType, Category.CheckIn)]
231+
[Trait(Category.Owner, NrpTeamAlias.azurefirewall)]
232+
public void TestAzureFirewallAutoscaleConfiguration()
233+
{
234+
TestRunner.RunTestScript("Test-AzureFirewallAutoscaleConfiguration");
235+
}
228236
}
229237
}

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,4 +2311,67 @@ function Test-InvokeAzureAllocateByopipHubFirewall {
23112311
# Cleanup
23122312
Clean-ResourceGroup $rgname
23132313
}
2314+
}
2315+
2316+
<#
2317+
.SYNOPSIS
2318+
Tests Azure Firewall Autoscale Configuration feature
2319+
#>
2320+
function Test-AzureFirewallAutoscaleConfiguration {
2321+
$rgname = Get-ResourceGroupName
2322+
$azureFirewallName = Get-ResourceName
2323+
$resourceTypeParent = "Microsoft.Network/AzureFirewalls"
2324+
$location = Get-ProviderLocation $resourceTypeParent "eastus"
2325+
2326+
$vnetName = Get-ResourceName
2327+
$subnetName = "AzureFirewallSubnet"
2328+
$publicIpName = Get-ResourceName
2329+
2330+
$expectedMinCapacity = 3
2331+
$expectedMaxCapacity = 5
2332+
$expectedUpdatedMinCapacity = 4
2333+
$expectedUpdatedMaxCapacity = 4
2334+
2335+
try {
2336+
# Create the resource group
2337+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location
2338+
2339+
# Create the Virtual Network
2340+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
2341+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
2342+
2343+
# Create public ip
2344+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -Sku Standard
2345+
2346+
# Create AzureFirewall
2347+
$azureFirewall = New-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname -Location $location -MinCapacity $expectedMinCapacity -MaxCapacity $expectedMaxCapacity
2348+
2349+
# Verify
2350+
$getAzureFirewall = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname
2351+
Assert-AreEqual $getAzureFirewall.AutoscaleConfiguration.MinCapacity $expectedMinCapacity
2352+
Assert-AreEqual $getAzureFirewall.AutoscaleConfiguration.MaxCapacity $expectedMaxCapacity
2353+
2354+
# Update Scale
2355+
$azureFirewall.AutoscaleConfiguration.MinCapacity = $expectedUpdatedMinCapacity
2356+
$azureFirewall.AutoscaleConfiguration.MaxCapacity = $expectedUpdatedMaxCapacity
2357+
Set-AzFirewall -AzureFirewall $azureFirewall
2358+
2359+
# Verify
2360+
$getAzureFirewall = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname
2361+
Assert-AreEqual $getAzureFirewall.AutoscaleConfiguration.MinCapacity $expectedUpdatedMinCapacity
2362+
Assert-AreEqual $getAzureFirewall.AutoscaleConfiguration.MaxCapacity $expectedUpdatedMaxCapacity
2363+
2364+
# Reset
2365+
$azureFirewall.AutoscaleConfiguration.MinCapacity = $null
2366+
$azureFirewall.AutoscaleConfiguration.MaxCapacity = $null
2367+
Set-AzFirewall -AzureFirewall $azureFirewall
2368+
2369+
# Verify
2370+
$getAzureFirewall = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname
2371+
Assert-Null $getAzureFirewall.AutoscaleConfiguration
2372+
}
2373+
finally {
2374+
# Cleanup
2375+
Clean-ResourceGroup $rgname
2376+
}
23142377
}

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

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

src/Network/Network/AzureFirewall/NewAzureFirewallCommand.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ public class NewAzureFirewallCommand : AzureFirewallBaseCmdlet
230230
HelpMessage = "The Route Server Id for the firewall")]
231231
public string RouteServerId { get; set; }
232232

233+
[Parameter(
234+
Mandatory = false,
235+
HelpMessage = "The minimum number of capacity units for this azure firewall")]
236+
public int? MinCapacity { get; set; }
237+
238+
[Parameter(
239+
Mandatory = false,
240+
HelpMessage = "The maximum number of capacity units for this azure firewall")]
241+
public int? MaxCapacity { get; set; }
242+
233243
public override void Execute()
234244
{
235245
// Old params provided - Get the virtual network, get the public IP address
@@ -372,6 +382,19 @@ private PSAzureFirewall CreateAzureFirewall()
372382
firewall.ValidateDNSProxyRequirements();
373383
}
374384

385+
PSAzureFirewallAutoscaleConfiguration autoscaleConfiguration = new PSAzureFirewallAutoscaleConfiguration();
386+
387+
if (this.MinCapacity.HasValue)
388+
{
389+
autoscaleConfiguration.MinCapacity = this.MinCapacity.Value;
390+
}
391+
if (this.MaxCapacity.HasValue)
392+
{
393+
autoscaleConfiguration.MaxCapacity = this.MaxCapacity.Value;
394+
}
395+
396+
firewall.AutoscaleConfiguration = autoscaleConfiguration;
397+
375398
// Map to the sdk object
376399
var azureFirewallModel = NetworkResourceManagerProfile.Mapper.Map<MNM.AzureFirewall>(firewall);
377400
azureFirewallModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);

src/Network/Network/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
## Upcoming Release
2222
* Added `DefaultOutboundConnectivityEnabled` property in PSNetworkInterface
2323

24+
* Added support for `AutoscaleConfiguration` property in `AzureFirewall` model for `New-AzFirewall` and `Set-AzFirewall` commands
25+
2426
## Version 7.10.0
2527
* Onboarded Azure Virtual Network Manager Cmdlets for UDR and NSG Management
2628
- `New/Get/Remove/Set-AzNetworkManagerRoutingConfiguration`

src/Network/Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ private static void Initialize()
19281928
cfg.CreateMap<CNM.PSAzureFirewallPacketCaptureFlags, MNM.AzureFirewallPacketCaptureFlags>();
19291929
cfg.CreateMap<CNM.PSAzureFirewallPacketCaptureRule, MNM.AzureFirewallPacketCaptureRule>();
19301930
cfg.CreateMap<CNM.PSAzureFirewallPacketCaptureParameters, MNM.FirewallPacketCaptureParameters>();
1931+
cfg.CreateMap<CNM.PSAzureFirewallAutoscaleConfiguration, MNM.AzureFirewallAutoscaleConfiguration>();
19311932

19321933
// MNM to CNM
19331934
cfg.CreateMap<MNM.AzureFirewall, CNM.PSAzureFirewall>()
@@ -2022,6 +2023,8 @@ private static void Initialize()
20222023
// MNM to CNM
20232024
cfg.CreateMap<MNM.AzureFirewallFqdnTag, CNM.PSAzureFirewallFqdnTag>();
20242025

2026+
cfg.CreateMap<MNM.AzureFirewallAutoscaleConfiguration, CNM.PSAzureFirewallAutoscaleConfiguration>();
2027+
20252028
// Azure Firewall Policies
20262029
// CNM to MNM
20272030
cfg.CreateMap<CNM.PSAzureFirewallPolicyExplicitProxy, MNM.ExplicitProxy>();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public class PSAzureFirewall : PSTopLevelResource
5757

5858
public PSAzureFirewallIpPrefix LearnedIPPrefixes { get; set; }
5959

60+
public PSAzureFirewallAutoscaleConfiguration AutoscaleConfiguration { get; set; }
61+
6062
public string[] PrivateRange
6163
{
6264
get
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
namespace Microsoft.Azure.Commands.Network.Models
2+
{
3+
using System;
4+
using System.Management.Automation;
5+
6+
public class PSAzureFirewallAutoscaleConfiguration
7+
{
8+
public const int AbsoluteMinCapacity = 2;
9+
10+
private int? minCapacity;
11+
private int? maxCapacity;
12+
13+
public int? MinCapacity
14+
{
15+
get
16+
{
17+
return this.minCapacity;
18+
}
19+
set
20+
{
21+
ValidateCapacity(value);
22+
minCapacity = value;
23+
}
24+
}
25+
26+
public int? MaxCapacity
27+
{
28+
get
29+
{
30+
return this.maxCapacity;
31+
}
32+
set
33+
{
34+
ValidateCapacity(value);
35+
maxCapacity = value;
36+
}
37+
}
38+
39+
private void ValidateCapacity(int? capacity)
40+
{
41+
if (capacity.HasValue)
42+
{
43+
if (capacity < 2)
44+
{
45+
throw new PSArgumentException(String.Format("\'{0}\' is below the service minimum of \'{1}\'", capacity, AbsoluteMinCapacity));
46+
}
47+
}
48+
}
49+
}
50+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ This example retrieves a firewall and calls Allocate on the firewall to start th
283283
The credentials, account, tenant, and subscription used for communication with azure.
284284

285285
```yaml
286-
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
286+
Type: IAzureContextContainer
287287
Parameter Sets: (All)
288288
Aliases: AzContext, AzureRmContext, AzureCredential
289289

@@ -298,7 +298,7 @@ Accept wildcard characters: False
298298
Specifies the name of the Firewall that this cmdlet gets.
299299
300300
```yaml
301-
Type: System.String
301+
Type: String
302302
Parameter Sets: (All)
303303
Aliases: ResourceName
304304

@@ -313,7 +313,7 @@ Accept wildcard characters: True
313313
Specifies the name of the resource group that Firewall belongs to.
314314
315315
```yaml
316-
Type: System.String
316+
Type: String
317317
Parameter Sets: (All)
318318
Aliases:
319319

0 commit comments

Comments
 (0)