Azure MSSQL Server public network access needs review

Identify required database connection paths and restrict unnecessary public access.

Description

When public access is enabled on an Azure SQL logical server, its firewall rules determine which external clients can attempt to connect. Database authentication and permissions govern access to data.

Potential impact

A broad firewall rule exposes the sign-in endpoint to unnecessary clients, increasing the impact of leaked credentials or excessive permissions.

Remediation

For private-only access, test the private endpoint, DNS and client routes before setting public_network_access_enabled = false. If the public endpoint is required, restrict its firewall to approved sources. Use strong authentication and least-privilege database permissions, then verify application connectivity.

Examples

The excerpts use the same SQL server and omit private endpoints and DNS. Supply the administrator password through a protected input.

Before

hcl
resource "azurerm_mssql_server" "app_db" {
  name                         = "mssqlserver"
  resource_group_name          = azurerm_resource_group.example.name
  location                     = azurerm_resource_group.example.location
  version                      = "12.0"
  administrator_login          = "mradministrator"
  administrator_login_password = "thisIsDog11"
}

AzureRM defaults the omitted public_network_access_enabled flag to true. Check the deployed network setting and firewall rules.

After

hcl
resource "azurerm_mssql_server" "app_db" {
  name                         = "mssqlserver"
  resource_group_name          = azurerm_resource_group.example.name
  location                     = azurerm_resource_group.example.location
  version                      = "12.0"
  administrator_login          = "mradministrator"
  administrator_login_password = "thisIsDog11"
  public_network_access_enabled = false
}

false disables public access. Test that the application connects through the private path.

References