I recently had the requirement to save the monthly Dataset of a Power BI Report. I remembered a blog post by Chris Webb on how to use Power Automate to access the Power BI Rest API. The following post describes how I use this to create a monthly PBIX backup.
Register an app for the Power BI APIs
In the first step, we have to register a new application that can access the Power BI APIs of our tenants. I will not describe the process in detail. Take a look at theMicrosoft documentation.
After clicking on “Create connector” the Redirect URL is displayed. Depending on your location, this URL may be different.
Add the Redirect URL to the previously registered Application. Sign in to the Azure portalhttps://portal.azure.com “Azure Active Directory” -> “App registrations” -> “Name of our app”. Under “Authentication”, replace the “Redirect URIs” with the URL from Power Automate.
Creation of the Power Automate Flow
Now we create the Power Automate Flow. First we determine the GUID of the workspace and the Power BI report that is to be archived. After opening the report, the values can be read from the address line.
For the monthly execution we choose a “Scheduled flow” in Power Automate.
Give the flow a name and set up the schedule.
In the flow, the Custom Connector can now be used with all Power BI API calls.
When you access for the first time, you must sign in and agree to the requested permissions.
You can then set up the following Power Automate Flow.
New Step: Export PBIX
Select the Custom Connector action“Exports the specified report from the specified workspace to a .pbix file.”and rename it “Export PBIX”.
groupId:GUID of the source workspace
reportId:GUID of the source report
New Step: Compose
Select the “Compose”action to convert the export body into the “multipart/form-data” structure required for the import.