We have all done embedded power bi on a web page which is the most widely used mode of exposing the dashboards or reports to the end users. With windows 10 improving there has been increase in the usage of apps as well. So there has been an increase in the requests coming from end users to have it as an app instead of typing an URL. So the way some teams have done this was have a webpage in which the power bi is embedded, then they call this inside UWP because Microsoft did not have a native control on the app which allowed you to add the power bi reports. Well that is an uncessary overhead in the case where the clients are looking only for an app especially in the case of remote site operations. To overcome this Microsoft have released a control in Graph UI .
How to do this?
Well it is a very simple process and requires hardly 30 minutes to get this up and running on a dev environment by following the below steps -
1) Have a Power BI pro account else you need an Azure Active Directory and a master user
2) Fill the onboarding document.
This requires your step 1 details.
Then enter a name for your application and click on select all. This step is basically to provide the app access to the api which it needs and click on Register.
How to do this?
Well it is a very simple process and requires hardly 30 minutes to get this up and running on a dev environment by following the below steps -
1) Have a Power BI pro account else you need an Azure Active Directory and a master user
2) Fill the onboarding document.
This requires your step 1 details.
Then enter a name for your application and click on select all. This step is basically to provide the app access to the api which it needs and click on Register.
Please copy the application ID which you will obtain after this step.
Create a workspace.
Import a power bi report which you want to embed in the UWP app, if do not have a power bi dashboard then import a Sample Power BI report.
Last step will be to grant permisson which can be done by clicking on 'Grant Permission' button.
Once you do this copy the details as shown in the image below.
3) Creating UWP App -
Now to create your application, download the visual studio community edition 2019
Once you have it installed, create a new uwp project
Enter the project name and click on Create.
Then VS will ask you to choose target version and minimum version for the app, you can leave it as default and click on OK.
Once it is done you should be able to see the project structure as shown in the image below.
you will not have the graph ui controls by default, to add this go to 'References' and do a right click and click on 'Manage NuGet Packages' as shown in the image below.
Search for 'Microsoft.Toolkit.Uwp.UI.Controls' in the browse window and click on install.
Now if you browse the toolbox you should be able to see the Graph UI control and also see Power BI embedded.
Click on MainPage.xaml and you should be able to see a sample screen. You should be able to see the xaml code,
Add the reference of graph UI into this by adding the below code -
Add the below code with the App ID and GroupID (WorkspaceID) which was obtained in the above step.
Your final code should like below -
Once it is done, you can click on Run button and the app will load in debug mode and you should be able to see the app as below.
You will be shown a login page, enter your credentials and then it should load the sample app / report which would have been added based on the selection done while registering.
There can possible blocking points which can be -
1) If you have not enabled developer settings on your system -
In this case, search for Developer settings in the start and click on Developer Mode. Once it is done it should install and enable the mode, if it requires admin privileges the request the concerned team to enable it for you.
2) If you have an exception stating debugger is not attached, then change the debug environment to 64 bit and it should start working for you as shown in the image below.
before -
after -
Else right click on the project and go to the debug option and change Debugger type to Mixed mode.
As you can see it is pretty easy and can be used in lot of cases along with your UWP app. Hope it was informative, do let me know if you have any questions on the same.
I think there is a need to provide some more information about Power BI and its power to solve complex IT problems.
ReplyDeletePowerbi Read Rest