Tutorial: Embed Power BI content using a sample embed for your organization application

Power BI embedded analytics allows you to embed Power BI content such as reports, dashboards and tiles, into your application.

In this tutorial, you'll learn how to:

  • Set up your embedded environment.
  • Configure an embed for your organization (also known as user owns data) sample application.

To use your application, your users will need to sign in to Power BI.

The embed for your organization solution is usually used by enterprises and big organizations, and is intended for internal users.

Code sample specifications

This tutorial includes instructions for configuring an embed for your organization sample application in one of the following frameworks:

  • .NET Framework
  • .NET Core
  • React TypeScript

Note

The .NET Core and the .NET Framework samples will allow the end user to view any Power BI dashboard, report or tile they have access to in Power BI service. The React TypeScript sample lets you embed only one report that your end user already has access to on Power BI service.

The code samples support the following browsers:

  • Microsoft Edge
  • Google Chrome
  • Mozilla Firefox

Prerequisites

Before you start this tutorial, verify that you have both the Power BI and code dependencies listed below:


Method

To create an embed for your organization sample app, follow these steps:

  1. Register an Azure AD application.

  2. Create a Power BI workspace.

  3. Create and publish a Power BI report.

  4. Get the embedding parameter values.

  5. Embed your content.

Step 1 - Register an Azure AD application

Registering your application with Azure AD allows you to establish an identity for your app.

To register your application with Azure AD, follow the instructions in Register your application.

Step 2 - Create a Power BI workspace

Power BI keeps your reports, dashboards, and tiles in a workspace. To embed these items, you'll need to create them and upload them into a workspace.

Tip

If you already have a workspace, you can skip this step.

To create a workspace, do the following:

  1. Sign in to Power BI.

  2. Select Workspaces.

  3. Select Create a workspace.

  4. Name your workspace and select Save.

Step 3 - Create and publish a Power BI report

Your next step is to create a report and upload it to your workspace. You can create your own report using Power BI Desktop, and then publish it to your workspace. Or, you can upload a sample report to your workspace.

Tip

If you already have a workspace with a report, you can skip this step.

To download a sample report and publish it to your workspace, follow these steps:

  1. Open the GitHub Power BI Desktop samples folder.

  2. Select Code and then select Download zip.

    A screenshot showing the ZIP download option in the Power B I desktop samples GitHub

  3. Extract the downloaded ZIP and navigate to the Samples Reports folder.

  4. Select a report to embed, and publish it to your workspace.

Step 4 - Get the embedding parameter values

To embed your content, you'll need to obtain a few parameter values. The parameter values you'll need depend on the language of the sample application you want to use. The table below lists which parameter values are required for each sample.

Parameter .NET Core .NET Framework React TypeScript
Client ID Applies to. Applies to. Applies to.
Client secret Applies to. Applies to. Does not apply to.
Workspace ID Does not apply to. Does not apply to. Applies to.
Report ID Does not apply to. Does not apply to. Applies to.

Client ID

Tip

Applies to: Applies to..NET Core Applies to..NET Framework Applies to.React TypeScript

To get the client ID GUID (also know as application ID), follow these steps:

  1. Log into Microsoft Azure.

  2. Search for App registrations and select the App registrations link.

  3. Select the Azure AD app your using for embedding your Power BI content.

  4. From the Overview section, copy the Application (client) ID GUID.

Client secret

Tip

Applies to: Applies to..NET Core Applies to..NET Framework Does not apply to.React TypeScript

To get the client secret, follow these steps:

  1. Log into Microsoft Azure.

  2. Search for App registrations and select the App registrations link.

  3. Select the Azure AD app your using for embedding your Power BI content.

  4. Under Manage, select Certificates & secrets.

  5. Under Client secrets, select New client secret.

  6. In the Add a client secret pop-up window, provide a description for your application secret, select when the application secret expires, and select Add.

  7. From the Client secrets section, copy the string in the Value column of the newly created application secret. The client secret value is your client ID.

Note

Make sure you copy the client secret value when it first appears. After navigating away from this page, the client secret will be hidden and you'll not be able to retrieve its value.

Workspace ID

Tip

Applies to: Does not apply to..NET Core Does not apply to..NET Framework Applies to.React TypeScript

To get the workspace ID GUID, follow these steps:

  1. Sign in to Power BI service.

  2. Open the report you want to embed.

  3. Copy the GUID from the URL. The GUID is the number between /groups/ and /reports/.

    A screenshot showing workspace ID GUID in the Power B I service U R L

Report ID

Tip

Applies to: Does not apply to..NET Core Does not apply to..NET Framework Applies to.ReactTypeScript

To get the report ID GUID, follow these steps:

  1. Sign in to Power BI service.

  2. Open the report you want to embed.

  3. Copy the GUID from the URL. The GUID is the number between /reports/ and /ReportSection.

    A screenshot showing report ID GUID in the Power B I service U R L

Step 5 - Embed your content

The Power BI embedded sample application allows you to create an embed for your organization Power BI app.

Follow these steps to modify the embed for your organization sample application, to embed your Power BI report.

  1. Open the Power BI developer samples folder.

  2. Select Code and then select Download zip.

    A screenshot showing the ZIP download option in the Power B I developer samples GitHub

  3. Extract the downloaded ZIP and navigate to the PowerBI-Developer-Samples-master folder.

  1. Depending on the language you want your application to use, open one of these folders:

    • .NET Core
    • .NET Framework
    • React-TS

    Note

    The embed for your organization sample applications only support the frameworks listed above. The Java, Node JS and Python sample applications, only support the embed for your customers solution.

Configure your Azure AD app

  1. Sign into the Azure portal.

  2. Select App registrations. If you can't see this option, search for it.

  3. Open the Azure AD application you created in Step 1 - Register an Azure AD application.

  4. From the Manage menu, select Authentication.

  1. In Platform configurations, open your Web platform and in the Redirect URIs section, add https://localhost:5000/signin-oidc.

    Note

    If you don't have a Web platform, select Add a platform and in the Configure platforms window, select Web.

  2. Save your changes.

Screenshot showing the Azure AD app authentication configurations including the web redirect U R I for the .NET core app sample.

Configure the sample embedding app

  1. Open the Embed for your organization folder.

  2. Open the embed for your organization sample app using one of these methods:

  3. Open appsettings.json and fill in the following parameter values:

Run the sample app

  1. Run the project by selecting the appropriate option:

    • If you're using Visual Studio, select IIS Express (play).

    • If you're using Visual Studio Code, select Run > Start Debugging.

  1. Sign into the embedding sample application.

    Note

    During your first sign in, you'll be prompted to allow Azure AD permissions for the app.

  2. When the embedding sample application loads, select the Power BI content you want to embed and then select Embed.

    Screenshot showing the Power BI embedding sample app.

Developing your application

After configuring and running the embed for your customers sample application, you can start developing your own application.

Next steps