Azure PowerShell Documentation

Az.SqlDatabaseFirewallRule

The Az.SqlDatabaseFirewallRule cmdlet family provides commands for managing firewall rules on Azure SQL databases.

Syntax

Get-AzSqlDatabaseFirewallRule
   [-ResourceGroupName] <String>
   [-ServerName] <String>
   [-DatabaseName] <String>
   [-FirewallRuleName] <String>
   [-Expand <String[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]

New-AzSqlDatabaseFirewallRule
   -ResourceGroupName <String>
   -ServerName <String>
   -DatabaseName <String>
   -FirewallRuleName <String>
   -StartIpAddress <String>
   -EndIpAddress <String>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf] [-Confirm]

Remove-AzSqlDatabaseFirewallRule
   -ResourceGroupName <String>
   -ServerName <String>
   -DatabaseName <String>
   -FirewallRuleName <String>
   [-Force] [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf] [-Confirm]

Parameters

ParameterTypeDescription
-ResourceGroupNameStringName of the resource group that contains the SQL server.
-ServerNameStringName of the Azure SQL server.
-DatabaseNameStringName of the Azure SQL database.
-FirewallRuleNameStringName of the firewall rule to manage.
-StartIpAddressStringStarting IP address of the rule range (e.g., 0.0.0.0).
-EndIpAddressStringEnding IP address of the rule range (e.g., 255.255.255.255).
-ForceSwitchParameterSuppresses confirmation prompts.
-WhatIfSwitchParameterShows what would happen if the command runs.
-ConfirmSwitchParameterPrompts for confirmation before executing.

Examples

# Get all firewall rules for a database
Get-AzSqlDatabaseFirewallRule `
  -ResourceGroupName "MyResourceGroup" `
  -ServerName "my-sql-server" `
  -DatabaseName "mydb"
# Create a new firewall rule allowing IP range 203.0.113.0 - 203.0.113.255
New-AzSqlDatabaseFirewallRule `
  -ResourceGroupName "MyResourceGroup" `
  -ServerName "my-sql-server" `
  -DatabaseName "mydb" `
  -FirewallRuleName "AllowAppSubnet" `
  -StartIpAddress "203.0.113.0" `
  -EndIpAddress "203.0.113.255"
# Remove an existing firewall rule
Remove-AzSqlDatabaseFirewallRule `
  -ResourceGroupName "MyResourceGroup" `
  -ServerName "my-sql-server" `
  -DatabaseName "mydb" `
  -FirewallRuleName "AllowAppSubnet" -Force

Related Links