Skip to content

Commit cb65a83

Browse files
Gizachew-EshetieGizachew Eshetie
andauthored
Blocked some regions when creating/updating Basic Sku firewall (#21179)
Co-authored-by: Gizachew Eshetie <[email protected]>
1 parent 3bce5b6 commit cb65a83

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

src/Network/Network/AzureFirewall/NewAzureFirewallCommand.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ private PSAzureFirewall CreateAzureFirewall()
289289
sku.Name = !string.IsNullOrEmpty(this.SkuName) ? this.SkuName : MNM.AzureFirewallSkuName.AZFWVNet;
290290
sku.Tier = !string.IsNullOrEmpty(this.SkuTier) ? this.SkuTier : MNM.AzureFirewallSkuTier.Standard;
291291

292+
if (sku.Tier.Equals(MNM.AzureFirewallSkuTier.Basic) && !string.IsNullOrEmpty(this.Location))
293+
{
294+
if (FirewallConstants.IsRegionRestrictedForBasicFirewall(this.Location))
295+
{
296+
throw new ArgumentException("Basic Sku Firewall is not supported in this region yet - " + this.Location, nameof(this.Location));
297+
}
298+
}
292299
if (this.SkuName == MNM.AzureFirewallSkuName.AZFWHub)
293300
{
294301

src/Network/Network/AzureFirewall/SetAzureFirewallCommand.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ public override void Execute()
4242
throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound);
4343
}
4444

45+
if (this.AzureFirewall.Sku != null && this.AzureFirewall.Sku.Tier != null && this.AzureFirewall.Sku.Tier.Equals(MNM.AzureFirewallSkuTier.Basic) && !string.IsNullOrEmpty(this.AzureFirewall.Location))
46+
{
47+
if (FirewallConstants.IsRegionRestrictedForBasicFirewall(this.AzureFirewall.Location))
48+
{
49+
throw new ArgumentException("Basic Sku Firewall is not supported in this region yet - " + this.AzureFirewall.Location, nameof(this.AzureFirewall.Location));
50+
}
51+
}
52+
4553
// Map to the sdk object
4654
var secureGwModel = NetworkResourceManagerProfile.Mapper.Map<MNM.AzureFirewall>(this.AzureFirewall);
4755
secureGwModel.Tags = TagsConversionHelper.CreateTagDictionary(this.AzureFirewall.Tag, validate: true);

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* Added `New-AzGatewayCustomBgpIpConfigurationObject` command
2828
* Updated `New-AzVirtualNetworkGatewayConnection`, `Set-AzVirtualNetworkGatewayConnection` and `New-AzVpnSiteLinkConnection` to support GatewayCustomBgpIpConfiguration.
2929
* Updated `Reset-AzVpnGateway` to support IpConfigurationId.
30+
* Blocked some regions when creating/updating Basic Sku firewall
3031

3132
## Version 5.5.0
3233
* Updated cmdlets to add new property of `Snat` in Azure Firewall Policy.

src/Network/Network/Common/Utils.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.Network.Models;
1616
using System;
17+
using System.Globalization;
1718

1819
namespace Microsoft.Azure.Commands.Network
1920
{
@@ -60,4 +61,26 @@ public static bool IsIpv4PrivatePeeringNull(PSPeering privatePeering)
6061
return false;
6162
}
6263
}
64+
65+
public static class FirewallConstants
66+
{
67+
public static readonly System.Collections.Generic.List<string> RestrictedBasicSkuFirewallRegions = new System.Collections.Generic.List<string>()
68+
{
69+
"TaiwanNorth","CanadaEast","JioIndiaWest", "PolandCentral", "SpainCentral", "USSecWestCentral", "BelgiumCentral", "GermanyNorth", "SwedenSouth", "ChinaEast3"
70+
};
71+
public static bool IsRegionRestrictedForBasicFirewall(string region)
72+
{
73+
if (!string.IsNullOrEmpty(region))
74+
{
75+
foreach(var reg in RestrictedBasicSkuFirewallRegions)
76+
{
77+
if(String.Compare(reg, region, CultureInfo.CurrentCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) == 0)
78+
{
79+
return true;
80+
}
81+
}
82+
}
83+
return false;
84+
}
85+
}
6386
}

0 commit comments

Comments
 (0)