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.

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.