赛派号

无人机勘测地形有什么用 PowerBI embedded in Streamlit

All the code from this article can be found here: https://github.com/RodrigoPombo/streamlitPBIembed

Motivation

Streamlit is an open source Python framework where you can develop front-end applications all from the comfort of your preferred programming language - in this case Python, it also manages the complexity of spinning up and managing the web server - by default, it spins up a web server when you run the framework.

Streamlit has emerged in response to the specific need for data teams to make analytics or prescriptive data ailable to consumers quickly, affordably, and openly.

On the other hand, Power BI enables you to embed report contents into your web applications using tokens generated by its API. These tokens, along with an EmbedURL, are then utilized within your client logic and retrieved to your clients' browser, typically within an HTML iframe object

Power BI provides two main methods for embedding your content within your application:

Embed for your organization: Embed for your organization occurs when users needing access to the report are within your organization and can authenticate to Power BI using their own IDs. In this case whatever permissions your users he are going to be propagated when the REST API is called. Embed for your customers: Embed for your customers is perhaps the most commonly used scenario for Power BI embedding today. It is used when you want to share your report with users outside of your organization's tenant. In this case, users obviously won't be able to authenticate directly, so a service principal is used for authentication with Power BI. This authenticated service principal will then retrieve metadata from Power BI APIs, which will be used in the front-end.

Full details on the above approaches can be found in the following links: https://learn.microsoft.com/en-us/power-bi/guidance/powerbi-implementation-planning-usage-scenario-embed-for-your-organization

Recommended by LinkedIn Building a Basic MCP Server with Python Alex Merced 8 months ago JSON 101: The Language of Data in the Modern Web Marcel Broschk 8 months ago Getting Started with SQL and Python: What You Need to… Walter Shields 8 months ago

https://learn.microsoft.com/en-us/power-bi/guidance/powerbi-implementation-planning-usage-scenario-embed-for-your-customers

So here I am presenting a minimal example of a streamlit application which uses the "Embed for your customers" flow to retrieve a report from PBI:

The code can be basically divided into:

main.py - entry point for the streamlit application - it does not really contain too much content on our minimal example. Index.html - this contains all the html code required for the front end, including: HTML paragraphs that are going to be replaced dynamically by python, embedded jascript code that is making use of the public powerbi.embed function and that is used to retrieve the contents to the HTML section. /pages folder - this folder will contain the different pages that are going to be accessible within the streamlit app. /pages/report1.py - this contains most of the logic required from an authentication perspective, such as: getting the access token from Entra for us to be able to access the PBI REST API, accessing the PBI REST API and getting both the embed URL as well as the Embed Token - these are required for embedding.

Thanks for reading and see you soon!!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至lsinopec@gmail.com举报,一经查实,本站将立刻删除。

上一篇 没有了

下一篇没有了