Admin

Rashesh Chothani

Experienced Software Engineer with a demonstrated history of working in the information technology and services industry. Skilled in SQL, Web Applications, C#, jQuery, Javascript. Strong engineering professional with a Bachelor's degree focused in Computer Software Engineering from veerayatan group of institution. 

Posts by Rashesh Chothani

POWER BI Report Integration
Aug 04, 2020

Here we will see how we can access Power BI Embed reports and Dashboards in ASP.NET MVC applications. Let’s start with a small introduction to Power BI. Power BI is a reporting tool provided by Microsoft. It is accessible in two forms windows version and web version. Using windows version, we can design reports and then publish it to the Power BI server and Web version Power BI can be used to view that Published report. Power BI server URL: https://powerbi.microsoft.com/en-us/   Prerequisite to Start with Power BI: Visual Studio 2017 (https://visualstudio.microsoft.com/vs/older-downloads/) Power BI Desktop (https://powerbi.microsoft.com/en-us/downloads/) Azure subscription to register the application. (http://portal.azure.com/) Please follow the below steps to set up the Environment before starting with integration. Create an Active Directory on AZURE portal Register Application on Azure Portal. Note: Copy these details to somewhere User Id, Password, ClientID, Client Secret Key Grant All Access Permissions to application. Later on, you can remove extra permissions as per requirement. Register on the Power BI server to host reports and create the workspace. Create one sample report and Deploy on the Workspace we create on power BI server We can access this report directly without any authorization with the help of the URL. In that case, there is no data security. That’s why we are using Power BI Embed, and this report will be loaded with the help of Embedded URL and We’ll use Authorization Token for Authentication.   Power Integration Steps Generate Bearer token for Authenticate your application with Azure Active Directory with help of User Id, Password, ClientID, Client Secret key of Azure portal. We are going to generate this with the help of Postman. This bearer token will be used to access all the APIs related to Power BI. I.E. Get Workspace list inside Active Directory, Get Workspace items list, etc. API URL for generating Bearer token: https://login.microsoftonline.com/common/oauth2/token    Now, we have Bearer Token. We’ll get Workspace (Groups) list with the help of that bearer token. Below API will provide Workspace Details. Like Workspace Name, id, IsReadOnly, etc. API URL:  https://api.powerbi.com/v1.0/myorg/groups/   Now we have bearer Token and group details. Based on these all details. We’ll get report details which we hosted for integration.  We have different API methods for fetch report details, which will be used to integrate with our application. It will provide report id, name, report type, Web URL, Embed URL, Dataset Id, etc. Web URL: It can be accessed without authentication, which is open for all. You can access reports by browsing the URL in the browser directly. Embed URL: It is Secure URL which we are going to use for secure integration purpose. API URL: https://api.powerbi.com/v1.0/myorg/groups/{GroupID}/reports   Now we have all the required details to access the Power BI report. But still, we cannot access the report. It will require an Authentication token for that specific report to access it.  So, we’ll generate a Token for it. API URL:   https://api.powerbi.com/v1.0/myorg/groups/{GroupID}/reports/{ReportId}/generatetoken     We’ll Use Embed URL and Report Authentication Token to integrate a report with Existing Application.   Create a sample MVC application Create All the API methods as explained in step 1 to 4 Add below code in the controller   Add the below code in the view. Now, Run the project it will display sample reports in a web browser. Conclusion: After reading the blog, We have learned about Power BI API and the integration of those APIs into ASP.NET MVC application.