In this article, we will explore how to migrate Power BI reports across workspaces using Power BI REST APIs. This tutorial is specifically targeted towards Power BI admins or DevOps teams who need to migrate dashboards between various environments without any manual intervention.
Creating the Power BI Report
First, let’s create a sample report in Power BI Desktop and then deploy it to a workspace. For this tutorial, we will use the WideWorldImportersDW database provided by Microsoft. Download and install the tutorial from the official Microsoft documentation.
Open Power BI Desktop and click on “Get Data” and select “SQL Server” from the drop-down menu. Select the tables from the WideWorldImportersDW database and click on “Load” to load the data into the data model.
Drag and drop the required fields into the canvas to create the report. Once the report is created, click on the “Publish” button on the Power BI Desktop window.
Select the desired workspace to publish the report. Once the publish is successful, you can verify the report in the Power BI service.
Migrating the Power BI Report
Now, let’s migrate the Power BI report from one workspace to another using Power BI REST APIs. We will use a PowerShell script provided by Microsoft for this purpose.
First, obtain a ClientID for your Power BI account by visiting the Power BI Apps page. Save the ClientID in a secure place as we will need it later.
Download the “copyWorkspace.ps1” PowerShell script from the official Azure Samples GitHub repository. Update the ClientID in the script and execute it using Visual Studio Code or PowerShell ISE.
Authenticate your Power BI service account and provide the name of the source workspace from where you want to copy the report. Then, specify the name of the destination workspace where you want to migrate the report.
The PowerShell script will connect to the Power BI service account, export the files from the source workspace to a local directory, create the destination workspace, and upload the files to the new workspace.
Once the migration is completed, you can verify the migrated report in the Power BI service.
Conclusion
In this article, we have learned how to create Power BI reports using Power BI Desktop and publish them to a workspace. We have also explored how to migrate reports across workspaces using Power BI REST APIs. This knowledge will be valuable for Power BI administrators and DevOps teams who need to manage and migrate reports across different environments within the Power BI service.