This topic has not yet been rated - Rate this topic

sp_set_firewall_rule (Windows Azure SQL Database)

Creates or updates the server-level firewall settings for your SQL Database server. This stored procedure is only available in the master database to the server-level principal login. The sp_set_firewall_rule stored procedure is specific to Windows Azure SQL Database and is not supported in on-premise SQL Server.

Syntax Conventions (Windows Azure SQL Database)

sp_set_firewall_rule [@name = ] ‘name’, [@start_ip_address =] ’start_ip_address’, [@end_ip_address =] ‘end_ip_address’

The following table demonstrates the supported arguments and options in Microsoft Windows Azure SQL Database.

 

Name Datatype Description

[@name = ] ‘name’

NVARCHAR(128)

The name used to describe and distinguish the server-level firewall setting.

[@start_ip_address =] ’start_ip_address’

VARCHAR(50)

The lowest IP address in the range of the server-level firewall setting. IP addresses equal to or greater than this can attempt to connect to the SQL Database server. The lowest possible IP address is 0.0.0.0.

[@end_ip_address =] ‘end_ip_address’

VARCHAR(50)

The highest IP address in the range of the server-level firewall setting. IP addresses equal to or less than this can attempt to connect to the SQL Database server. The highest possible IP address is 255.255.255.255.

noteNote
Windows Azure connection attempts are allowed when both this field and the start_ip_address field equals 0.0.0.0.

The names of server-level firewall settings must be unique. If the name of the setting provided for the stored procedure already exists in the firewall settings table, the starting and ending IP addresses will be updated. Otherwise, a new server-level firewall setting will be created.

When you add a server-level firewall setting where the beginning and ending IP addresses are equal to 0.0.0.0, you enable access to your SQL Database server from Windows Azure. Provide a value to the name parameter that will help you remember what the server-level firewall setting is for.

Only the server-level principal login created by the provisioning process can create or modify server level firewall rules. The user must be connected to the master database to execute sp_set_firewall_rule.

The following code creates a server-level firewall setting called Allow Windows Azure that enables access from Windows Azure.

-- Enable Windows Azure connections.
exec sp_set_firewall_rule N'Allow Windows Azure','0.0.0.0','0.0.0.0'

The following code creates a server-level firewall setting called Example setting 1 for only the IP address 0.0.0.2. Then, the sp_set_firewall_rule stored procedure is called again to allow an additional IP address, 0.0.0.3, in that firewall setting.

-- Create server-level firewall setting for only IP 0.0.0.2
exec sp_set_firewall_rule N'Example setting 1','0.0.0.2','0.0.0.2'

-- Update server-level firewall setting to also allow IP 0.0.0.3
exec sp_set_firewall_rule N'Example setting 1','0.0.0.2','0.0.0.3'

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.