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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JSkyrm
Advocate I
Advocate I

Publishing a Live Connection PBI Report to different environments

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?

1 ACCEPTED SOLUTION
Poojara_D12
Super User
Super User

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.

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

View solution in original post

11 REPLIES 11
rockymtnrajah
Frequent Visitor

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

  

Poojara_D12
Super User
Super User

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.

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
v-kpoloju-msft
Community Support
Community Support

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.

 

  • In your Power BI report, create parameters that function as environment variables such as dev, test, and prod. Adjust the connection logic based on these parameters during the report loading phase. This typically requires modifying how the connections are established, possibly using M code to reference the appropriate dataset.
  • If you’re using power bi premium, consider using deployment pipelines. This feature allows you to create a streamlined publishing process from one environment to another and helps with the data source bindings as you move between environments. You can configure these pipelines to manage settings for each environment appropriately.
  • Use the Power BI REST API to automate the re binding of datasets after publishing. By scripting the re bind process, it can occur automatically once the report is in the appropriate workspace. Create custom scripts using power shell or other languages that detect the environment and adjust the data source accordingly post publish.
  • Centralize your semantic model to prevent duplication. Manage changes from a central point and link development branches to the same model, while using a configuration file to maintain environment specific settings.
  • While not ideal, you can manually adjust the data source connections after publishing if you can automate or simplify the bindings once the report is live.

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.

nilendraFabric
Community Champion
Community Champion

@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

JSkyrm
Advocate I
Advocate I

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

nilendraFabric
Community Champion
Community Champion

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

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.