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 typically used by enterprises and large organizations, and is intended for internal users.

Important

If you are embedding content for a national/regional cloud, the first few steps of this tutorial are different. See Embed content for national/regional clouds for details.

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 allow the end user to view any Power BI dashboard, report or tile they have access to in the Power BI service. The React TypeScript sample lets you embed only one report that your end user already has access to in the 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 following Power BI and code dependencies:


Method

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

  1. Register a Microsoft Entra 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 a Microsoft Entra application

Registering your application with Microsoft Entra ID allows you to establish an identity for your app.

To register your application with Microsoft Entra ID, 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 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
Client secret
Workspace ID
Report ID

Client ID

Tip

Applies to: .NET Core .NET Framework 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 Microsoft Entra app you're using for embedding your Power BI content.

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

Client secret

Tip

Applies to: .NET Core .NET Framework 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 Microsoft Entra app you're 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: .NET Core .NET Framework 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: .NET Core .NET Framework 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. Open one of the following folders depending on the language you want your application to use:

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

    Note

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

Configure your Microsoft Entra app

  1. Sign into the Azure portal.

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

  3. Open the Microsoft Entra application you created in Step 1 - Register a Microsoft Entra 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, choose Web.

  2. Save your changes.

Screenshot of the Azure portal window, which shows the app authentication configurations and the web redirect URI 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 Microsoft Entra 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.

Develop your application

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

Update user permissions

Users need permission to access the Power BI folder the report is in. When you grant a user permission to access a folder, the change usually takes effect only after the user logs in to the Power BI Portal. For the new permissions to take effect immediately, in the Embedded scenario, make an explicit call to the RefreshUser Permissions REST API at startup. This API call will refresh the permissions and avoid authorization failures for users with newly granted permissions.