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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
glennbrodie
New Member

Issue with setting connection with embedded Power BI c#

We have muti tenant DB, with PowerBI Embedded - in order to run the report for each tenant, my uderstanding is we have to clone the report, then set the connection string. When we do this, the connection string does not change, but we receive no errors - see code below:

 

CloneReportRequest cloneReportRequest = new CloneReportRequest()

                                                                                  {

                                                                                                Name = $"{newReportName}-{Host}"

                                                                                  };

                                                                                  report = client.Reports.CloneReportInGroupAsync(groupID, report.Id, cloneReportRequest).Result;

 

                                                                                  var dsnArray = hostDataRepository.Get(Host).DSN.Split(':')[1].Split(';');

                                                                                  var datasource = dsnArray[0];

                                                                                  var initialCatalog = dsnArray[3].Split('=')[1];

 

                                                                                   ConnectionDetails connectionDetails = new ConnectionDetails()

                                                                                  {

                                                                                                ConnectionString = $"data source={datasource};initial catalog={initialCatalog}; persist security info=False"

                                                                                  };

 

                                                                                  var setConnections = client.Datasets.SetAllDatasetConnectionsInGroupAsync(groupID, report.DatasetId, connectionDetails).Result;

2 REPLIES 2
Eric_Zhang
Microsoft Employee
Microsoft Employee


@glennbrodie wrote:

We have muti tenant DB, with PowerBI Embedded - in order to run the report for each tenant, my uderstanding is we have to clone the report, then set the connection string. When we do this, the connection string does not change, but we receive no errors - see code below:

 

CloneReportRequest cloneReportRequest = new CloneReportRequest()

                                                                                  {

                                                                                                Name = $"{newReportName}-{Host}"

                                                                                  };

                                                                                  report = client.Reports.CloneReportInGroupAsync(groupID, report.Id, cloneReportRequest).Result;

 

                                                                                  var dsnArray = hostDataRepository.Get(Host).DSN.Split(':')[1].Split(';');

                                                                                  var datasource = dsnArray[0];

                                                                                  var initialCatalog = dsnArray[3].Split('=')[1];

 

                                                                                   ConnectionDetails connectionDetails = new ConnectionDetails()

                                                                                  {

                                                                                                ConnectionString = $"data source={datasource};initial catalog={initialCatalog}; persist security info=False"

                                                                                  };

 

                                                                                  var setConnections = client.Datasets.SetAllDatasetConnectionsInGroupAsync(groupID, report.DatasetId, connectionDetails).Result;


@glennbrodie

  1. How do you identify that the connection string is not changed, by calling the Get Datasources?
  2. It is only supported to change the connection strings of the datasets in DirectQuery mode, what is going on when calling the Set All Connections instead of the C# SDK in Postman?

So it appears the issue is more complicated - it turns out the data connection is changing but it apparently takes a bit of time to see. However, the issue is that when you clone the report, it uses the same data set that is in the original report for the resulting report. So when you change the data connection for the resulting report, you are changing it for all the reports that you copied for each tenant from the base report. This is not the desire result - we want to clone the report with a clone of the data set so that when we change the connection for the report it is unique to that report. The high level is that we are trying to create reports for every tenant (becuase we cant change the connection uniquely on the fly), and each tenant has their own Database. Is there a better approach to this problem? Right now we are stuck with manually copying every report and manually setting all the data set/connections - not a good solution at all.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.