skip to Main Content

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


  1. can you check these, firstly make sure you are using the latest version of the Azure PowerShell module.

    Update-Module -Name Az -Force

    and verify the API version used by the Get-AzFirewallPolicy command. You can use the -ApiVersion parameter to specify the API version explicitly.

    Get-AzFirewallPolicy -Name "FirewallPolicy_AzureFirewall_EU_NonProd" -ResourceGroupName "RG-Firewalls-NonProd" -ApiVersion '2020-05-01'
    Login or Signup to reply.
  2. 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:

    $firewallPolicy = Get-AzFirewallPolicy -Name "FWNAME" -ResourceGroupName "RGName"
    $firewallPolicy | Format-List *
    

    Output:

    Identity             : 
    ThreatIntelMode      : Alert
    ThreatIntelWhitelist : 
    BasePolicy           : 
    ProvisioningState    : Succeeded
    RuleCollectionGroups : {/subscriptions/bxxxxxxxxb5ba-2b83xxxxxxf/resourceGroups/Networking-Resources/providers/Microsoft.Network/firewallPolicies/fw-test-pol/ruleCollectionGroups/DefaultAppl
                           icationRuleCollectionGroup, /subscriptions/xxxxxxxxxx-b5ba-2b8xxxxxxxf/resourceGroups/Networking-Resources/providers/Microsoft.Network/firewallPolicies/fw-test-pol/ruleC
                           ollectionGroups/DefaultNetworkRuleCollectionGroup, /subscriptions/xxxxxxxxxxx5ba-2b8xxxxf/resourceGroups/Networking-Resources/providers/Microsoft.Network/firewallPol
                           icies/fw-test-pol/ruleCollectionGroups/DefaultDnatRuleCollectionGroup, /subscriptions/xxxxxxxxxxx-b5ba-2b83a074c23f/resourceGroups/Networking-Resources/providers/Microsoft
                           .Network/firewallPolicies/fw-test-pol/ruleCollectionGroups/testgroup...}
    DnsSettings          : 
    SqlSetting           : 
    IntrusionDetection   : 
    TransportSecurity    : 
    Sku                  : Microsoft.Azure.Commands.Network.Models.PSAzureFirewallPolicySku
    Snat                 : 
    ExplicitProxy        : 
    PrivateRange         : 
    PrivateRangeText     : null
    ResourceGroupName    : Networking-Resources
    Location             : westus2
    ResourceGuid         : 
    Type                 : Microsoft.Network/FirewallPolicies
    Tag                  : {CreatedBy, CreatedDate, OwningTeam, Reason}
    TagsTable            : 
                           Name         Value                
                           ===========  =====================
                           CreatedBy    chnaykod             
                           CreatedDate  4/12/2022 10:17:31 PM
                           OwningTeam   Integration          
                           Reason       Repro                
                           
    Name                 : fw-test-pol
    Etag                 : 44XXXXXXXXXb0fe22
    Id                   : /subscriptions/b83cXXXXXXX/resourcegroups/Networking-Resources/providers/Microsoft.Network/firewallPolicies/fw-test-pol
    

    enter image description here

    If still error persists, try updating the Az.Network module to the latest version using below command:

    Update-Module -Name Az.Network
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search