sp_set_firewall_rule (SQL Azure Database)
Creates or updates the firewall settings for your SQL Azure 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 SQL Azure Database and is not supported in on-premise SQL Server.
Syntax Conventions (SQL Azure 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 SQL Azure Database.
| Name | Datatype | Description | ||
|---|---|---|---|---|
|
[@name = ] ‘name’ |
NVARCHAR(128) |
The name used to describe and distinguish the firewall setting. |
||
|
[@start_ip_address =] ’start_ip_address’ |
VARCHAR(50) |
The lowest IP address in the range of the firewall setting. IP addresses equal to or greater than this can attempt to connect to the SQL Azure server. The lowest possible IP address is |
||
|
[@end_ip_address =] ‘end_ip_address’ |
VARCHAR(50) |
The highest IP address in the range of the firewall setting. IP addresses equal to or less than this can attempt to connect to the SQL Azure server. The highest possible IP address is
|
The names of 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 firewall setting will be created.
When you add a firewall setting where the beginning and ending IP addresses are equal to 0.0.0.0, you enable access to your SQL Azure server from Windows Azure. Provide a value to the name parameter that will help you remember what the firewall setting is for.
The following code creates a 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 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 new 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 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'
Note