Skip to content

Commit 277b599

Browse files
Gizachew-EshetieGizachew Eshetie
andauthored
Fixed bugs related to auto learn IP prefixes and Snat (#21246)
* Bug fixes * Fixed PrivateRange issue with Snat * Displayed RouteServerId on output * Added change log --------- Co-authored-by: Gizachew Eshetie <[email protected]>
1 parent 94a05a6 commit 277b599

File tree

6 files changed

+37
-8
lines changed

6 files changed

+37
-8
lines changed

src/Network/Network/AzureFirewall/AutoLearnedPrefix/GetAzureFirewallLearnedIpPrefixCommand.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public override void ExecuteCmdlet()
4848
base.ExecuteCmdlet();
4949
if (ShouldGetByName(ResourceGroupName, Name))
5050
{
51-
var learnedIPPrefixes = this.AzureFirewallClient.ListLearnedPrefixes(this.ResourceGroupName, this.Name);
51+
var learnedIPPrefixes = this.GetLearnedPrefixes(this.ResourceGroupName, this.Name);
5252
var pslearnedIPPrefixes = new PSAzureFirewallIpPrefix();
5353
if (learnedIPPrefixes != null)
5454
{
@@ -61,5 +61,17 @@ public override void ExecuteCmdlet()
6161
throw new ArgumentException($" Name and ResourceGroupName should be provided to get firewall learned IP prefixes.");
6262
}
6363
}
64+
65+
private IPPrefixesList GetLearnedPrefixes(string rgName, string fwName)
66+
{
67+
try
68+
{
69+
return this.AzureFirewallClient.ListLearnedPrefixes(rgName, fwName);
70+
}
71+
catch (Exception)
72+
{
73+
throw new Exception("Error occurred while fetching learned IP prefixes. Please make sure learning IP prefix is configured properly.");
74+
}
75+
}
6476
}
6577
}

src/Network/Network/AzureFirewallPolicy/NewAzureFirewallPolicyCommand.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,14 @@ private PSAzureFirewallPolicy CreateAzureFirewallPolicy()
192192
},
193193
IntrusionDetection = this.IntrusionDetection,
194194
PrivateRange = this.PrivateRange,
195-
ExplicitProxy = this.ExplicitProxy,
196-
Snat = this.Snat
195+
ExplicitProxy = this.ExplicitProxy
197196
};
198197

198+
if (this.Snat != null)
199+
{
200+
firewallPolicy.Snat = this.Snat;
201+
}
202+
199203
if (this.UserAssignedIdentityId != null)
200204
{
201205
firewallPolicy.Identity = new PSManagedServiceIdentity

src/Network/Network/AzureFirewallPolicy/SetAzureFirewallPolicyCommand.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,14 @@ public override void Execute()
270270
DnsSettings = this.DnsSetting,
271271
SqlSetting = this.SqlSetting,
272272
PrivateRange = this.PrivateRange,
273-
ExplicitProxy = this.ExplicitProxy,
274-
Snat = this.Snat
273+
ExplicitProxy = this.ExplicitProxy
275274
};
276275

276+
if (this.Snat != null)
277+
{
278+
firewallPolicy.Snat = this.Snat;
279+
}
280+
277281
AddPremiumProperties(firewallPolicy);
278282

279283
var azureFirewallPolicyModel = NetworkResourceManagerProfile.Mapper.Map<MNM.FirewallPolicy>(firewallPolicy);
@@ -302,10 +306,14 @@ public override void Execute()
302306
DnsSettings = this.DnsSetting,
303307
SqlSetting = this.SqlSetting,
304308
PrivateRange = this.PrivateRange,
305-
ExplicitProxy = this.ExplicitProxy,
306-
Snat = this.Snat
309+
ExplicitProxy = this.ExplicitProxy
307310
};
308311

312+
if (this.Snat != null)
313+
{
314+
firewallPolicy.Snat = this.Snat;
315+
}
316+
309317
AddPremiumProperties(firewallPolicy);
310318

311319
// Map to the sdk object

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* Updated `New-AzVirtualNetworkGatewayConnection`, `Set-AzVirtualNetworkGatewayConnection` and `New-AzVpnSiteLinkConnection` to support GatewayCustomBgpIpConfiguration.
2929
* Updated `Reset-AzVpnGateway` to support IpConfigurationId.
3030
* Blocked some regions when creating/updating Basic Sku firewall
31+
* Fixed bugs related to auto learn IP prefixes and Snat
3132

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

src/Network/Network/Models/AzureFirewallPolicy/PSAzureFirewallPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public string[] PrivateRange
6262
{
6363
get
6464
{
65-
return Snat?.PrivateRanges.ToArray();
65+
return Snat?.PrivateRanges?.ToArray();
6666
}
6767
set
6868
{

src/Network/Network/Network.format.ps1xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4207,6 +4207,10 @@
42074207
<Label>IPv6CircuitConnectionConfig</Label>
42084208
<PropertyName>IPv6CircuitConnectionConfigText</PropertyName>
42094209
</ListItem>
4210+
<ListItem>
4211+
<Label>RouteServerId</Label>
4212+
<PropertyName>RouteServerId</PropertyName>
4213+
</ListItem>
42104214
</ListItems>
42114215
</ListEntry>
42124216
</ListEntries>

0 commit comments

Comments
 (0)