Skip to main content
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started


[SimplePBI][Python] Copy reports (pbix) between workspaces

In order to perform this action with code, we will draw from the SimplePBI Library built by LaDataWeb, but before diving into the code, let's explain how it works.

As of today, the API query catalog does not provide a method that allows us to copy .pbix files, but we do have other methods that will help us achieve this result. To do this, the following permissions will be necessary:

Report.ReadWrite.All and Dataset.ReadWrite.All

The first step will be to determine the environment in which to write our code to copy the reports. I recommend using a cloud environment such as an AzureVM, Azure Function, Automation Runbook, etc. Let's see why it's necessary and recommended to be in the cloud.


As we can see, since there is no native request for this, the way to do it will be by exporting and then re-importing the .pbix file. If our environment is local, we will have to download and upload it again, which can take quite some time depending on the file size. If we use a cloud environment, we can significantly reduce the time spent adjusting to local bandwidth.

Our library will contain the necessary method under the "Reports" category. Execution is quite straightforward. First, we import the necessary packages:



from simplepbi import token
from simplepbi import reports



We initialize objects by category to perform actions more comfortably:



t = token.Token(tenant_id, power_bi_client_id, power_bi_username, power_bi_password, None, use_service_principal=False)
r = reports.Reports(t.token)



NOTE: Remember that we can create our token by authenticating with a service principal if we locate the secret where we see the None and change the last argument to use_service_principal=True.


Once all that is created, we simply call the method with our desired values:



r.simple_copy_reports_between_groups(workspace_id_origin, report_id, workspace_id_destination, displayName=None, nameConflict="CreateOrOverwrite")



The arguments are:

  • workspace_id_origin: ID of the source workspace.
  • report_id: ID of the source report to export and import.
  • workspace_id_destination: ID of the destination workspace.
  • displayName: desired name for the destination, if we want to change the name. By default, None will give it the same name as it had in the source.
  • nameConflict: action in case of encountering the same name, by default it will create or overwrite.

Restrictions: This method only allows copying of reports that contain the dataset (less than 1Gb). It does not work with Live Connection.

With that simple line, we will have succeeded in making the copy of the report. This could help us generate our own deployment between different development environments of workspaces. I hope you find it useful and enjoy it. Follow SimplePBI for more useful methods built with API requests. Who knows, maybe one day we'll have one for copying between different tenants.


Original post from LaDataWeb