Integrate Power BI into Your Application: Part 3 – Embed Content



In the part 1, you learned how to register an application to be able to interact with Power BI service and Azure environment. In the part 2, you learned how the authentication process works and how you can get the access token. In this part, I’m going to explain what is the process of embedding content (Dashboard, Report, and Tile) into a web page. you will learn about JavaScript part of it, and also the REST API section of it. if you like to learn more about Power BI; read Power BI book; from Rookie to Rock Star.

Step 1: Register your Application

Step 2: Authenticate

Step 3: Embed Content

in this step you will learn about codes and the method to embed the content into your application after registration and authentication of the application.

Sample Code

The sample code for this example can be downloaded from here.

Power BI Client Object

Power BI Client object is the main object needs to be created in order to interact with Power BI Service. As you’ve learned above, you need to have the access token for this step. You just need to parameters to create a Power BI Client object; ApiURL (which is static), and token (which is gained through authentication process mentioned in previous post).

After creating this object, you have access to massive amount of information from Power BI Service, and you can implement many actions through it (Which I explain many of these actions in other posts).

Get List of Reports

For this example; I’m going to Embed a report into web page, so I will get list of reports first (you can even directly mention the report Id).

As you can see the function used is GetReportsInGroupAsync. This function simply returns all reports under a group. Group Id is specified in web.config file. Notice that Id is not name of the group. the name that you see for group, dashboard, report, and data set, are just display labels. Each object in Power BI has an ID which is a unique identifier (GUID). you can easily find it when you browse the group in Power BI Service through URL;


These Ids can then be used for Power BI REST API functions.

Function above will return first report on that list, because I’ve used FirstOrDefault() function. You can easily mention any other reports if you want to.

Creating Embed Content

In the MVC application the next step is to create the embed content and push it to the view. lines below generating the embed content;

JAVA Script in the Web page

In the EmbedReport.Chtml page which is view web page, you need a JavaScript section to embed the content into the page. here is the JavaScript code;

As you can see in the above section; Embed Token is required for embedding part again, plus embed content coming from the controller.

Testing Application

If you run the sample application, you can check and see how embedding Report in application works perfectly;


As you can see, the report is integrated into my application which is running on my localhost. This method of embedding works with any type of report, sourced from any data source with any connection type.

Getting List of Dashboards

There is a function that returns list of dashboards for you, and you can easily select dashboards  you want.

GetDashboardsInGroupAsync, or GetDashboardAsync and many methods as listed below can give you information about dashboards;


After fetching list of dashboards it can then be passed to view with script below;

Embed Dashboard

Finally embedding dashboard is similar to embedding report, with slight difference;

so as a result this is the embedded dashboard;


Getting Tiles

You first need to have the dashboard object in order to get tiles under it.


As you can see above there are some functions that fetch Tiles from Dashboard and group. Code below will fetch first tile in a dashboard and pass it to the view page.

Embedding Content Limitless

Very important consideration of the new REST API way of integrating Power BI content is that, now you can embed any type of content: Dashboard, Report, and Tile. Your data set can be connected to any data set, online or on-premises, import data or DirectQuery. With this method of integration, you can integrate anything that you have in Power BI account easily into your application. I will explain another post later about FAQs of such integration plan. Stay tuned for next blog posts from this series.

Reza Rad on FacebookReza Rad on LinkedinReza Rad on TwitterReza Rad on Youtube
Reza Rad
Trainer, Consultant, Mentor
Reza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering; he has more than 20 years’ experience in data analysis, BI, databases, programming, and development mostly on Microsoft technologies. He is a Microsoft Data Platform MVP for nine continuous years (from 2011 till now) for his dedication in Microsoft BI. Reza is an active blogger and co-founder of RADACAD. Reza is also co-founder and co-organizer of Difinity conference in New Zealand.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog:
He wrote some books on MS SQL BI and also is writing some others, He was also an active member on online technical forums such as MSDN and Experts-Exchange, and was a moderator of MSDN SQL Server forums, and is an MCP, MCSE, and MCITP of BI. He is the leader of the New Zealand Business Intelligence users group. He is also the author of very popular book Power BI from Rookie to Rock Star, which is free with more than 1700 pages of content and the Power BI Pro Architecture published by Apress.
He is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL user groups. And He is a Microsoft Certified Trainer.
Reza’s passion is to help you find the best data solution, he is Data enthusiast.

10 thoughts on “Integrate Power BI into Your Application: Part 3 – Embed Content

    • This should be a group not from Shared with me. the link you have here is from “Shared With Me” section. group basically is under Work Spaces. just click on the work space, and you will be able to see Group GUID in the url of that page.

      • Hi Reza,
        Thanks for your reply. I am at the exact same page as per your screenshot. I am using my own account/works space. All the dashboard, reports and data sets are all mine as I am not a pro user,therefore nothing is shared with me. But yet i dont see the groupID


        • Hi Tim.
          You need to have Pro user to be able to create work spaces. it should not be “My work space”. it should be a new created work space.

  • I followed your instructions and everything seems to be displaying properly, however when I click on a tile in my dashboard to get to the report below it nothing happens.
    Clicking on a tile to a report seems to do nothing.

    Any suggesstions as to why that is?


    • clicking on dashboard and navigating to report is a functionality of Power BI Service. When you embed that into your application, you won’t have such functionality. clicking on dashboard tiles in web app won’t navigate to reports. however you will have some “click” events which you can program on those to navigate to another page in your web app that brings the report.

  • Hi Reza, Nice blog. Does the embed token always need to be generated server side? Is there JavaScript equivalent API where I can get the token without writing anything server side?

    • Hi Unnie,
      Yes, Embed token needs to be created server side through a controller, then after authentication the JScript API can be used for embedding.

  • Hi Reza,
    we have a Power BI report in an app workspace.
    our developer plan to embed a report from the app workspace into the application.
    what should I provide to developers?

Leave a Reply

%d bloggers like this: