Description
Enable auditing on the logical Azure SQL server to track the connections or changes you need across its databases. Check database-specific policies where additional actions need to be recorded.
Potential impact
Missing records make it harder to trace when a particular account accessed or changed data.
Remediation
Set the server audit actions, destination, write permissions and retention. For Blob Storage alone, set log_monitoring_enabled to false. To also use Azure Monitor, keep the AzureRM 5.6.0 default of true and configure SQLSecurityAuditEvents in the master database’s diagnostic settings. Perform a selected operation in one of the server’s databases and check each destination you use.
Examples
The second example adds a server audit policy with 90-day retention at the referenced Blob Storage endpoint. Use separately managed administrator credentials in production.
Before
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 = "mradministrator"
administrator_login_password = "thisIsDog11"
}
After
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 = "mradministrator"
administrator_login_password = "thisIsDog11"
}
resource "azurerm_mssql_server_extended_auditing_policy" "example" {
server_id = azurerm_mssql_server.example.id
blob_storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint
storage_account_access_key = azurerm_storage_account.example.primary_access_key
storage_account_access_key_is_secondary = false
retention_in_days = 90
}