Review Azure SQL administrator login names

Use a valid administrator login name that follows organizational naming standards.

Description

For a new Azure SQL server, set administrator_login to a valid name that meets your organization’s policy.

Potential impact

A common login name is easy to guess. Changing the login on an existing server makes AzureRM replace the server.

Remediation

Supply a strong, unique password securely and restrict administrative connections. For MFA, have administrators sign in with Entra identities and enforce MFA for Azure SQL through Conditional Access. On an existing server, check terraform plan for replacement and plan the migration before applying it.

Examples

var.sql_admin_name supplies the login name. Replace the sample password with a secret from secure storage.

Before

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

After

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

References