Microsoft Power BI Developer Samples

repository·master·Indexed 23 days ago

https://github.com/microsoft/powerbi-developer-samples

A collection of Power BI Embedded solutions and reference implementations across multiple frameworks, including C#, JS, Python, Java, TS, and PowerShell. The repository provides samples for 'App Owns Data' and 'User Owns Data' embedding scenarios, credential encryption, and interacting with Power BI REST APIs.

Tokens
10.9K
Snippets
22
Records
55
Agent score
80%

What's inside microsoft-powerbi-developer-samples

  1. Overview of Power BI Embedded solutions

    master

    This repository provides sample implementations for embedding Power BI content using various frameworks. The solutions are categorized by the embedding model used:

    Embed for your customers (App Owns Data)

    Use this model when your application manages access to data for its users. Available frameworks:

    • .NET Framework
    • .NET Core
    • Python
    • Java
    • Node JS

    Embed for your organization (User Owns Data)

    Use this model when users sign in with their own Power BI identities to access content. Available frameworks:

    • .NET Framework
    • .NET Core
    • React TS

    Specialized Functionality

    If you need to implement credential encryption or data source updates, use the following frameworks:

    • .NET Core
    • Python
    • Node JS

    Additionally, the repository includes PowerShell samples for calling the Power BI REST APIs.

  2. Available Microsoft Power BI PowerShell scripts

    master

    This repository provides a collection of self-documenting PowerShell scripts for interacting with Power BI REST APIs. The scripts cover administrative tasks, workspace management, deployment pipelines, and dataset operations.

    | Script | Description |
    |----|:---|
    | [Admin-Create-Workspace-Inventory-Report.ps1](Admin-Create-Workspace-Inventory-Report.ps1) | Run as admin to get inventory report for workspace |
    | [Admin-Get-All-Workspaces-in-Tenant.ps1](Admin-Get-All-Workspaces-in-Tenant.ps1) | Run as admin to get list all of asctive workspace in current tenant |
    | [bindToGateway.ps1](bindtogateway.ps1) | Bind a dataset to a new gateway |
    | [copyWorkspace.ps1](copyWorkspace.ps1) | Duplicate a workpsace in the Power BI service |
    | [Create-Workspace-and-Add-Workspace-Users.ps1](Create-Workspace-and-Add-Workspace-Users.ps1) | Create a new workspace and add user as contributor |
    | [Create-Workspace.ps1](Create-Workspace.ps1) | Create a new workspace |
    | [DeploymentPipelines-AddUserToPipeline.ps1](DeploymentPipelines-AddUserToPipeline.ps1) | Add a user as an admin to a deployment pipeline |
    | [DeploymentPipelines-DeployAll.ps1](DeploymentPipelines-DeployAll.ps1) | Starts a deployment of all contnet between two stages in the pipeline |
    | [DeploymentPipelines-E2ESampleFromPipelineCreationToDeployment.ps1](DeploymentPipelines-E2ESampleFromPipelineCreationToDeployment.ps1) | End to end sample - create a pipeline, assign a workspace to Production and backward deploy to Test and Development |
    | [DeploymentPipelines-SelectiveDeploy.ps1](DeploymentPipelines-SelectiveDeploy.ps1) | Starts a deployment of specific contnet between two stages in the pipeline |
    | [DeploymentPipelines-WaitForDeployment.ps1](DeploymentPipelines-WaitForDeployment.ps1) | Waits for the deployment operation to be completed |
    | [Import-PBIX-File.ps1](Import-PBIX-File.ps1) | Import PBIX into a target workspace |
    | [Login-User-Interactively.ps1](Login-User-Interactively.ps1) | Login user interactively as script runs |
    | [Login-User-Unattended.ps1](Login-User-Unattended.ps1) | Login user automatically using hard-coded user name and password |
    | [Patch-Anonymous-Datasource-Credentials-and-Refresh.ps1](Patch-Anonymous-Datasource-Credentials-and-Refresh.ps1) | Patch credentials for anonymous datasource and start dataset refresh operation |
    | [Patch-SQL-Datasource-Credentials-and-Refresh.ps1](Patch-SQL-Datasource-Credentials-and-Refresh.ps1) | Patch credentials for Azure SQL datasource and start dataset refresh operation |
    | [manageRefresh.ps1](manageRefresh.ps1) | Trigger scheduled refresh and check refresh history |
    | [rebindReport.ps1](rebindReport.ps1) | Clone a report in the Power BI service and rebind it to a different dataset |
    | [takeOverDataset.ps1](takeOverDataset.ps1) | Take ownership of a dataset to your account |
    | [Update-Connection-Details-for-Sql-Datasource.ps1](Update-Connection-Details-for-Sql-Datasource.ps1) | Update server name and/or database name for Azure SQL datasource |
    | [Update-Dataset-Parameters.ps1](Update-Dataset-Parameters.ps1) | Update dataset parameter |
  3. Configure Power BI authentication requirements

    master

    When setting up authentication for the Flask sample, ensure the following permissions are met:

    • Service Principal Authentication: The Azure AD Service Principal used for authentication must have admin rights on the corresponding Power BI workspace.
    • On-premises Gateway: If using Service Principal mode alongside an on-premises gateway, the Service Principal must be a gateway admin.
    • Power BI App Setup: Follow the official guidance at aka.ms/EmbedForCustomer to set up your Power BI app.
  4. Build and run the AppOwnsData sample in Eclipse

    master

    Follow these steps to configure the environment, import the project, and launch the application:

    1. Configure Tomcat Server in Eclipse

    1. Open the Servers view (Window > Show View > Servers).
    2. Click No servers are available. Click this link to create a new server....
    3. Select v9.0 Tomcat version from Apache.
    4. Browse to and select your Tomcat installation folder.
    5. Select your system JRE and click Finish.

    2. Import and Configure the Project

    1. Import: File > Open Project from File System > Select the AppOwnsData directory.
    2. Dependencies: Wait for Maven to automatically download dependencies.
    3. Targeted Runtime: Right-click the AppOwnsData project > Properties > Targeted Runtimes > Select Apache Tomcat > Apply and Close.
    4. Configuration: Open src/main/java/com/embedsample/appownsdata/config/Config.java and fill in the required parameters for:
      • AAD app
      • Power BI report
      • Workspace
      • User account information

    3. Run the Application

    1. Right-click the project name > Run As > Run on Server.
    2. Select your Tomcat server and click Finish.
    3. Access the app at: http://localhost:8080/appownsdatasample

    Supported Browsers: Google Chrome, Microsoft Edge, and Mozilla Firefox.

  5. Requirements for the Power BI credentials encryption sample

    master

    To run this Spring MVC sample, you need the following environment setup:

    1. JDK (or JRE): Ensure Java is installed and the path is added to your environment variables. Verify installation by running java -version in your terminal.
    2. Eclipse IDE: Specifically the Eclipse for Enterprise Java Developers package.
    3. Apache Tomcat: Download the binary distributions (v9.0 is used in the guide).
  6. Configure and run the Flask application

    master

    To run the application locally:

    1. Open the AppOwnsData folder in your IDE.
    2. Edit AppOwnsData/config.py to provide the required parameters for your AAD app, Power BI report, workspace, and user account information.
    3. Start the server using the flask run command.
    4. Access the application at http://localhost:5000.

    Note: You must restart the application whenever you modify config.py for changes to take effect.

    flask run
  7. Build and run the EncryptCredentials project in Eclipse

    master

    Follow these steps to configure the environment and execute the Spring MVC application:

    1. Configure Tomcat Server in Eclipse

    1. Open the Servers view (Window > Show View > Servers).
    2. Click No servers are available. Click this link to create new server....
    3. Select v9.0 Tomcat version from Apache.
    4. Browse to and select your Tomcat installation folder.
    5. Select your system JRE and click Finish.

    2. Import and Configure the Project

    1. Import: Click File > Open Project from File System, select the Update Credentials folder, and click Finish.
    2. Dependencies: Allow Maven to download dependencies automatically.
    3. Targeted Runtimes: Right-click the EncryptCredentials project > Properties > Targeted Runtimes > Select Apache Tomcat > Apply and Close.
    4. Configuration: Open src/main/java/com/encryptcredentialsample/encryptcredential/config/Config.java and fill in the required parameters for:
      • AAD app
      • Power BI report
      • Workspace
      • User account information

    3. Execution

    1. Right-click the project name > Run As > Run on Server.
    2. Select your Tomcat server and click Finish.
    3. Access the application at: http://localhost:8080/encryptcredential

    Supported Browsers: Google Chrome, Microsoft Edge, and Mozilla Firefox.