Audit Trails Unleashed: Automating Power BI Logs to SQL via ADF

Tracking Power BI Report Access Across All Workspaces Using ADF and the Power BI REST API.

One of the most common requests I receive as a data engineer is:

“Can you get me a list of people who have accessed our Power BI reports?”

At first, this sounded simple enough. Power BI’s built-in Usage Metrics report gives you user and report access information right out of the box.
But, as expected, the requirements quickly evolved — the business wanted usage tracking across all workspaces and reports in the organization.

That’s when things got interesting.

The Challenge

The out-of-the-box Power BI usage analytics are scoped to individual reports and workspaces. Expanding this to every report across the tenant is not something Power BI natively supports — at least not easily.

So, I started looking for alternatives.

The Microsoft Purview Approach (and Its Limitation)

After some exploration, I found that Microsoft Purview (via compliance.microsoft.com) captures audit events such as "Viewed Report".

At first, this seemed perfect — it gave me all report access activity across the tenant for a selected time period. I thought:

“Yay… problem solved!”

But there was a catch.

  • Purview retains audit logs for only the past 90 days.

  • Extracting the data is manual and time-consuming.

So, while it provided visibility, it wasn’t a sustainable or scalable solution.

The Breakthrough: Power BI REST API

That’s when I stumbled upon the Power BI Admin REST API — a hidden gem for automation enthusiasts.

The endpoint I used was:

https://api.powerbi.com/v1.0/myorg/admin/activityevents

This API allows you to query Power BI audit logs programmatically for specific time windows.
Exactly what I needed to build a long-term, automated solution.

And since I love working with Azure Data Factory (ADF), that became my orchestration tool of choice.

Building the Automated Solution in Azure Data Factory

Here’s how I automated Power BI audit log extraction into Azure SQL Database.

Step 1: App Registration

First, register an application in Azure AD and grant it the following API permission:

This must be Application-level permission (not Delegated).
Then authenticate this app in ADF using the Service Principal (Client ID, Secret, and Tenant ID).

Step 2: Configure the REST API Source

In Azure Data Factory:

  1. Create a REST linked service to connect to the Power BI API.
  2. Create a dataset under the adming API.
  3. In the dataset’s relative URL, enter the following expression:activityevents?startDateTime=’@{formatDateTime(getPastTime(item(), ‘Day’), ‘yyyy-MM-dd’)}T00:00:00.000Z’&endDateTime=’@{formatDateTime(getPastTime(item(), ‘Day’), ‘yyyy-MM-dd’)}T23:59:59.999Z’

This dyanmically builds the start and end time for each day transaction

 

Step 3: Configure the Destination (SQL)

Create a SQL linked service and dataset pointing to your Azure SQL Database — this will store the audit logs retrieved from Power BI.

Step 4: Set Up the Copy Activity

Now, in your Copy Data activity:

  1. Add a parameter to define how many days of data you want to extract.

  2. In the “Items” property, use this expression:

    @range(1, pipeline().parameters.Daystoextract)

    This allows the pipeline to loop through a range of days, calling the API once per day.

Finally, map your columns between the REST source and SQL destination.

Step 5: Run and Schedule

Run your pipeline manually for a few test days to validate data flow.
Once verified, schedule it to run daily (e.g., using a trigger).

This ensures that you continuously capture and append audit data into SQL — effectively creating your own Power BI audit warehouse.

The Outcome

With this automated setup:

  • You have a complete and permanent record of Power BI report views.

  • Data is stored securely in Azure SQL for as long as you need.

  • You can even build a Power BI dashboard on top of this SQL table for real-time usage insights.

No more 90-day limit. No more manual exports. Everything runs automatically.

Power BI Unchained

I recently ran into a snag when I wanted to use Power BI for some projects at home. Like any curious data enthusiast, I downloaded Power BI Desktop to my personal laptop, excited to dive in. Almost straight away, I was met with an all-too-familiar screen: Power BI kept asking me to enter my email address.

I am sure many of us are familiar with this screen

.

If you’ve ever tried this, you probably know the one I’m talking about—it only likes work or school emails, not our regular personal ones! I didn’t want to go through the hassle of setting up a special office account, especially if it meant worrying about trial periods or future costs.

So, I went digging online for a workaround. After trying a few things, I found a simple fix that worked perfectly: In Power BI, head to the Options menu, look under Preview Features, and disable something called “Translytical Task Flow.”

That’s it! Once I did that, the annoying email prompt was gone, and I could finally get back to building reports for personal use—without jumping through extra hoops or paying for things I didn’t need.

If you’ve been frustrated by this, hopefully this little tip saves you some time and headaches

Table Names in the database and the last time they were Updated

Ever wondered to see all the tables names and the last time they were updated?

This is a query which will give you all the desired result.

Select
Distinct Object_name(object_id) as DatabaseName,
Object_id,
Database_id,
Last_user_update
From
Sys.dm_db_index_usage_stats
Where
database_id = db_id() and last_user_update is not null