Description
Database threat detection alerts you to unusual activity such as suspicious logins. An audit policy stores records for investigation. Saving those records alone does not enable threat detection.
Potential impact
Without applicable Defender for SQL protection, suspicious activity in this database can go unreported.
Remediation
Set state to Enabled in threat_detection_policy and confirm Defender for SQL covers the database. If a test notification is available, verify that it reaches the intended recipient. Separately, check storage for a record of an operation you selected for auditing.
Examples
Both excerpts retain database audit logs in Blob Storage for six days. The second changes only threat detection. Choose audit retention to cover your investigation period.
Before
resource "azurerm_mssql_database" "example" {
name = "myexamplesqldatabase"
server_id = azurerm_mssql_server.example.id
threat_detection_policy {
state = "Disabled"
}
}
resource "azurerm_mssql_database_extended_auditing_policy" "example" {
database_id = azurerm_mssql_database.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 = 6
}
After
resource "azurerm_mssql_database" "example" {
name = "myexamplesqldatabase"
server_id = azurerm_mssql_server.example.id
threat_detection_policy {
state = "Enabled"
}
}
resource "azurerm_mssql_database_extended_auditing_policy" "example" {
database_id = azurerm_mssql_database.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 = 6
}