Microsoft Docs

Azure SQL Database Networking

This document provides a comprehensive overview of networking capabilities and considerations for Azure SQL Database. Understanding and configuring network access is crucial for securing your data and ensuring efficient connectivity.

Key Networking Concepts

Azure SQL Database offers several mechanisms to control network access. These include:

Firewall Configuration

Firewall rules are the first line of defense for your Azure SQL Database. You can configure these through the Azure portal, Azure CLI, PowerShell, or Transact-SQL.

Server-Level Firewall Rules

These rules apply to all databases on your Azure SQL Database server. They are useful for allowing access from trusted client IP addresses, such as your development machine or on-premises network.

To create a server-level firewall rule using Azure CLI:

az sql server firewall-rule create --resource-group  --server  --name "AllowMyIP" --start-ip-address  --end-ip-address 

Database-Level Firewall Rules

These rules apply to a specific database. They offer more granular control for scenarios where different databases might have different access requirements.

To create a database-level firewall rule using T-SQL:

EXEC sp_set_database_firewall_rule N'MyDatabase', N'AllowSpecificClient', '192.168.1.100', '192.168.1.100';
Important: Ensure that your client IP address is correctly configured. If you are connecting from a dynamic IP address, you may need to use a service like Azure VPN Gateway or ensure your firewall rule covers a broader range.

Virtual Network Service Endpoints

Service endpoints extend your virtual network's private address space and Identity of the virtual network subnet to the Azure service. This ensures that traffic from your VNet to Azure SQL Database travels over the Azure backbone network, bypassing the public internet.

To enable service endpoints for Azure SQL Database on a subnet:

az network vnet subnet update --resource-group  --vnet-name  --name  --service-endpoints Microsoft.Sql

Once service endpoints are enabled, you can configure VNet rules to allow access from specific subnets.

az sql server vnet-rule create --resource-group  --server  --name "AllowVNetSubnet" --subnet-id "/subscriptions//resourceGroups//providers/Microsoft.Network/virtualNetworks//subnets/"

Azure Private Link

Azure Private Link provides the ultimate in network isolation by enabling you to access Azure SQL Database via a private endpoint. A private endpoint is a network interface that uses a private IP address from your virtual network, effectively bringing the Azure SQL Database service into your virtual network.

Key benefits of Private Link include:

Consideration: Private Link offers the highest level of security but requires careful planning for DNS resolution and network configuration.

Connection Strings

Connection strings for Azure SQL Database typically include the server name, database name, and authentication credentials. When using Private Link, ensure your DNS is configured to resolve the server name to the private endpoint's IP address.

A typical connection string might look like this:

Server=tcp:your-server-name.database.windows.net,1433;Initial Catalog=your-database-name;Persist Security Info=False;User ID=;Password=;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

Troubleshooting Network Connectivity

Common issues and troubleshooting steps include:

For detailed troubleshooting guides, please refer to the official Microsoft documentation.