I am trying to list azure firewall policies using Get-AzFirewallPolicy command, but running into mapping error when trying to obtain details of one of the firewall policies.
Following is the command execution:
Get-AzFirewallPolicy -Name "FirewallPolicy_AzureFirewall_EU_NonProd" -ResourceGroupName "RG-Firewalls-NonProd"
Following is the error message:
Get-AzFirewallPolicy : Error mapping types.
Mapping types:
FirewallPolicy -> PSAzureFirewallPolicy
Microsoft.Azure.Management.Network.Models.FirewallPolicy -> Microsoft.Azure.Commands.Network.Models.PSAzureFirewallPolicy
Type Map configuration:
FirewallPolicy -> PSAzureFirewallPolicy
Microsoft.Azure.Management.Network.Models.FirewallPolicy -> Microsoft.Azure.Commands.Network.Models.PSAzureFirewallPolicy
Property:
ThreatIntelWhitelist
At line:1 char:1
+ Get-AzFirewallPolicy -Name "FirewallPolicy_AzureFirewall_EU_NonProd ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzFirewallPolicy], AutoMapperMappingException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Network.GetAzureFirewallPolicyCommand
I have tried updating my Az.Network(was 5.x now 7.x version) module, but no luck.
TIA
2
Answers
can you check these, firstly make sure you are using the latest version of the Azure PowerShell module.
and verify the API version used by the Get-AzFirewallPolicy command. You can use the -ApiVersion parameter to specify the API version explicitly.
This error related to the mapping of types in the Azure PowerShell module try to use below command and
Install-Module -Name Az -Force
it will update up to date Azure PowerShell module.When I ran this PowerShell command, I got detail list of firewall policy like below:
Output:
If still error persists, try updating the
Az.Network
module to the latest version using below command: