1. What is Embedded Analytics?

2. Why should I care?

User adoption of centralised BI systems has and continues to be a persistent challenge. With only a fraction of users ever leveraging some form of analytical capability, the majority of users are left ill-informed with adoption rates stagnating between 15 - 25%. This kind of makes absolute sense when you think of the expectation that is placed on consumers in order to reap any reward.

Typical Example:

User X is in the middle of working with Bus App Y and would like to analyse some of the underlying data.

In order to do so, User X would need to stop what they are doing and switch over to a BI platform, usually via a centralised portal.

Once complete, switch back and resume working.

As you can appreciate, this is quite disruptive to the users flow, and herein lies the opportunity! Embedded analytics delivers insights directly to users, significantly increasing the likelihood of adoption while accelerating the users time to value.

3. What is Power BI Embedded?

Power BI Embedded enables ISVs and developers to integrate Power BI content (reports, dashboards and tiles) directly into an application.

You simply provision and pay for the dedicated capacity required to serve the content and meet peak usage demand.

Each individual consumer does not require a license.

There only needs to be a single "master" Power BI Pro account.

Note:

The Power BI Embedded offering is targeted at ISVs and developers (i.e. building apps for external users).

If you are looking to embed Power BI within the enterprise context (e.g. an internal portal, SharePoint, Microsoft Teams), the guidance from Microsoft is to look at Power BI Premium, as this SKU may be better suited when combined with existing internal usage of the Power BI service.

4. Power BI Embedded History

Not to dwell on the past but understanding Power BI Embedded's history to date may provide some needed clarity as the offering has evolved since its initial release.

With the above in mind...

Power BI Workspace Collections

You may still see this resource in the Azure marketplace or stumble across the term in Google, this is the legacy version of the Power BI Embedded offering prior to the API convergence that occurred in May 2017.

Power BI Workspace Collections are on the deprecation path and will be completely retired in June 2018.

The legacy pricing model was based on sessions (current model based on capacity).

Note: Power BI Embedded is billed hourly. If you pause the resource, you will not be charged.

Do I need Power BI Embedded capacity during Development / Testing?During development and testing, you do not need Power BI Embedded dedicated capacity (i.e. you could skip this step) as you are able to generate a limited number of embed tokens (we'll get to embed tokens later) without this resource being active. In terms of the number of embed tokens that can be generated before being exhausted, this (afaik) is undocumented. That said, generally speaking, you can live without Power BI Embedded dedicated capacity until you are ready to transition to Production. With Power BI Embedded capacity you are then free to generate unlimited embed tokens.

Once complete, you should see a diamond icon next to your App Workspace to indicate that it is backed by premium capacity.

Note: You will need to publish some content into your App Workspace (i.e. Dashboards, Reports). You can do this via Power BI Desktop otherwise clicking Get Data > Samples can quickly get you started.

Step 3. Get an Embed Token (Power BI API)

The diagram below illustrates the high-level interchange of requests. In this example I am using an Azure Function to do the bulk of the work, once authenticated it will invoke the Power BI API to construct a JSON response that will include an Embed Token. The Embed Token allows the client (Power BI JavaScript Library) to embed Power BI content. There are obviously a number of ways this could be done (e.g. back-end web server logic). Using Azure Functions keeps our complexity low and should be easy to follow along.

Azure Function App

Log on to the Azure portal.

Create a Function App.

Fill in the required property values.

App Name (e.g. pbieFunctionApp)

Subscription (valid Azure subscription)

Resource Group (e.g. PBIE)

OS (Windows)

Hosting Plan (Consumption Plan)

Location (e.g. West Central US)

Storage (Create New)

Application Insights (Off)

Click Create

Azure Function (Code)

Navigate to your Azure Function App.

Create a new C# HTTP triggered function (i.e. Webhook + API).

Navigate back to the Azure Function App (parent) and click Application Settings.

Add the following settings:

Name: PBIE_CLIENT_ID; Value: Azure AD > App Name > Application ID

Name: PBIE_GROUP_ID; Value: <Power BI Group ID> (see notes)

Name: PBIE_REPORT_ID; Value: <Power BI Report ID> (see notes)

Name: PBIE_USERNAME; Value: Your Power BI Pro Account Username

Name: PBIE_PASSWORD; Value: Your Power BI Pro Account Password

Click Save

Navigate back to the Azure Function.

Add a new file called project.json

Copy and paste the JSON code from below into the file and click Save.

Open run.csx.

Copy and paste the C# code from run.csx below and click Save.

Note: The easiest way to get the Group ID and Report ID is directly from PowerBI.com. Simply open a report from your App Workspace that you intend on embedding and you can see the values in the URL (e.g. https://powerbi.com/groups/<Group ID>/reports/<Report ID>/ReportSection). These values can also be attained programmatically but to keep this demo as simple as possible, we are going to supply them directly.

That's it. To test your API, click on the </> Get Function URL link and navigate to it in your browser. The JSON response should look something like the below.

Note: You will notice that the HTML is referring to online hosted versions of the JavaScript library dependencies (jQuery & Power BI JS). This means we can get away with a single HTML document.

That's it! In this example I'm just running the HTML code from my local machine, if you wanted to go FULL SERVERLESS, you could upload the HTML document on to Blob storage and make the container public.