Forum Discussion
Is it possible to Embedded Powers BI Reports into a WinForms application?
- 10 years ago
Thank you!
Do you know some project example?
- 10 years ago
I know someone did it before but I am not aware of any samples,
I found that there is a winforms with power bi embedded sample in github.
I have not yet tried it, but here is the link:
P.S. for those who tries this out - please put some comments (or send me a message) about what was your experience with this sample (it seems I'll give it a try only after 3-4 weeks, and will put my comments here afterwards)
just wanted to say, that I succesfully managed to implement power bi embeded in winform project - so, now I can say it works :)
(with Azure AD authentication in multi-tenant mode, with tech account that has power bi free subscription. So if anyone needs some help - let me know, perhaps I can help)
- thmakhou9 years agoNew Member
Can i please have an example of wat is needed to view a power bi report from a vs 2015 c# winform application?
- prokurors9 years ago
Advocate III
Hi,
as you know there are changes going on, I have not yet migrated to the new Power BI service.
Not clear what have you tried so far. But there are 2 main options
a) if your report contains no sensitive data - then you can use iframe (and you can get it into winform using WebControl btw.)
https://powerbi.microsoft.com/en-us/guided-learning/powerbi-learning-6-6-publish-to-web/
b) if your report is contains business data, then you should go for power bi embedded (please note the following is changed due to recent changes to power bi, I have not done migration yet)
-in this case you should develop Power bi report, create workspace collection in Azure and upload your report there
-there is a power bi provision application available, that you can use to operate with power bi embedded Azure service (it's a console app and takes some time to get used to)
-in my case (it's working on the old mode, will try to update here after I will migrate to the new version, if I will do it at all... depends on the new pricing...)
This is a code to create embed token for Power BI report
One more thing regarding Provision application - after you upload you report, you have to update Connection string - you can do it using the same Provision application - there you have to enter your data source credentials
I hope this helps...
using Microsoft.PowerBI.Api.V1; using Microsoft.PowerBI.Api.V1.Models; using Microsoft.PowerBI.Security; using Microsoft.Rest; using System; using System.Collections.Generic; using System.Linq; namespace PowerBiReportingService.PowerBI { public class PowerReports : IDisposable { private const string APP_KEY = "sdlfjalkfjalsjdlfa..."; // you get it from Azure portal Power BI workspace collection -> Access keys private const string BASE_URL = "https://api.powerbi.com"; //this is the same for all private const string REPORT_COLLECTION = "CollectionName"; //as you named it in Azure portal private const string WORKSPACE_ID = "8v3a8713-...."; //this is what you get when you upload your report to power bi collection using Power BI report Provision console application - there you have option to get report Id private string ReportId; private string ReportUrl; private IList<Report> Reports { get; set; } public string AccessToken { get; set; } public PowerReports() { var credentials = new TokenCredentials(APP_KEY, "AppKey"); using (var client = new PowerBIClient(credentials)) { client.BaseUri = new Uri(BASE_URL); var reportsResponse = client.Reports.GetReports(REPORT_COLLECTION, WORKSPACE_ID); Reports = reportsResponse.Value; var report = Reports.FirstOrDefault(); if (report == null) throw new InvalidOperationException("Power BI analysis services not configured / or unexpected error!"); ReportId = report.Id; ReportUrl = report.EmbedUrl; } } public string GetEmbedReportUrl() { var embedToken = PowerBIToken.CreateReportEmbedToken(REPORT_COLLECTION, WORKSPACE_ID, ReportId); AccessToken = embedToken.Generate(APP_KEY); return ReportUrl; } public void Dispose() { Reports = null; AccessToken = string.Empty; } } }
- thmakhou9 years agoNew Member
can i have an example from the gentlman who got a power bi report to show from a winform application
i am using vs 2015, .net 4.5.1 and c# for a winform application.
i was able to download from nuget the powerbi security package
but the api failed to install
- prokurors9 years ago
Advocate III
Btw, here are two links regarding new way of embedding
https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding/
I see that it states that non-AAD users use embedded token to access power BI, but in my scenario (depends on how will new pricing mess resolve though) I would like to use AAD for authorization and embedded token for report access (so that I wouldn't have to buy/manage power bi pro licences for all of my apps users)
https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-migrate-from-powerbi-embedded/
- prokurors9 years ago
Advocate III
BTW, here is a tutorial I made some time ago
- MawashiKid9 years ago
Resolver II
RE: BTW, here is a tutorial I made some time ago
This is always good to know...
I have actually managed to run Power BI Embedded reports in a lot of scenarios ranging from
static HTML, Asp.Net MVC 5 Razor, Angular 4 Component to even Asp.Net Core 1.1 using custom
TagHelper. So I thought that logically...if any of these coding approaches supports iFrame then it should
allow me to embed Power BI Embedded reports. I said it should... For example, WPF has a WebBrowser
control though I found it a bit limited... At this stage in WPF, I could see the Power BI logo
'pumping' in a white screen but that was about it...All in all it's not just a matter of putting an iFrame in a page, we still need to provide a reusable
mechanism which will allow rendering iFrame in combination with proper provisioned
data [embedToken, enbedUrl, reportId,... ] in order to display the requested reports
or in some cases dashboards.In what I call the 'classic' Power BI Embedded - Workspace Collections - Workspace model 'topology',
you would need to first create a Workspace Collection on your Azure Portal account then get Access Key.
From there, you could either chose the C# Provisionsample console application. I use Visual Studio Code a lot,
so I prefer running the PowerBI-CLI interface in Powershell in Integrated Terminal panel.
Overall everything went pretty pretty straight forward and provision datas could be applicable in all cases.As you may already be aware, Microsoft Team has announced significant changes about Power BI Embedded convergence
with Power BI Service API. Therefore the 'classic' Power BI Embedded model may be no longer applicable after a while.
Microsoft Team said existing Power BI Embedded project would keep running though it is strongly suggested to start migrating...
I followed Adam Saxton [aka Guy in a Cube] video series and managed to get what I wanted through the integrate-dashboard-web-app [after registering my app...] We'll agree that the whole process is somehow a bit different...
For sake of testing simplicity I just reproduced the data in a mock data sample and managed to make it run. Nothing pretty fancy.
What would be interesting would be being able to hook the same 'integrate-dashboard-web-app' process in our own application or service.
If you have any ideas or comments, or suggestions, please be my guest...Regards
- fgreal6 years agoNew Member
Me podria indicar como llevo a cabo la integracion de powerbi con winforms
gracias