While self-service is an easy way of creating and changing existing reports, organizations may struggle with version control of the reports that are published to a Power BI service. We’ve often heard the sentence “Sh**, I’ve overwritten one of my important reports!”. Yes, this problem can also occur to experienced developers and even consultants of Lytix. In most development environments you can setup version-control to keep track of your changes, and in operational systems a daily backup is taken. Power BI Service however, doesn’t support version control (*)! Despite a ton of ideas have been posted to provide source/version control for reports, I couldn’t really find any on the backlog or planned to integrate with Power BI.

This article describes a way of setting-up your own source control by using the Power BI API to export all reports of a workspace. Having a local copy of your database may come-in handy for those organizations which need to adhere to any compliancy (e.g. SOX compliancy, regulatory requirements) or those that just want to revert loss of data/effort.

Walkthrough

Setting-up the download script is not that hard, but it does require you to follow some steps. Instead of copying the different guides, we’ll redirect you to the different guides on the documentation-site of Microsoft. If you’ve followed the steps one-by-one, you can download our script for free.


Step 1: Make sure you can use the Azure Powershell module. This adds some new functions to your default PowerShell environment to manage Azure objects. https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-2.4.0


Step 2: To validate your ‘requests to download’, we will obtain an identification token. This can be retrieved by following the next steps: https://docs.microsoft.com/nl-be/power-bi/developer/register-app 
Choose a ‘Native’ app and make sure to note down the ApplicationId. 

Step 3: One of the most forgotten steps to take is to ‘Grant Consent’ in the Azure portal. ‘Mostly forgotten’ because of two reasons: firstly, it is hidden in the documentation of Microsoft and, secondly, it is not so easy to retrieve in the Azure Portal as well. As a friendly reminder, I’ve provided an easy screenshot to find this.

Step 4: Download our PowerShell script and change the parameters at the top of the script, easy as ‘one-two-three(-four)’. This script will first create a connection to the Power BI API, then it will search for the WorkspaceID you’ve defined and it will download all the different reports within this workspace. https://lytix.be/product/power-bi-source-control-using-power-bi-api/

Wait, what if I use DirectQuery?

This method will only download what is published to your Power BI Service tenant. If your report is connected in DirectQuery mode to a source, then that data doesn’t get uploaded to Power BI Service and thus can also not be downloaded by our script. Combine this technique with some snapshots of your source system (… and even keeping track of history in your DWH and DataVault) for the best experience.

 

(*) OneDrive and Power BI

Some of the attentive readers may know that there is a way to do out-of-the-box version control with Power BI Service. In the old-way of creating workspaces, a OneDrive folder is created when you make a new workspace. Putting PBIX files on this folder will automatically publish the report to the Service. And the best functionality of OneDrive is to see the version history. BUT(!), Microsoft is now pushing a newer version of the workspaces with better defined roles which doesn’t support the creation of a OneDrive folder anymore. 

Wrap-Up

Thanks for reading through this blog post, we at Lytix hope you’ve learned something new. If you need advice on your data & analytics landscape, send a message to Lytix or the author Sander Allert and we’ll be more than happy to introduce ourselves. 🤜