Embedding Power BI Reports with Power BI Report Server

A common question I get is what will we will be able to do around embedding Power BI reports with Power BI report server. To understand this it is important to look at how the Power BI reports are being integrated into SSRS.

The Power BI reports are really a new type of reports supported by Reporting services. In SQL Server 2016 we added support for mobile reports and now with Power BI Report Server we add support for Power BI reports. This means that the reports will be using the traditional reporting services framework and “content management” system which means it’s existing folder structure including all it’s security features but also it’s existing embedding framework. Now SSRS has several ways to do embedding, one is using the reportviewer control and the other is through iframe embedding. The report viewer control only works for RDL files, not for the mobile reports nor for the Power BI reports, that leaves us with the traditional IFrame embedding.  Let’s take a look at this works.

To try this I started by creating a sample report and upload it to Power BI report server:

image

This I can open and see as part of my Report Server:

image

Now let’s say I want to embed this into a regular ASP.NET application. I start by creating a blank ASP.NET web app in Visual Studio and remove all the content from my Default.ASPX  within the asp:Content tags and replace it with an asp.net Iframe, leaving my page to look like this:

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<IFRAME id="frame1" scrolling="auto" runat="server" width="1000px;" height="600px">
</IFRAME>
</asp:Content>

Now in my code behind I want to load my report:

protected void Page_Load(object sender, EventArgs e)
{
frame1.Src = "http://kadejosb/Reports/powerbi/PBItest/pbitest";
}

Running this will compile and run but will not show anything:

image

The trick here is to add the following parameter to the URL: “?rs:Embed=true” as described here in the SSRS team blog. This will generate an embedding-optimized view of the report.

Now the code looks like this:

protected void Page_Load(object sender, EventArgs e)
{
frame1.Src = "http://kadejosb/Reports/powerbi/PBItest/pbitest?rs:Embed=true";
}

Now running this again give us what we want:

image

And that is it, of course this can be used in a customer application or when you want to embed into SharePoint.

A few interesting things to note here are:

  1. There are currently no ways to add parameters to the connection string, I talked to the team and this is definitely on the road map.
  2. The user who is connecting to your custom app also needs to have access to the Power BI report on the report server, this is great for internal applications but harder for extranet scenario’s. A solution to this is also on the road map.

16 Replies to “Embedding Power BI Reports with Power BI Report Server

  1. Thanks for working out this code. Even for internal apps, what is the “security” tolerance to using an iFrame still these days?

    1. not sure what the problem with IFrames are in this case compared to anything else? There are no “public” client side parameters that flow that could be intercepted. I don’t see the attack vector.

  2. Hi Kasper,

    Did you tried this with OnPrem SharePoint, cause if i am using Content Editor WebPart it does not working and just showing “Loading Data…” and not the report

        1. I’m also interested as using an iframe in on-prem SharePoint we can get the report to show but “Loading Data….” remains even after the report has finished loading. Does it regardless of whether the report contains imported or Live Connection data.

  3. Embedding reports from Power BI server into applications displaying role level access data will be great, is there a timeline on when this would be available.

  4. Hi Kasper,
    I am waiting with anticipation for the following features
    – ASP.NET Core 2.0 Power BI Report Viewer instead of iframe;
    – Passing parameters from ASP.NET Core 2.0 to PBI Report (Clients are SCREAMING for this)
    – User Toolbox for ASP.NET Core 2.0 Power BI Report Viewer for zooming, printing and exporting a WHOLE Report to Excel/PDF/Word etc.

  5. I also want to see mobile versions of my reports, when I opened iframed code in my mobile phone browser. But I see desktop versions only…
    Should I add some thing like mobile=true after rs:Embed=true.?

  6. Hi Kasper,

    Embedding Power BI Reports with Power BI Report Server -> can you use this iFrame also in another powerbi report in the reportserver? It doesn’t work the same way unfortunately if i try to do that.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.