I have been trying to extract DDL changes from SQL Server via Extended Events, we needed to know the type of change and the user who made the change. We wanted to avoid the use of triggers where possible and liked the idea of extended events as they are not part of the running transaction when a schema change is made.
Doing this on an on-premise server seems to work pretty well, populating a queue from a notification listening for DDL_DATABASE_LEVEL_EVENTS.
However, I need this solution to work on Azure so my first thought was to do exactly the same but the service broker does not work on Azure so I then looked at using EVENT SESSION sending the information to a ring buffer but this does not appear to be able to get the same events.
Is it possible to get this information on Azure via the ring buffer or do I have to revert to using triggers?
Best Answer
Assuming you are on v12, then Extended Events (with Ring Buffer target) are available but there is what is known as a reduced surface area, or less things you can do. If I run the query below to list available actions, events and targets (sourced from here) I get 941 rows on my SQL Server 2014 and only 71 rows on my v12 Azure database, as at today:
As you know with Azure, things get added so it may well catch up.
That said, there are three events available which would allow you to track DDL changes on your v12 Azure database:
Based on these three events, I scripted this Extended Events session to track DDL on my v12 Azure database:
My results:
Remember to drop your Azure Extended Event sessions when you're not using them. You might also consider an Event File target which writes to an Azure Storage container because the ring buffer can fill up and cycle.
HTH