Set Firewall Rule (classic)
THIS TOPIC APPLIES TO: SQL Server Azure SQL DatabaseAzure SQL Data Warehouse Parallel Data Warehouse
Update a firewall rule for an Azure SQL Database server.
Important
The recommended REST commands to work with SQL Database are the Resource Manager based Azure SQL Database REST API. While there is no change to SQL Database, be aware that the classic deployment model command in this article is scheduled for deprecation on December 1, 2019. For a table providing links to the specific new commands you should use, see Operations for Azure SQL Databases.
Request
The Set Firewall Rule request must be specified as follows:
Replace {subscriptionId} with your subscription ID.
Replace {serverName} with the name of the server to set the firewall rule on.
Replace {firewallRuleName} with your firewall rule name.
Method | Request URI | HTTP Version |
---|---|---|
PUT | https://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/firewallrules/{firewallRuleName} | HTTP/1.1 |
If the operation returns success, the operation is complete, but changes will be effective five minutes later. If the operation returns failure, and the error is user error, no changes will be applied. If there is a communication error or an internal server error, the current state needs to be determined with Get Firewall Rule (classic).
In SQL Database, login data required to authenticate a connection and server-level firewall rules are temporarily cached in each database. This cache is periodically refreshed. To force a refresh of the authentication cache and make sure that a database has the latest version of the logins table, execute DBCC FLUSHAUTHCACHE (Transact-SQL).
URI Parameters
None.
Request Headers
The following table describes the required and optional request headers:
Request Header | Description |
---|---|
x-ms-version | Required. Specifies the version of the operation to use for this request. This header should be set to 2012-03-01. |
Request Body
The format of the request body is as follows:
<ServiceResource xmlns="https://schemas.microsoft.com/windowsazure">
<Name>AllowAll</Name>
<StartIPAddress>0.0.0.0</StartIPAddress>
<EndIPAddress>255.255.255.255</EndIPAddress>
</ServiceResource>
The following table describes the elements of the request body:
Element Name | Description |
---|---|
Name | The name of the firewall rule. |
StartIPAddress | 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 server. The lowest possible IP address is 0.0.0.0. |
EndIPAddress | 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 server. The highest possible IP address is 255.255.255.255. |
Response
The response includes an HTTP status code, a set of response headers, and a response body.
Status Code
Response Headers
The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.
Response Header | Description |
---|---|
x-ms-request-id | A value that uniquely identifies a request made against the database management service. This request id is used for request tracking. If a failure occurs that requires the user to contact Microsoft Support, the request id should be provided to Microsoft to assist in tracking and resolving the failure for the request. |
Response Body
The following is an example response body:
<ServiceResource xmlns="https://schemas.microsoft.com/windowsazure">
<Name>AllowAll</Name>
<Type>Microsoft.SqlAzure.FirewallRule</Type>
<State>Normal</State>
<SelfLink>https://management.core.windows.net/2eae7c21-ffd1-49e4-ac22-39095e0b9f02/services/sqlservers/servers/bpr0d6li5t/firewallrules/AllowAll</SelfLink>
<ParentLink>https://management.core.windows.net/2eae7c21-ffd1-49e4-ac22-39095e0b9f02/services/sqlservers/servers/bpr0d6li5t</ParentLink>
<StartIPAddress>0.0.0.0</StartIPAddress>
<EndIPAddress>255.255.255.255</EndIPAddress>
</ServiceResource>
The following table describes the elements in the response body:
Element Name | Description |
---|---|
Name | The name of the firewall rule. |
Type | The type of this service resource; Microsoft.SqlAzure.FirewallRule. |
State | The state of the service resource. |
SelfLink | The URI identifier for this resource. |
ParentLink | The URI identifier for the parent of this resource (the server). |
StartIPAddress | The lowest IP address in the range of the server-level firewall setting. |
EndIPAddress | The highest IP address in the range of the server-level firewall setting. |
See Also
Common REST API Error Codes
Azure SQL Database
Azure SQL Database Firewall
Azure SQL Database Security Guidelines and Limitations
Operations for Azure SQL Databases
Azure SQL Database Cmdlets