Get-AzFirewall

Gets a Azure Firewall.

Syntax

Get-AzFirewall
   [-Name <String>]
   [-ResourceGroupName <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Get-AzFirewall cmdlet gets one or more Firewalls in a resource group.

Examples

1: Retrieve all Firewalls in a resource group

Get-AzFirewall -ResourceGroupName rgName

This example retrieves all Firewalls in resource group "rgName".

2: Retrieve a Firewall by name

Get-AzFirewall -ResourceGroupName rgName -Name azFw

This example retrieves Firewall named "azFw" in resource group "rgName".

3: Retrieve a firewall and then add a application rule collection to the Firewall

$azFw=Get-AzFirewall -Name "azFw" -ResourceGroupName "rgName"
$appRule = New-AzFirewallApplicationRule -Name R1 -Protocol "http:80","https:443" -TargetFqdn "*google.com", "*microsoft.com" -SourceAddress "10.0.0.0"
$appRuleCollection = New-AzFirewallApplicationRuleCollection -Name "MyAppRuleCollection" -Priority 100 -Rule $appRule -ActionType "Allow"
$azFw.AddApplicationRuleCollection($appRuleCollection)

This example retrieves a firewall, then adds a application rule collection to the firewall by calling method AddApplicationRuleCollection.

4: Retrieve a firewall and then add a network rule collection to the Firewall

$azFw=Get-AzFirewall -Name "azFw" -ResourceGroupName "rgName"
$netRule = New-AzFirewallNetworkRule -Name "all-udp-traffic" -Description "Rule for all UDP traffic" -Protocol "Udp" -SourceAddress "*" -DestinationAddress "*" -DestinationPort "*"
$netRuleCollection = New-AzFirewallNetworkRuleCollection -Name "MyNetworkRuleCollection" -Priority 100 -Rule $netRule -ActionType "Allow"
$azFw.AddNetworkRuleCollection($netRuleCollection)

This example retrieves a firewall, then adds a network rule collection to the firewall by calling method AddNetworkRuleCollection.

5: Retrieve a firewall and then retrieve a application rule collection by name from the Firewall

$azFw=Get-AzFirewall -Name "azFw" -ResourceGroupName "rgName"
$getAppRc=$azFw.GetApplicationRuleCollectionByName("MyAppRuleCollection")

This example retrieves a firewall and then gets a rule collection by name, calling method GetApplicationRuleCollectionByName on the firewall object. The rule collection name for method GetApplicationRuleCollectionByName is case-insensitive.

6: Retrieve a firewall and then retrieve a network rule collection by name from the Firewall

$azFw=Get-AzFirewall -Name "azFw" -ResourceGroupName "rgName"
$getNetRc=$azFw.GetNetworkRuleCollectionByName("MyNetworkRuleCollection")

This example retrieves a firewall and then gets a rule collection by name, calling method GetNetworkRuleCollectionByName on the firewall object. The rule collection name for method GetNetworkRuleCollectionByName is case-insensitive.

7: Retrieve a firewall and then remove a application rule collection by name from the Firewall

$azFw=Get-AzFirewall -Name "azFw" -ResourceGroupName "rgName"
$azFw.RemoveApplicationRuleCollectionByName("MyAppRuleCollection")

This example retrieves a firewall and then removes a rule collection by name, calling method RemoveApplicationRuleCollectionByName on the firewall object. The rule collection name for method RemoveApplicationRuleCollectionByName is case-insensitive.

8: Retrieve a firewall and then remove a network rule collection by name from the Firewall

$azFw=Get-AzFirewall -Name "azFw" -ResourceGroupName "rgName"
$azFw.RemoveNetworkRuleCollectionByName("MyNetworkRuleCollection")

This example retrieves a firewall and then removes a rule collection by name, calling method RemoveNetworkRuleCollectionByName on the firewall object. The rule collection name for method RemoveNetworkRuleCollectionByName is case-insensitive.

9: Retrieve a firewall and then allocate the firewall

$vnet=Get-AzVirtualNetwork -Name "vnet" -ResourceGroupName "rgName"
$publicIp=Get-AzPublicIpAddress -Name "firewallpip" -ResourceGroupName "rgName"
$azFw=Get-AzFirewall -Name "azFw" -ResourceGroupName "rgName"
$azFw.Allocate($vnet, $publicIp)

This example retrieves a firewall and calls Allocate on the firewall to start the firewall service using the configuration (application and network rule collections) associated with the firewall.

Optional Parameters

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Name

Specifies the name of the Firewall that this cmdlet gets.

Type:String
Aliases:ResourceName
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceGroupName

Specifies the name of the resource group that Firewall belongs to.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Inputs

String

Outputs

Microsoft.Azure.Commands.Network.Models.PSAzureFirewall

System.Collections.Generic.IEnumerable`1[[Microsoft.Azure.Commands.Network.Models.PSAzureFirewall, Microsoft.Azure.PowerShell.Cmdlets.Network, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]