如何删除 Azure MSSQL 审核日志

How to remove Azure MSSQL audit logs

看起来我们已经过 SQL 审核,默认保留期为 0。我注意到 Azure 存储帐户的价格上涨了。 Azure 文档说,如果我更改保留期,现有日志将不会 affected/deleted.

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-auditing#subheading-2

Important

The default value for retention period is 0 (unlimited retention). You can change this value by moving the Retention (Days) slider in Storage settings when configuring the storage account for auditing.

If you change retention period from 0 (unlimited retention) to any other value, please note that retention will only apply to logs written after retention value was changed (logs written during the period when retention was set to unlimited are preserved, even after retention is enabled)

如何清除超过 180 天的日志?

我认为您可以手动删除超过 180 天的日志。

通常,审核日志存储在存储中。

Audit 将创建一个容器来将日志存储在您的存储帐户中:

SQL 服务器文件夹:

数据库文件夹:

选择数据库:

据我了解(如有遗漏,请指正):

  • 如果您将保留期设置为其他日期(不是 0),则新日志是 存储在文件夹 SqlDbAuditing_Audit.
  • 如果保留期为0,数据库审计日志存储在 SqlDbAuditing_Audit_NoRetention,服务器审核日志存储在 SqlDbAuditing_ServerAudit_NoRetention.

您可以清除文件夹 SqlDbAuditing_Audit_NoRetentionSqlDbAuditing_ServerAudit_NoRetention 中超过 180 天的日志。

希望对您有所帮助。