Skip to content

Fixed bugs related to auto learn IP prefixes and Snat #21246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override void ExecuteCmdlet()
base.ExecuteCmdlet();
if (ShouldGetByName(ResourceGroupName, Name))
{
var learnedIPPrefixes = this.AzureFirewallClient.ListLearnedPrefixes(this.ResourceGroupName, this.Name);
var learnedIPPrefixes = this.GetLearnedPrefixes(this.ResourceGroupName, this.Name);
var pslearnedIPPrefixes = new PSAzureFirewallIpPrefix();
if (learnedIPPrefixes != null)
{
Expand All @@ -61,5 +61,17 @@ public override void ExecuteCmdlet()
throw new ArgumentException($" Name and ResourceGroupName should be provided to get firewall learned IP prefixes.");
}
}

private IPPrefixesList GetLearnedPrefixes(string rgName, string fwName)
{
try
{
return this.AzureFirewallClient.ListLearnedPrefixes(rgName, fwName);
}
catch (Exception)
{
throw new Exception("Error occurred while fetching learned IP prefixes. Please make sure learning IP prefix is configured properly.");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,14 @@ private PSAzureFirewallPolicy CreateAzureFirewallPolicy()
},
IntrusionDetection = this.IntrusionDetection,
PrivateRange = this.PrivateRange,
ExplicitProxy = this.ExplicitProxy,
Snat = this.Snat
ExplicitProxy = this.ExplicitProxy
};

if (this.Snat != null)
{
firewallPolicy.Snat = this.Snat;
}

if (this.UserAssignedIdentityId != null)
{
firewallPolicy.Identity = new PSManagedServiceIdentity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,14 @@ public override void Execute()
DnsSettings = this.DnsSetting,
SqlSetting = this.SqlSetting,
PrivateRange = this.PrivateRange,
ExplicitProxy = this.ExplicitProxy,
Snat = this.Snat
ExplicitProxy = this.ExplicitProxy
};

if (this.Snat != null)
{
firewallPolicy.Snat = this.Snat;
}

AddPremiumProperties(firewallPolicy);

var azureFirewallPolicyModel = NetworkResourceManagerProfile.Mapper.Map<MNM.FirewallPolicy>(firewallPolicy);
Expand Down Expand Up @@ -302,10 +306,14 @@ public override void Execute()
DnsSettings = this.DnsSetting,
SqlSetting = this.SqlSetting,
PrivateRange = this.PrivateRange,
ExplicitProxy = this.ExplicitProxy,
Snat = this.Snat
ExplicitProxy = this.ExplicitProxy
};

if (this.Snat != null)
{
firewallPolicy.Snat = this.Snat;
}

AddPremiumProperties(firewallPolicy);

// Map to the sdk object
Expand Down
1 change: 1 addition & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Updated `New-AzVirtualNetworkGatewayConnection`, `Set-AzVirtualNetworkGatewayConnection` and `New-AzVpnSiteLinkConnection` to support GatewayCustomBgpIpConfiguration.
* Updated `Reset-AzVpnGateway` to support IpConfigurationId.
* Blocked some regions when creating/updating Basic Sku firewall
* Fixed bugs related to auto learn IP prefixes and Snat

## Version 5.5.0
* Updated cmdlets to add new property of `Snat` in Azure Firewall Policy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public string[] PrivateRange
{
get
{
return Snat?.PrivateRanges.ToArray();
return Snat?.PrivateRanges?.ToArray();
}
set
{
Expand Down
4 changes: 4 additions & 0 deletions src/Network/Network/Network.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -4207,6 +4207,10 @@
<Label>IPv6CircuitConnectionConfig</Label>
<PropertyName>IPv6CircuitConnectionConfigText</PropertyName>
</ListItem>
<ListItem>
<Label>RouteServerId</Label>
<PropertyName>RouteServerId</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
Expand Down