Forum Discussion
PowerBIModelNotFoundException when publishing Power BI report to Azure Power BI
- 1 year ago
Hi Anonymous , Thank you for reaching out to the Microsoft Community Forum.
Yes, Power BI Deployment Pipelines can automatically rebind reports to the correct semantic models during deployments between Dev, Test and Prod, if the reports and datasets are included in the pipeline. You just need to configure dataset rules in the pipeline settings to map each report to the appropriate dataset in each stage. When those rules are in place, deploying from one stage to another will automatically rebind the report, no manual steps required. To fully automate this in your Azure DevOps pipeline, you can use the Power BI REST API to trigger deployments between pipeline stages.
Parameterizing live semantic model connections in PBIX files is not supported. When you connect a report to a Power BI dataset, that connection is hardcoded in the PBIX. You can't change it using parameters, environment variables or PowerShell before publishing. The only way to switch the dataset is after publishing, using the Rebind Report In Group API, which you're already doing correctly.
If this helped solve the issue, please consider marking it “Accept as Solution” and giving a ‘Kudos’ so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.
Hi Anonymous
Just checking to rule it out: Does the semantic model that the downloaded report is connected to still exist when executing New-PowerBIReport?
I tried to reproduce your error, and the only way I could produce an error (though a slightly different message) with New-PowerBIReport was to download the report PBIX, delete the semantic model that the report was connected to (after downloading) then execute New-PowerBIReport.
Would you consider using Copy-PowerBIReport which avoids downloading the PBIX and allows you to specify a target semantic model?
This script may also be a useful reference:
https://github.com/Microsoft/powerbi-powershell/blob/master/examples/CopyWorkspaceSampleScript.ps1
- Anonymous1 year agoNot applicable
Hi @OwenAuger ,
Thanks for replying to this thread.
Yes, the semantic model that the downloaded report is connected to still exists when executing New-PowerBIReport.Our scenario is as follows:
- Download a PBIX report via browser from one Azure Power BI workspace with the option to download "A copy of your report with a live connection to data online (.pbix)":
or create a new PBIX report using Power BI Desktop. In both cases, PBIX reports have relationships with a Semantic Model, so the reports don't contain a Semantic Model but use a live connection to data online.
- Add some updates in a PBIX report using Power BI Desktop.
- Push the updated PBIX report to Azure Repo which triggers Azure DevOps pipeline.
- The Azure DevOps pipeline uses a PowerShell script which is based on MicrosoftPowerBIMgmt.Reports module, specifically New-PowerBIReport cmdlet, to publish the updated PBIX report to a target Power BI Workspace.
However, we are getting "Response : Bad Request (400): {"error":{"code":"PowerBIModelNotFoundException","pbi.error":{"code":"PowerBIModelNotFoundException","parameters":{},"details":[],"exceptionCulprit":1}}}" error message while publishing the updated PBIX report that doesn't contain a Semantic Model but use a live connection to data online. It works fine if we publish a PBIX report that contains a Semantic Model, but we don't want to keep semantic models for each PBIX report. Our use case is to successfully publish a PBIX report without a semantic model using MicrosoftPowerBIMgmt.Reports module so that the PBIX report should be able to find and establish relationships with a semantic model that is already in a target Power BI workspace.
- Download a PBIX report via browser from one Azure Power BI workspace with the option to download "A copy of your report with a live connection to data online (.pbix)":