Steps to embed your Power BI reports

There are three major steps in setting up Power BI Embedded for your Power BI Reports. These steps apply to embed your dashboards or Q&A

In this blog post we will be setting up Power BI Embedded for ISV or “App owns data” scenarios. The scenario where your users need not have Power BI License to view reports. You embed Power BI Reports in your custom application say, e-commerce site, or health app etc. for your end users.

Here are those three major steps to embed your reports.

Note: Some of the settings differ when you embed for US Gov clouds. Read our brand new post on settings when embedding for US Gov clouds here

1. Register application

2. Set up permissions in Azure Portal

3. Set up sample code to embed Power BI Reports

 

Step 1: Register application

Step by Step guide.

a. Go to https://dev.powerbi.com/apps and register your application. This step is required since Power BI Rest APIs or .NET SDK requires an “application” to connect to Power BI to get token for embedding.

This application is not your custom application (or portal) where the reports will be embedded.

b. Login with your Power BI Account. This is the account where you have Pro or Premium license assigned. This could be yours or a master account (non-human).

c. Add the following setup. You can put any Application Name, but Application Type should be “Native”

d. Select APIs to access. If you only want to “view” reports, select “Read all reports”, “Read all datasets”, and “Create content”. If you want to embed in edit mode, select “Read and write all datasets”, “Read and write all reports”, and “Create content”. We will/can change these in Azure Portal later.

Note: We have seen if you do not select “Create content” permissions, requests to Power BI APIs fail with 403 error.

e. Click on “Register” button. You will receive your client id (or application id as it is called in Azure Portal). Keep it handy

Step 2: Set up permissions in Azure Portal

Let’s log in to Azure Portal using our Power BI account (the account used to register application above).

a. Login to portal.azure.com

b. Navigate to the Azure Active Directory in the left panel and click on App Registrations. If you do not see your app you just created, select “All Apps” instead of “My Apps”

pbiazureappreg.PNG

c. Click on “PBIEmbedApp” and then on Settings and Required permissions

pbiazureclickpermissions.png

d. On the Required permissions, select Power BI Service. Here you can enable/disable any permissions. 

Click on “Save”.

pbiazurepbiservice.PNG

e. After saving you would see “3” delegated permissions for Power BI Service. While Power BI Service is selected, click on “Grant permissions”.

pbiazure3grant.PNG

This would grant permissions to your app.

pbiazuregrant.PNG

You are set to embed your reports now! You would need 3 things to embed your report in your application.

a. Your app’s client id (Remember I had asked you to keep that handy above). If you miss it no worries, go to Azure Portal and grab the “application Id” for your app under Azure Active Directory. This is nothing but your client id.

b. Power BI Report Group ID and Report ID. How do you find out your report’s group id and report id? Navigate to your Power BI report in Power BI portal. Copy the URL

pbiurl.png

Anything after “groups/” but before “/reports” shown above in red box is group_id, and anything after “reports/” but before the last “/” shown above in blue box is report_id. Copy them.

c. Your Power BI username and password. Usually in ISV or App owns data scenarios this is a master account. This means it can be a person’s account like you or me or any other account which nobody (or I must say “no human”) will use.

Step 3: Set up sample code to embed Power BI Reports

Download sample code from Microsoft’s GitHub repo. You will need to use “PowerBIEmbedded_AppOwnsData” project.

Github URL: https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/.NET%20Framework/Embed%20for%20your%20customers/PowerBIEmbedded_AppOwnsData

Go to web.config and update the following settings – applicationId, workspaceId, reportId, pbiUsername, pbiPassword.

pbicodesettings.PNG

Your client id is application id and group id is workspaceid.

Run the application in Visual Studio, and you will see your report embedded!

pbiembed.PNG

If you have any questions, feel free to comment on the blog post, or contact us.

Note: Some of the settings differ when you embed for US Gov clouds. Read our brand new post on settings when embedding for US Gov clouds here

One thought on “Steps to embed your Power BI reports

Leave a Reply