Restrict SQL Server Instance Access to a Single Subnet

GitaraniSharma-MSFT 50,021 Reputation points Microsoft Employee Moderator
2024-08-01T12:18:29.3266667+00:00

How can I configure my SQL Server instance on Azure to allow connections only from a specific subnet and deny access from all other subnets in a Hub and spoke topology?

PS - Based on common issues that we have seen from customers and other sources; we are posting these questions to help the Azure community.

Azure SQL Database
Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,762 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. GitaraniSharma-MSFT 50,021 Reputation points Microsoft Employee Moderator
    2024-08-01T12:19:06.52+00:00

    To configure your SQL Server instance on Azure to allow connections only from a specific subnet while denying access from all other subnets in a Hub and spoke topology, follow these steps:

    1. Use Private Endpoints and enable network policies: Ensure that your SQL Server instance is using a private endpoint. This allows you to leverage Azure's network security features to control access.
    2. Add/Modify Network Security Group (NSG) Rules:
      • Navigate to the Azure portal and find the SQL Server instance.
      • Locate the "Networking" section and identify the private endpoint associated with the SQL Server.
      • Confirm that the NSG is applied to the subnet containing the private endpoint.
      • Modify the NSG rules to allow traffic only from the specific subnet by adding an "Allow" rule for the IP range of that subnet.
      • Add "Deny" rules for other subnets or ensure a default deny rule is in place to block traffic from all other subnets.

    For comprehensive guidance, please refer to the Microsoft documentation on managing network policies for private endpoints: Manage network policies for private endpoints - Azure Private Link.

    Additional References:

    Please do not forget to "up-vote" wherever the information provided helps you, as this can be beneficial to other community members.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.