
Data drives better decisions, and Microsoft Power BI is one of the most popular tools for turning raw data into interactive visual reports. While many teams view these reports inside the Power BI service, embedding them directly into a web application creates a far more seamless experience. Customers can see their analytics inside your product, employees can access dashboards within internal portals, and stakeholders no longer need to switch between tools. This guide explains how to show a Power BI report in a web application, covering embedding options, setup, authentication, security, and best practices.
Integrate Analytics Seamlessly with AAMAX.CO
Embedding analytics requires careful coordination between front-end design, back-end security, and cloud configuration. AAMAX.CO is a full-service digital marketing company offering web development, digital marketing, and SEO services worldwide. Their developers build custom portals and dashboards that integrate third-party tools like Power BI securely and elegantly. Businesses that want to deliver data insights to customers or teams can rely on them to create a polished, high-performance experience from start to finish.
Understand Your Embedding Options
Power BI offers several ways to display reports on the web. Publish to web creates a public embed code that anyone can view, but it should only be used for non-sensitive, public data because there is no authentication. Secure embed lets you embed reports in internal websites or portals such as SharePoint, requiring viewers to sign in with Power BI accounts. Power BI Embedded, also known as "embed for your customers" or "app owns data," lets your application authenticate on behalf of users so they do not need Power BI licenses. The "embed for your organization" or "user owns data" approach requires users to sign in with their own Microsoft accounts. Choose based on your audience, security needs, and licensing.
Prepare Your Power BI Workspace
Start by creating and publishing your report from Power BI Desktop to a workspace in the Power BI service. Embedding for external customers generally requires the workspace to be backed by dedicated capacity, such as a Power BI Embedded A SKU in Azure or a Fabric capacity. Organize reports into dedicated workspaces for each environment, such as development, testing, and production, to manage changes safely.
Register an Application in Microsoft Entra ID
To embed securely, your web application needs an identity. In the Azure portal, open Microsoft Entra ID (formerly Azure Active Directory) and register a new application. Record the application or client ID and tenant ID, and create a client secret or certificate. For the app owns data scenario, using a service principal is recommended. Enable service principal access in the Power BI admin portal and add the service principal as a member or admin of your workspace.
Generate an Embed Token on the Server
Security tokens must always be generated on your back end, never in client-side code. Your server authenticates with Microsoft Entra ID using the client credentials to obtain an Azure AD access token. It then calls the Power BI REST API to retrieve report details, including the embed URL, and to generate an embed token scoped to the specific report and dataset. Microsoft provides SDKs and samples for .NET, Node.js, Python, and Java that simplify these steps. Your front end requests this information from a secure API endpoint in your application.
Embed the Report with the JavaScript SDK
On the front end, install the Power BI JavaScript client library, available as the powerbi-client package, or use the official React wrapper, powerbi-client-react. Create a container element in your page where the report will appear. Then configure an embed object with the report ID, embed URL, embed token, and token type. Call the embed method to render the report inside the container. The SDK also lets you customize the experience, such as hiding the filter pane, adjusting navigation, setting the default page, and applying themes that match your brand.
Handle Token Expiration
Embed tokens expire, typically after an hour. To avoid interruptions, implement a refresh mechanism. Listen for token expiration events or set a timer to request a new token from your back end a few minutes before expiry, then update the embedded report using the SDK's set access token method. This keeps reports working smoothly for users who leave dashboards open for long periods.
Implement Row-Level Security
When multiple customers or departments share the same report, they should only see their own data. Row-level security (RLS) in Power BI allows you to define roles and filters in Power BI Desktop. When generating an embed token, pass the user's identity and role so Power BI applies the correct filters automatically. This approach keeps one report maintainable while ensuring each user sees only authorized information.
Make Reports Interactive and Integrated
The JavaScript SDK supports rich interactivity. Your application can apply filters programmatically based on user selections, listen for events such as data point clicks, export data, and switch between report pages. These capabilities allow reports to feel like native parts of your application rather than isolated iframes. Thoughtful website design around the embedded report, including layout, navigation, and responsive behavior, further enhances usability.
Optimize Performance
Large reports can load slowly. Optimize your data model in Power BI Desktop by removing unnecessary columns, using star schemas, and limiting heavy visuals on a single page. In your application, consider bootstrapping the embed process early so the report begins loading as soon as possible, and use the SDK's preload functionality. Monitor capacity utilization in Azure and scale capacity when usage grows.
Test, Monitor, and Govern
Test embedded reports across browsers and devices, verify that RLS works correctly for different roles, and confirm that token refresh behaves as expected. Monitor usage with Power BI's activity logs and capacity metrics. Establish governance processes for publishing changes so updates to reports do not break embedded experiences unexpectedly.
Conclusion
Showing a Power BI report in a web application transforms static data into interactive insights available exactly where users need them. By selecting the right embedding approach, configuring Microsoft Entra ID, generating tokens securely on the server, using the JavaScript SDK, implementing row-level security, and optimizing performance, you can deliver a professional analytics experience that adds significant value to your application and empowers better decision-making.