I need to investigate some events from Azure SQL Database.
The Audit logs were stored on a Storage Account and I have downloaded them on my laptop. They are now all in the same folder.
There are many guides that explains you how to import such files into SQL Server:
- https://www.brentozar.com/archive/2015/01/query-extended-events-target-xml/
- https://gist.github.com/brazilnut2000/f9e9859f095219b1a17d151292efc278
- https://www.sqlservercentral.com/forums/topic/reading-from-extended-events-xml-column-event_data
- https://dba.stackexchange.com/questions/226704/how-to-view-xevent-event-file-data
But when I try to run the query
SELECT event_data = convert(XML, event_data)
FROM sys.fn_xe_file_target_read_file(N'C:\Users\FrancescoMantovani\Downloads\Investigate\*.xel', NULL, NULL, NULL);
I receive the error:
Msg 25718, Level 16, State 3, Line 1 The log file name "C:\Users\FrancescoMantovani\Downloads\Investigate*.xel" is invalid. Verify that the file exists and that the SQL Server service account has access to it.
What am I doing wrong?
EDIT: I tried to put the files into the DATA
folder inside Microsoft SQL Server, the error has now changed. Command:
SELECT event_data = convert(XML, event_data)
FROM sys.fn_xe_file_target_read_file(N'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\Investigate\00_00_06_511_24.xel', NULL, NULL, NULL);
Error:
Msg 25748, Level 16, State 9, Line 1
The file "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\Investigate\00_00_06_511_24.xel" contains audit logs. Audit logs can only be accessed by using the fn_get_audit_file function.