Integrating Power BI into Azure Web App

 In Technology

Power BI is a great data visualisation tool, which makes it easy to get insights from the raw data. The new functionality from Microsoft to integrate power bi into a web app makes it even more useful. In this blog I will show you how to embedded Power BI report into an Azure Web app.

How is embedding Power BI into web app useful?

  • Gives you one point solution: If you are a decision maker of a company then you like to have a integrated view of your sales, marketing campaing, your expenses etc, Power BI does the same and with its embedding feature gets that onto your own website.
  • Convinient for your clients : Since Power BI has row level security feature, you can share the reports of respective clients on your website without rendering to any third party solution.

What all is needed?

  • You need a Azure Subscription
  • Power BI desktop application
  • Power BI service account
  • Visual Studio
  • I assume that the Power BI Report is ready and is published to the Power BI Service account from your Power BI Desktop.

Following are the steps to Embed Power BI Reports:

  • Register your app
    • This step creates client ID and client secret for the API you select
    • Go to dev.powerbi.com/apps, sign-in with your Power BI service account. After successful login your name will appear on the screen, for me it shows “Swapnil Jadhav” in the below image. In Step 2 box fill in the details of your app as shown in below image.
    • App Name : should be relevant to your app, for ex mine is a survey app.
    • App Type : server-side Web app since its a web application.
    • RedirectURL : it is the page which is rendered after authentication, I have set the page on which my power bi report will be embedded.
    • Home Page URL : this is the home page of your app.
    • In step 3 set the access level, for example I want to embed reports, so I will select “Read all Reports” check box.
    • Click on Register App to generate the Client ID and Client Secret. Keep a record of the ID and Secret and do not share it with anyone else.
  • Open your application in visual Studio
    • I have created a azure web app with local url : https://localhost:44563, I will open this app into visual studio.
    • As shown below you need to insert the xml code in the Web.config, under applicationSetting tag.
    • Instead of SurveyApplication mention the name of your application.
    • Change the RedirectUrl to the url of your application page which you have given in the above steps.
    • Mention the ClientID and ClientSecret you generated in the above steps and save the web.config file.
    • Microsoft has an demo application for Integrating Power BI, the code needed for the controller can be reffered from this project. Link to the project is given below:
      https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/User%20Owns%20Data/integrate-report-web-app
    • I have created a MVC app so the code for the view is as mentioned below. I have mentioned the view code since the code in the above project was not working for me.
    • You would need the three javascript files powerbi.js, powerbi.js.map and powerbi.min.js, these files can be copied from the microsoft demo app.
    • Once the project is ready you can run it and power bi report will be loaded.

Blog disclaimer:
This is a professional weblog, and we have invited experts to share their thoughts, expertise , perspectives and knowledge. The opinions expressed here are purely representing their personal views and not those of any institution, employer or company.

Recent Posts

Start typing and press Enter to search