Over the last few months we’ve had the privilege of deploy numerous creative Power BI embedded solutions into custom apps for clients. It is a service that allows users to access Power BI cloud-based reports without the need for signing into the powerbi.com service to access the reports within that environment. 

Power BI Embedded Demo.

Let’s take a look at three ways of embedding Power BI report into an application:

Embedding Power BI

1 Publish to web

Publishing your report to the web from powerbi.com .
Here you can easily bring your report into the iframe of your application and you embed the report using the link generated by “publish to web” feature. This simple method uses a public report URL.

This approach doesn’t allow for viewing reports based on user’s permissions, neither to manage page/report level filters. Be aware, when you use Publish to Web, the report or visual you publish can be viewed by anyone on the Internet. There is no authentication used when viewing these reports. Only use Publish to Web with reports and data that the anyone on the Internet (unauthenticated members of the public) should be able to see.

Steps: go to powerbi.com >  Reports > open your report >  click on File > click Publish to web >create embed code > click Publish > copy your report URL and html iframe code

2016-10-22_20h25_06 2016-10-22_20h25_41 2016-10-22_20h26_10 2016-10-22_20h26_39

 

2 Using the Power BI REST API

In this case you’ll need to create a user account in the Power BI service and assign a Basic/Pro license to every user. Licensing requirements are absolutely same as for the Power BI service itself. Moreover, all users of the application must be authenticated using Azure AD. This approach requires setting up the back-end service to obtain authentication tokensPower BI REST API calls are made on behalf of an authenticated user by passing a token in the “Authorization” header that is acquired through Azure Active Directory

3 Power BI Embedded

Power BI Embedded is an Azure-hosted service which allows users to embed the reports into external applications. The most important advantage of Power BI Embedded is that users don’t need to have a Power BI service accounts and licenses to access Power BI reports via the application. This licensing model is described here:
https://azure.microsoft.com/en-us/documentation/articles/power-bi-embedded-what-is-power-bi-embedded/#licensing-for-microsoft-power-bi-embedded

To ensure the users will have access to the most updated information the Power BI model type must be “direct query” and the data source must be cloud-based (AzureSQL) at this time . When using “Direct Query”, no data is imported or copied into the data model.  As you interact with a visualization, Power BI Embedded queries the underlying data source, which means you’re always viewing current data. You can read more about Direct Query mode here:

https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-use-directquery/

Of course, you can use “Import data” mode as well, but you’ll need to manually refresh your data sets.

Security

There is no explicit requirement that your end users be customers of Azure Active Directory (Azure AD). Instead, your application expresses to Microsoft Power BI Embedded authorization to render a Power BI report by using Application Authentication Tokens (App Tokens).

In a previous post, I explain how to use Row level security (RLS). RLS can be used to restrict user access to particular data within a report or dataset and this allows for multiple users to use the same report while all seeing different data. Power BI Embedded now supports datasets configured with RLS.

demo
Requirements

You’ll need an Azure account/subscription and from the Power BI Embedded service  > Create Workspace collection > create workspace and then deploy your Power BI Desktop file from this workspace. Below is the flow diagram

flow

Like any other service in Azure, resources for Power BI Embedded are provisioned through the Azure ARM APIs. In this case, the resource that you provision is a Power BI Workspace Collection.


With Power BI Embedded we have three main steps:

Step 1: Developing the Power BI report in Power BI Desktop (Download the free tool here)
Once done developing the report set you will save the Power BI Desktop file (.pbix file)

Step 2: Configuring Azure Power BI and uploading/deploying the Power BI Desktop file.

First, create the Azure Power BI Embedded service and Workspace Collection.
Steps: Azure portal > click new > Intelligence+Analytics > Power BI Embedded > fill the require form as shown below > click create

azure

Once you have created the Power BI embedded service you can find this service in your resources:

service

Note: Take note of the Workspace Collection name , Resource Group and Access Key.

Now that we have created the Power BI Embedded service with Workspace CollectionNext, we have to create a Workspace and upload the Power BI Desktop file to this Workspace. For this, we need a console app which will connect to the Azure Power BI service and upload the file.

We run the console app and press 5  > follow the instructions (provide the Workspace Collection name, and Access Key).

console

After doing this we will have a new Workspace in our Workspace collection. Next we upload the .pbix file, press 6, and follow the steps in console app. Finally, we have created/configured the Power BI Embedded environment in Azure.

Step 3: Calling the deployed report.

The last step will be to consume the Power BI reports from Azure.
In our sample app we configure the web.config, in the EmbedSample web application and provide the Access key, Workspace Collection  and Workspace id. You can get all these from the Azure Power BI Embedded service.

config

Sample download https://github.com/Azure-Samples/powerbi-dotnet-server-aspnet-web-api

Some additional features you can add is RLS and refreshable report using an azure SQL Database as source for your Power BI report.

Want to get started on this:

power-bi-embedded-get-started-sample

Here is a example of embedding Power BI into a custom app using the Azure services:

Power BI Embedded Demo

This is a fantastic way to consolidate value into one place via a custom app and thereby negating the need to visit the Power BI service to view your reports.

Feel free to contact me if you would like to discuss how best to embed Power BI reports into your app environment.

For more great posts check out our blog page.