March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
Hi
I'm doing some tests with PBI Embedded and getting stuck on embedding a report/dataset that utilizes a dataflow as data source (import mode).
I have a PBI Embedded workspace (SKU A1) which contains a report with a dataset that gets data directly from an SQL server (import mode).
Using the sample app provided from Microsofts github I run the following code:
private static bool useEmbedToken = true;
private static bool useRLS = true;
public static async Task<ReportEmbedConfig> GetEmbedParams(Guid workspaceId, Guid reportId, [Optional] Guid additionalDatasetId)
{
using (var pbiClient = await GetPowerBiClient())
{
// Get report info
var pbiReport = pbiClient.Reports.GetReportInGroup(workspaceId, reportId);
/*
Check if dataset is present for the corresponding report
If no dataset is present then it is a RDL report
*/
bool isRDLReport = String.IsNullOrEmpty(pbiReport.DatasetId);
EmbedToken embedToken;
if (isRDLReport)
{
// Get Embed token for RDL Report
embedToken = await GetEmbedTokenForRDLReport(workspaceId, reportId);
}
else
{
// Create list of dataset
var datasetIds = new List<Guid>();
// Add dataset associated to the report
datasetIds.Add(Guid.Parse(pbiReport.DatasetId));
// Append additional dataset to the list to achieve dynamic binding later
if (additionalDatasetId != Guid.Empty)
{
datasetIds.Add(additionalDatasetId);
}
// Get Embed token multiple resources
if (useRLS)
{
embedToken = await GetEmbedToken();
}
else
{
embedToken = await GetEmbedToken(reportId, datasetIds, workspaceId);
}
}
// Add report data for embedding
var embedReports = new List<EmbedReport>() {
new EmbedReport
{
ReportId = pbiReport.Id, ReportName = pbiReport.Name, EmbedUrl = pbiReport.EmbedUrl
}
};
// Capture embed params
var embedParams = new ReportEmbedConfig
{
EmbedReports = embedReports,
EmbedToken = embedToken
};
return embedParams;
}
}
public static async Task<EmbedToken> GetEmbedToken()
{
EmbedToken embedToken = null;
try
{
using (var pbiClient = await GetPowerBiClient())
{
#region Embed Token
if (useEmbedToken && !useRLS)
{
// **** Without RLS ****
embedToken = pbiClient.Reports.GenerateTokenInGroup(ConfigValidatorService.WorkspaceId, ConfigValidatorService.ReportId,
new GenerateTokenRequest(accessLevel: "View", datasetId: ConfigValidatorService.DatasetId.ToString()));
}
else if (useEmbedToken && useRLS)
{
// **** With RLS ****
var rls = new EffectiveIdentity(username: "<emailAddress>", new List<string> { ConfigValidatorService.DatasetId.ToString() });
var rolesList = new List<string>();
rolesList.Add("<rlsRole>");
rls.Roles = rolesList;
embedToken = pbiClient.Reports.GenerateTokenInGroup(ConfigValidatorService.WorkspaceId, ConfigValidatorService.ReportId,
new GenerateTokenRequest(accessLevel: "View", datasetId: ConfigValidatorService.DatasetId.ToString(), rls));
}
return embedToken;
#endregion
}
}
catch (Exception ex)
{
embedToken = null;
return embedToken;
}
}
"if (useRLS)" in "GetEmbedParams" is evaluated as true and the "else if (useEmbedToken && useRLS)" block in "GetEmbedToken" is run. This works absolutely fine and the targeted report is shown in browser.
But if a change the reportId and datasetId to the one which uses the dataflow as data source, which is in the same workspace, I get the following error message in browser "PowerBI service client received error HTTP response. HttpStatus: 503. PowerBIErrorCode: OpenConnectionError".
I have tried using another "GetEmbedToken" method where I can send in multiple datasetIds and adding the dataflowId to this, but this is not accepted.
Can anyone provide some input as to where I'm going wrong, any setting I might be missing somewhere or any other tips?
Solved! Go to Solution.
Hi @rajendraongole1 , and sorry for the late reply (not enough hours in the day).
The solution in my case couldn't be found in any of the suggested posts.
However, the error was completely mine, as I hadn't set up the RLS in the correct manner for the dataset connected to the dataflow.
When doing that, and updating the rolesList.Add() method in the code, everything worked as it should.
But thanks a lot for trying to help.
Hi @MadBern85 - can you please refer the solved threads
Solved: Issue adding "PowerBI" (dataflow) source to an ent... - Microsoft Fabric Community
Solved: Power BI Dataflow -- Error when adding to gateway - Microsoft Fabric Community
Re: Power BI Embedded: OpenConnectionError - Microsoft Fabric Community
Troubleshooting dataflow issues - connection to the data source - Power Query | Microsoft Learn
Proud to be a Super User! | |
Hi @rajendraongole1 , and sorry for the late reply (not enough hours in the day).
The solution in my case couldn't be found in any of the suggested posts.
However, the error was completely mine, as I hadn't set up the RLS in the correct manner for the dataset connected to the dataflow.
When doing that, and updating the rolesList.Add() method in the code, everything worked as it should.
But thanks a lot for trying to help.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
21 | |
11 | |
10 | |
9 |
User | Count |
---|---|
48 | |
30 | |
18 | |
17 | |
15 |