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.
  • Artie Roggeband

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

    • Kasper

      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.

  • Pingback: # Excel Super Links #62 – shared by David Hager | Excel For You()