Verify that 'Auditing' Retention is 'greater than 90 days'
Why this matters
Audit logs are critical for detecting and investigating security incidents. Setting audit log retention to more than 90 days ensures that there is sufficient historical data available to analyze anomalies, identify breaches, and comply with legal or regulatory requirements.
What this check does
This Auto Check verifies that Azure SQL Server auditing, if enabled and writing to a storage account, retains logs for more than 90 days, or is set to 0 (unlimited).
Check Logic
Passes if:
RetentionInDays > 90
- or
RetentionInDays = 0
Fails if:
RetentionInDays <= 90
and not unlimited
Applies to:
- Azure SQL Servers with auditing configured to a supported destination (Blob Storage, Event Hub, Log Analytics)
How to fix it
Azure Portal
- Navigate to SQL servers
- Select the server
- Go to Auditing
- If Storage, Log Analytics, or Event Hub is selected, expand Advanced properties
- Set Retention (days) to greater than 90 or 0 (unlimited)
- Click Save
- Azure PowerShell
Log Analytics:
Set-AzSqlServerAudit `
-ResourceGroupName <resourceGroupName> `
-ServerName <sqlServerName> `
-RetentionInDays <value greater than 90> `
-LogAnalyticsTargetState Enabled `
-WorkspaceResourceId "/subscriptions/<subscriptionId>/resourceGroups/<group>/providers/Microsoft.OperationalInsights/workspaces/<workspaceName>"
Event Hub:
Set-AzSqlServerAudit `
-ResourceGroupName "<resourceGroupName>" `
-ServerName "<sqlServerName>" `
-EventHubTargetState Enabled `
-EventHubName "<eventHubName>" `
-EventHubAuthorizationRuleResourceId "<eventHubAuthRuleResourceId>"
Blob Storage:
Set-AzSqlServerAudit `
-ResourceGroupName "<resourceGroupName>" `
-ServerName "<sqlServerName>" `
-BlobStorageTargetState Enabled `
-StorageAccountResourceId "/subscriptions/<subscriptionId>/resourceGroups/<group>/providers/Microsoft.Storage/storageAccounts/<accountName>" `
-RetentionInDays <value greater than 90>
Exceptions
None. Retaining audit logs for less than 90 days is considered non-compliant. Unlimited (0
) is acceptable if log lifecycle management is handled via external tooling.