Forum Discussion
Overwrite report when copy/clone via powershell or API?
Hi Anonymous ,
I'd like to suggest you refer to following blog about use powershell and rest api to duplicate workspace:
Duplicate workspaces using the Power BI REST APIs: a step-by-step tutorial
Regards,
Xiaoxin Sheng
Thank you for the suggestion Xiaoxin. I have followed that guide, and can move datasets (or pbix with embedded datasets) around without duplicating.
My issue now is with .pbix files without embedded datasets (i.e. ones built when directly connected to a cloud dataset). I can import these with my previous code to the workspace of the associated dataset, however the code fails when uploading to a different workspace. If I try Cloning by first uploading to the initial workspace then cloning to the new workspace I get duplicates if the report already exists in the target space. The comments in section 4 (Cloning) of the referenced article seem to indicate that Cloning is the only way to move a report if the dataset exists, but that causes me issues. I don't think I should delete the report in the target workspace first as that might remove Dashboards and permissions?
Maybe I am going about this the wrong way or am missing something with the PowerBI service... How should reports flow through DEV/TEST/PROD in an enterprise environment? I envision having a dataset upon which many reports may be built (and then extended to Dashboards), and I'd like to have an automated process that "deploys" a report to PROD as opposed to manually using the desktop to repoint the dataset and republishing.
- Anonymous7 years agoNot applicable
Hi Anonymous ,
Maybe you can try to use template app to share your contents:
What are Power BI template apps?
Regards,
Xiaoxin Sheng
- Anonymous5 years agoNot applicable
Were you able to solve this efficiently?
I am facing the same issue.
The two options I am exploring are:
1. Use Copy-PowerBIReport and the find and delete the old report, but this negatively impacts references to the existing report
2. Use New-PowerBIReport with the "Overwrite" option. In this case, however, I have to find the reportId and then rebind it.
Thanks,
Chris
- mbutler714 years agoAdvocate I
Has anybody solved this?
I want the PBI Service to overwrite/update my report and not give me back a new Report Id everytime I deploy to a workspace(/environment).
I can use the "Import" REST API and/or the MicrosoftPowerBIMgmt New-PowerBIReport cmdlet to post an updated report, but both will give me a new Report Id for the report which will break all links and references to the original report of the same name.
- Anonymous4 years agoNot applicable
Hi mbutler71,
If you need more, let me know. I am running into a meeting this morning and kept this "short."
We have code that will find the report id "by name" dynamically, if you need it.
1. Copy pbix files from Drive to "Staging Area" workspace.
New-PowerBIReport -Path $fileToPublish -WorkspaceId $stagingGroupId -ConflictAction CreateOrOverwrite -VerboseCopying from the drive to Staging will keep the Same ID in place IF the dataset in Staging is the same as the dataset you use for development.
- We use a Golden Dataset that works for all workspaces.
- Publish the Golden Dataset to Staging
- Build reports that connect to the Staging Dataset in the Service
- Publish those reports to Staging with the above command.
2. Update Target report CONTENT from a report in Staging to the Target workspace
#Use UpdateReportContent API to copy content from Staging to Target workspace # Update "Update Report Content In Group" URL - POST https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/UpdateReportContent # Update "Update Report Content In Group" URL - POST https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/UpdateReportContent $updateReportUrl = "groups/$GroupId/reports/$reportIdToUpdate/UpdateReportContent" #Write-Output "$updateReportUrl" # The Dataset parameters to update $postParams = @{ sourceReport = @{ sourceReportId="$($reportIdFromStaging)" sourceWorkspaceId="$($stagingGroupId)" } sourceType = "ExistingReport" } | ConvertTo-Json Write-Output "$postParams" Invoke-PowerBIRestMethod -Url $updateReportUrl -Method Post -Body $postParams -ContentType $content -VerboseNOTES
The "UpdateReportContent" API will replace the report content and rebind to the target's data source AND keep the report ID in tact.