You administer an Azure SQL Database logical server named sql-fabrikam-02 that hosts several user databases. More databases will be added next quarter.
- Your workstation already has a server-level firewall rule, and you can connect by using SQL Server Management Studio (SSMS) with the server admin login.
- Users in a new on-premises branch office connect from the public IP range 192.0.2.0 to 192.0.2.255.
Requirements:
- Users from the branch office range must be able to connect to every database on the server, including databases created later.
- Change management requires that the change be made with a T-SQL script, not through the Azure portal.
Which actions should you perform, in order, to meet the requirements?
You didn't answer this one.
Only a server-level rule covers every database on the server, including databases created later, so database-level rules in each database do not meet the first requirement. The T-SQL requirement excludes the portal, leaving sp_set_firewall_rule, which is run from within master. You therefore connect with SSMS, open a query on master, and run the stored procedure with the branch office's start and end addresses.
- Step 1: In SSMS, connect to sql-fabrikam-02 by using the server admin login. Every T-SQL action requires a connection to the server first, and your workstation's existing server-level rule allows it.
- Step 2: In Object Explorer, expand System Databases, right-click master, and select New Query. Object Explorer shows the server's databases only after the connection is made; sp_set_firewall_rule is run from within master.
- Step 3: In the master query window, execute sp_set_firewall_rule with a rule name, a start IP address of 192.0.2.0, and an end IP address of 192.0.2.255. The stored procedure must run in the master query window opened in the previous step to create a server-level rule.
- Not needed: In each user database, execute sp_set_database_firewall_rule for the range 192.0.2.0 to 192.0.2.255. Database-level rules apply only to the database in which they are created, so databases added next quarter would not be covered, which breaks requirement 1.
- Not needed: In the Azure portal, open the Networking page of sql-fabrikam-02, add a firewall rule for 192.0.2.0 to 192.0.2.255, and select Save. This creates a valid server-level rule, but it uses the Azure portal, which breaks requirement 2.
- Not needed: In a user database, execute sp_set_firewall_rule for the range 192.0.2.0 to 192.0.2.255. Server-level rules are created with sp_set_firewall_rule from within the master database, not from a user database.