Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello - I have a Power BI report (.pbix file) that uses a live connection to a semantic model that is published within a workspace in Power BI Service.
The report is developed within the Dev environment and connected to the semantic model within the Dev environment.
My issue is that when trying to publish this report through environments (dev,test,demo and prod) and rebind the report to the environment specific dataset the publishing fails before I get the chance to rebind due to the live connection in the pbix file is referencing the Dev semantic model which is not available in the higher environments.
I have tried multiple ways to get it works through Powershell, YAML etc and all fail. The only way I have got this working is by duplicating the report for each environment and ensuring the connection is firstly made to the correct environment which is far from ideal having to now maintain the same report per environment.
Has anyone encountered this issue and found a resolution to this?
Solved! Go to Solution.
Hi @JSkyrm
The issue you're facing, where your Power BI report fails to publish across environments due to a live connection tied to the Dev semantic model, is a common challenge when managing Power BI reports in multiple environments (Dev, Test, Demo, Prod). Since the live connection is hardcoded to reference the Dev semantic model, Power BI Service cannot find the model in the higher environments, causing the publishing process to fail. The key to resolving this issue lies in dynamically adjusting the report's dataset connections to point to the appropriate environment-specific semantic model. One approach is to parameterize the dataset connection in Power BI Desktop, where you can create parameters for server names or dataset identifiers, and modify their values based on the environment. This allows you to use the same .pbix file across environments without needing to duplicate it for each one. Another solution is to use PowerShell scripts or the Power BI REST API to automate the publishing and re-binding process, where you can programmatically reconfigure the connection to the correct semantic model after the report is deployed. Power BI Deployment Pipelines can also help by automating the deployment of reports and datasets across environments, ensuring the report is connected to the correct model in each stage of the pipeline. Additionally, creating Template Apps can streamline deployment by allowing environment-specific configuration without manual duplication. By leveraging these methods, you can eliminate the need to manually manage multiple copies of the report and ensure that it always connects to the right dataset in each environment, reducing maintenance overhead and improving deployment consistency.
We had a similar issue. We had a report connected to a dataset using a live-connection. We needed to repoint the live connection at a dataset in a different workspace (we needed to move it to a different Premium Capacity workspace). The main reason we needed to do this, is so that we wouldnt change the report URL that everyone was already using.
What we wanted:
Workspace A (Report A) --------> Workspace 1 (Dataset A)
After change:
Workspace A (Report A) --------> Workspace 2 (Dataset A')
Here is everything we tried:
1. Directly updating the dataset using the "Transform Data" >> "Datasource settings".
This seemed to work locally, but when we published the report back to its workspace, it magically created 2 reports with the exact same name. The original report remained untouched.
2. Rebinding using PowerShell
The code I used is at the bottom of this post. This worked! Except for one major issue. The report was repointed at the new dataset in the new workspace, but when we downloaded the PBIX file, it still was pointed at the dataset in the original workspace. This would not work, as we still need to continue to build the pages in this report.
3. Using PBIP file (this is the solution)
a. We downloaded the file from PowerBi.com and opened the file in PowerBi Desktop and saved it as a PBIP file.
b. Closed PowerBi desktop and in the folder where we saved the PBIP file, within the "xxxxx.Report" subfolder, we opened the "definintion.pbir" file and edited in NotePad. Specifically the "connection string" was updated:
Original pbir file:
{
"version": "4.0",
"datasetReference": {
"byConnection": {
"connectionString": "Data Source=\"powerbi://api.powerbi.com/v1.0/myorg/Workspace 1\";Initial Catalog=\"Dataset A\";Access Mode=readonly;Integrated Security=ClaimsToken",
"pbiServiceModelId": null,
"pbiModelVirtualServerName": "sobe_wowvirtualserver",
"pbiModelDatabaseName": "Dataset A's GUID",
"name": "EntityDataSource",
"connectionType": "pbiServiceXmlaStyleLive"
}
}
}
PBIR file after update:
{
"version": "4.0",
"datasetReference": {
"byConnection": {
"connectionString": "Data Source=\"powerbi://api.powerbi.com/v1.0/myorg/Workspace 2\";Initial Catalog=\"Dataset A'\";Access Mode=readonly;Integrated Security=ClaimsToken",
"pbiServiceModelId": null,
"pbiModelVirtualServerName": "sobe_wowvirtualserver",
"pbiModelDatabaseName": "Dataset (A')'s GUID",
"name": "EntityDataSource",
"connectionType": "pbiServiceXmlaStyleLive"
}
}
}
c. Opened the PBIP file in Desktop and saved the file as PBIX (this step is not really needed).
d. Published the report back to Workspace A. Voila, the original report was now repointed at Dataset A` in Workspace 2.
PowerShell script used to rebind report
#report details that needs to be rebound
$reportWorkspaceName = "Workspace 1"
$reportName = "Report 1"
#new dataset details that report needs to be bound to
$datasetWorkspaceName = "Workspace 2"
$datasetName = "Dataset A`"
function RebindReport{
param(
[string]$workspaceId,
[string]$reportId,
[string]$datasetIdToRebindTo
)
if ($workspaceId -eq $null -or $reportId -eq $null -or $datasetIdToRebindTo -eq $null)
{
throw "WorkspaceId, ReportId, and DatasetIdToRebindTo must be specified"
}
$ApiUrl = "https://api.powerbi.com/v1.0/myorg/groups/${workspaceId}/reports/${reportId}/Rebind"
$ApiRequestBody = "{'datasetId': '${datasetIdToRebindTo}'}"
$ApiRequestBody
$response = $null
try
{
Write-Host "Rebinding Report"
$response = Invoke-PowerBIRestMethod -Url $ApiUrl -Method Post -Body ($ApiRequestBody)
Write-Host "Rebind completed"
Write-Host "Complete"
}
catch
{
Write-Host "An error occurred:"
Write-Host $_
}
$response
}
$ErrorActionPreference = "Stop"
Login-PowerBI | Out-Null
#report info
$WorkspaceObject = (Get-PowerBIWorkspace -Name $reportWorkspaceName)
$PbiReportObject = (Get-PowerBIReport -Workspace $WorkspaceObject -Name $reportName)
$reportWorkspaceId = $WorkspaceObject.Id
$reportId = $PbiReportObject.Id
$oldDatasetForReport = $PbiReportObject.DatasetId
#dataset to rebind to info
Write-Host "Getting info for dataset ${datasetName} in ${datasetWorkspaceName}"
$datasetWorkspaceObject = (Get-PowerBIWorkspace -Name $datasetWorkspaceName)
#$PbiDatasetObject = (Get-PowerBIDataset -Workspace $datasetWorkspaceObject -Name $datasetName -Scope Individual)
$PbiDatasetObject = (Get-PowerBIDataset -Workspace $datasetWorkspaceObject) | Where-Object {$_.Name -eq $datasetName}
$PbiDatasetObject
$datasetWorkspaceId = $datasetWorkspaceObject.Id
$datasetId = $PbiDatasetObject.Id
Write-Host "Rebinding ReportId: ${reportId}"
Write-Host "in workspace ${reportWorkspaceId}"
Write-Host "from ${oldDatasetForReport}"
Write-Host "to ${datasetId} in ${datasetWorkspaceId}"
RebindReport -workspaceId $reportWorkspaceId -reportId $reportId -datasetIdToRebindTo $datasetId
$PbiReportObject = (Get-PowerBIReport -Workspace $WorkspaceObject -Name $reportName)
$PbiReportObject
Hi @JSkyrm
The issue you're facing, where your Power BI report fails to publish across environments due to a live connection tied to the Dev semantic model, is a common challenge when managing Power BI reports in multiple environments (Dev, Test, Demo, Prod). Since the live connection is hardcoded to reference the Dev semantic model, Power BI Service cannot find the model in the higher environments, causing the publishing process to fail. The key to resolving this issue lies in dynamically adjusting the report's dataset connections to point to the appropriate environment-specific semantic model. One approach is to parameterize the dataset connection in Power BI Desktop, where you can create parameters for server names or dataset identifiers, and modify their values based on the environment. This allows you to use the same .pbix file across environments without needing to duplicate it for each one. Another solution is to use PowerShell scripts or the Power BI REST API to automate the publishing and re-binding process, where you can programmatically reconfigure the connection to the correct semantic model after the report is deployed. Power BI Deployment Pipelines can also help by automating the deployment of reports and datasets across environments, ensuring the report is connected to the correct model in each stage of the pipeline. Additionally, creating Template Apps can streamline deployment by allowing environment-specific configuration without manual duplication. By leveraging these methods, you can eliminate the need to manually manage multiple copies of the report and ensure that it always connects to the right dataset in each environment, reducing maintenance overhead and improving deployment consistency.
Hi @JSkyrm,
Thank you for reaching out to the Microsoft Fabric Community Forum.
We really apologies for the inconvenience, after reviewing the issue of how to use Publishing a Live Connection PBI Report to different environments, here are few steps to may resolve the issue.
Implementing one or more of these strategies can enhance your workflow and ease the management of Power BI reports across various environments.
If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.
Thank you.
Hi @JSkyrm,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Hi @JSkyrm,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thankyou.
Hi @JSkyrm,
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.
@JSkyrm Thanks for getting back.
have you trier rebind api already?
if not its worth trying .
Use the Rebind Report API to connect the report to the correct semantic model in higher environment.
Power shell code :
$WorkspaceId = "insert target Workspace ID here"
$ReportId = "insert published Report ID here"
$TargetDatasetId = "insert environment-specific Dataset ID here"
$body = @"
{
"datasetId": "$TargetDatasetId"
}
"@
$RebindApiCall = "https://api.powerbi.com/v1.0/myorg/groups/$WorkspaceId/reports/$ReportId/Rebind"
Invoke-PowerBIRestMethod -Method POST -Url $RebindApiCall -Body $body
Hopefully by this approach you can publish your report to higher environments and rebind it to the correct semantic model, overcoming the limitation of the initial live connection referencing the Dev semantic model.
please give kudos and accept the solution if this is helpful
@nilendraFabric I have tried to implement a Rebind but the issue is that to do a Rebind the report first needs to exist / published to the PowerBI Service specific to the environment I am deploying to and I cannot firstly publish the report due to the issues I have stated above
@JSkyrm Understood the problem.
hopefully someone will help here. I will do further research as well.
thanks
Thank you for the reply but this does not work for myself as I am using a Live Connecton to a preexisting Semantic Model on the PBI Service and the Semantic Model is already successfully being deployed through the environments
Hello @JSkyrm
Please try Parameterize the Dataset Connection.
1. Open the report in Power BI Desktop
2. Go to “Edit Queries” > “Data source settings”
3. Create a parameter for the server name or workspace ID
4. Use this parameter in your connection string
This allows you to change the connection for different environments without modifying the report structure.
see if this works for you.
thanks
User | Count |
---|---|
47 | |
31 | |
28 | |
27 | |
26 |
User | Count |
---|---|
58 | |
55 | |
36 | |
33 | |
28 |