Edit

Share via


New-AzureSqlDatabaseServerFirewallRule

Creates a firewall rule in Azure SQL Database Server.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

IpRange (Default)

New-AzureSqlDatabaseServerFirewallRule
    -ServerName <String>
    -RuleName <String>
    -StartIpAddress <String>
    -EndIpAddress <String>
    [-Force]
    [-Profile <AzureSMProfile>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

AllowAllAzureServices

New-AzureSqlDatabaseServerFirewallRule
    -ServerName <String>
    [-RuleName <String>]
    [-AllowAllAzureServices]
    [-Force]
    [-Profile <AzureSMProfile>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The New-AzureSqlDatabaseServerFirewallRule cmdlet creates a firewall rule in the specified instance of Azure SQL Database Server in the current subscription.

Use the StartIpAddress and EndIpAddress parameters to specify a range of IP addresses that this rule allows to connect to the Azure SQL Database server.

Specify the AllowAllAzureServices parameter to create a rule that allows Azure connections to the server. The rule has starting and ending IP address values of 0.0.0.0. If you do not specify a firewall rule name, this cmdlet assigns the default name AllowAllAzureServices.

Examples

Example 1: Create a firewall rule

PS C:\>New-AzureSqlDatabaseServerFirewallRule -ServerName "lpqd0zbr8y" -RuleName "FirewallRule24" -StartIpAddress 10.1.1.1 -EndIpAddress 10.1.1.2

This command creates a firewall rule FirewallRule24 on the Azure SQL Database server named lpqd0zbr8y. The command specifies an IP address range.

Example 2: Create a rule that allows all Azure services

PS C:\>New-AzureSqlDatabaseServerFirewallRule -ServerName "lpqd0zbr8y" -AllowAllAzureServices -RuleName "AzureConnections"

This command creates a firewall rule named AzureConnections on the server named lpqd0zbr8y that allows Azure connections.

Example 3: Create a rule that allows all Azure services that uses the default name Create a rule that allows all Azure services that uses the default name

PS C:\>New-AzureSqlDatabaseServerFirewallRule -ServerName "lpqd0zbr8y" -AllowAllAzureServices

This command creates a firewall rule on the specified server named lpqd0zbr8y that allows Azure connections. The command assigns the default rule name AllowAllAzureServices.

Parameters

-AllowAllAzureServices

Indicates that this firewall rule enables all Azure IP addresses to access the server.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AllowAllAzureServices
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-EndIpAddress

Specifies the end value of the IP address range for this rule.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

IpRange
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Forces the command to run without asking for user confirmation.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Profile

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Parameter properties

Type:AzureSMProfile
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RuleName

Specifies the name of the new firewall rule.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

IpRange
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ServerName

Specifies the name of a server. This cmdlet creates a firewall rule on the server that this cmdlet specifies. Specify the server name, not the fully qualified DNS name.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-StartIpAddress

Specifies the start value of the IP address range for the firewall rule.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

IpRange
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Outputs

Microsoft.WindowsAzure.Commands.SqlDatabase.Model.SqlDatabaseServerFirewallRuleContext