Power BI is a self-service business analytics solution that continues to progress the data and analytics space. Allowing different user types the ability to create and collaborate on reports through visualizations, Power BI offers a quality enterprise reporting solution for your organization.
Power BI Embedded allows you to add Power BI visualizations and reports to custom applications and websites. In doing so, customers can access the data they need through fully interactive reports. With the Power BI Embedded API, embedding analytics is a breeze and can be done within an existing application. Once your application contains embedded visualizations, the API also includes endpoints allowing communication between Power BI content, and the data within your custom application. This opens an exciting approach to business intelligence in the form of actionable insights. Imagine being able to view reports and act on them all within the context of your existing organization’s application. Awesome!
To get started, you are required to have your own Azure Active Directory tenant, and a Power BI Pro account to use to publish some content. The setup explained will allow you to run Microsoft sample code hosted on their GitHub. This post also assumes you have a general familiarity with the Power BI architecture, and suggests you use Microsoft setup documentation for more in-depth information.
Supporting Documentation: https://docs.microsoft.com/en-us/power-bi/developer/embed-sample-for-customers
Step 1: Register Application in Azure Active Directory
The first step to getting Power BI Embedded up and running is registering your application with Azure Active Directory. Registering your application allows it access to the Power BI Rest APIs. Microsoft has provided developers with a handy App Registration Tool, but this step can also be done in the Azure Portal. Once the application is registered, ensure proper Power BI Service API permissions are allowed through ‘API Permissions’.
Supporting Documentation: https://docs.microsoft.com/en-us/power-bi/developer/register-app
Step 2: Prepare Your Content
Power BI Embedded requires creating a workspace within the Power BI Service. This workspace will contain reports and dashboards eligible for embedding. Simply login to the Power BI Service using your licensed Pro account and create a workspace for your content. Ensure you are a workspace admin, this will be needed for authentication later.
Next, open a report you wish to embed in Power BI Desktop (windows application) and publish it to the newly created workspace.
The Power BI Embedded API will invoke REST calls against the Power BI Service. Before doing so, an access token must be retrieved from Azure Active Directory by authenticating against the application registration. Once the token is available, the API can facilitate actions against reports within the provisioned workspace.
Step 3: Configure ASP.NET Web Application
The Microsoft code sample on display here is an ‘App Owns Data’ embedded solution. This approach leverages capacity-based licensing in which a Power BI master account is responsible for access to the desired content. For now, use your Power BI Pro account as our master account.
Open the solution in Visual Studio and locate the web.config file in the ‘App Owns Data’ solution.
Fill in the blank values with the proper configurations:
- applicationId – GUID value assigned to app registration, found in Azure Portal as the ‘Application (client) ID
- workspaceId – GUID value assigned to Power BI workspace. When in the workspace within the Power BI service, it is the first GUID in the URL
- reportId – GUID value assigned to Power BI report to embed. When in the report within the Power BI service, it is the second GUID in the URL
- pbiUsername – Username associated with Power BI Pro account
- pbiPassword – Password associated with Power BI Pro account
Its time to run the application. If the configurations are set up properly, the application will display the published report within an ASP.NET MVC web application.
Step 4: Enhancements
Explore the sample code and the API calls used for embedded solutions. Now is the time to get creative! Power BI Embedded offers exciting opportunities to brand Power BI content to fit the style of your custom application. Leverage the API further to enable interactions between embedded reports and custom application content. Potentially add the ability to create Power BI reports inside your application. There are a bunch of interesting ways to expose Power BI to end-users with embedding.
Once your solution is production-ready, you will want to migrate the solution from authenticating against a master account to a service principal. With service principal, you can embed Power BI content using an app-only token. You will also need to determine the Power BI capacity the application will require and select an embedded licensing SKU based on your requirements.
For more information or additional help with Power BI Embedded, check out our AppSource offering.