2

My Azure SQL Server has been storing the audit logs for over a year, and storage size is in the TBs. I would like to keep the logs for 3 months max and delete the rest, how can I do this using PowerShell? Would setting the RetentionInDays parameter of Set-AzureRmSqlServerAuditingPolicy cmdlet to 90 days achieve the same? Will it delete anything older than 90 days, or would I need to run a script to explicitly delete them?

Thanks, and really appreciate it.

Hassan K
  • 23
  • 4

1 Answers1

1

You probably left the retention period to the default so the Azure tables created by Azure SQL Auditing will keep data forever. Please set the retention period according to your expectations. Expired records will be deleted.

enter image description here

You can use -RetentionInDays to set the retention period.

Set-AzureRmSqlServerAuditingPolicy -AuditType Table -EventType Login_Failure,Login_Success -StorageAccountName pradebban -StorageKeyType Primary -RetentionInDays 90 -ServerName hiddenserver -ResourceGroupName hiddenresourcegrp -TableIdentifier pradebban
Alberto Morillo
  • 13,893
  • 2
  • 24
  • 30
  • Yes, it was set to default '0' and know it can be changed to 90 days from the UI. Wanted to check if PowerShell could do the same, so thank you for the confirmation. – Hassan K Nov 27 '18 at 10:36