|
| 1 | +1. In your ADO organization you first need to install `Power BI Actions`. [Power BI Actions Extension!](https://marketplace.visualstudio.com/items?itemName=maikvandergaag.maikvandergaag-power-bi-actions) |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +1. Get the PBI Workspace ID. Open Powershell in Administrative Mode and run: |
| 6 | +### Install Power BI Management module |
| 7 | + `Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser -Force` |
| 8 | + |
| 9 | +### Sign in to Power BI |
| 10 | + `Login-PowerBI` |
| 11 | + |
| 12 | +### List all workspaces |
| 13 | + `Get-PowerBIWorkspace -Scope Organization` |
| 14 | + |
| 15 | +Write down the Workpace ID: |
| 16 | + |
| 17 | +#Create the App Registration |
| 18 | +1. Go to Entra AD |
| 19 | + |
| 20 | +1. Set `API Permissions -> Add a permission` |
| 21 | +1. Power BI Service |
| 22 | +1. Chose Delegated permissions |
| 23 | +1. Chose: |
| 24 | + - Tenant.Read.All |
| 25 | + - Tenant.ReadWrite.All |
| 26 | + - Report.ReadWrite.All |
| 27 | + |
| 28 | + |
| 29 | +#Power BI |
| 30 | + |
| 31 | +Setting up the tenant |
| 32 | +The next step is to configure your Power BI, |
| 33 | + |
| 34 | +1. Sign in to the Power BI portal. |
| 35 | +1. Click the gear icon on the top right and select Admin portal. |
| 36 | +1. Select the Tenant settings and scroll down to Developer Settings and allow service principals to use Power BI APIs |
| 37 | + |
| 38 | + |
| 39 | +#Configure a workspace |
| 40 | +Now create the workspace where your pipeline will publish the reports and grant permission to your Azure AD App to do this, |
| 41 | + |
| 42 | +1. Select Workspaces tab. |
| 43 | +1. Click the three vertical dots on the right of your new workspace. |
| 44 | +1. Click Manage access. |
| 45 | + |
| 46 | + |
| 47 | +1. Search the app that you have previously registered in Azure AD and grant it the permission of **Admin**. |
| 48 | + |
| 49 | + |
| 50 | +#Azure DevOps |
| 51 | + |
| 52 | +Install the extension |
| 53 | +These instructions will show you how to install the Power BI Action extension that we are going to use for this tutorial, |
| 54 | + |
| 55 | +1. Sign in to your Azure DevOps organization. |
| 56 | +1. Go to Organization Settings. |
| 57 | +1. Select Extensions. |
| 58 | +1. Click on Browse Marketplace at the top right. |
| 59 | + |
| 60 | +#Create a new service connection |
| 61 | +1. Go to Project Settings. |
| 62 | +1. Select Service connections. |
| 63 | +1. Click the New service connection button and select Power BI Service Connection. |
| 64 | + |
| 65 | +1. Fill in the parameters for the service connection and allow all pipelines to use this connection option. |
| 66 | +1. Click OK to create the connection. |
| 67 | + |
| 68 | + |
| 69 | +#Creating the Build Pipeline |
| 70 | +It is time to create your build pipeline. |
| 71 | + |
| 72 | +1. From the dashboard, select Pipelines. |
| 73 | +1. Click the New pipeline button. |
| 74 | +1. Select Azure Git Repos as a source that will trigger our pipeline. |
| 75 | +1. Azure DevOps will suggest several templates, select the Starter Pipeline, to begin with a bare bone pipeline. |
| 76 | +1. Create 4 variables for: |
| 77 | + - AppId |
| 78 | + - AppSecret |
| 79 | + - TenantId |
| 80 | + - WorkspaceId |
| 81 | + |
| 82 | + |
| 83 | +1. Add the following YAML snippet to your pipeline |
| 84 | +``` yaml |
| 85 | +trigger: |
| 86 | +- main |
| 87 | + |
| 88 | +pool: |
| 89 | + vmImage: 'ubuntu-latest' |
| 90 | + |
| 91 | +steps: |
| 92 | + Install Power BI Actions |
| 93 | +- task: PowerShell@2 |
| 94 | + inputs: |
| 95 | + targetType: 'inline' |
| 96 | + script: | |
| 97 | + Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser -Force |
| 98 | + Install-Module -Name MicrosoftPowerBIMgmt.Profile -Scope CurrentUser -Force |
| 99 | + Install-Module -Name MicrosoftPowerBIMgmt.Reports -Scope CurrentUser -Force |
| 100 | + displayName: 'Install Power BI Actions' |
| 101 | + |
| 102 | +Deploy PBIX file using PowerShell with Service Principal Authentication |
| 103 | +- task: PowerShell@2 |
| 104 | + inputs: |
| 105 | + targetType: 'inline' |
| 106 | + script: | |
| 107 | + # Authenticate with Power BI Service using Service Principal |
| 108 | + $tenantId = "$(TenantId)" |
| 109 | + $appId = "$(AppId)" |
| 110 | + $appSecret = "$(AppSecret)" |
| 111 | + $secureAppSecret = ConvertTo-SecureString -String $appSecret -AsPlainText -Force |
| 112 | + $credential = New-Object System.Management.Automation.PSCredential($appId, $secureAppSecret) |
| 113 | + Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -Tenant $tenantId |
| 114 | + |
| 115 | + # Ensure the MicrosoftPowerBIMgmt.Reports module is imported |
| 116 | + Import-Module MicrosoftPowerBIMgmt.Reports |
| 117 | +
|
| 118 | + # Publish PBIX file |
| 119 | + New-PowerBIReport -Path './samples/GitHubCopilotTelemetrySample.pbix' -WorkspaceId "$(WorkspaceId)" -Name 'copilot_metrics_usage_sample' |
| 120 | + |
| 121 | + # Note: Ensure that the necessary modules and credentials are correctly set up for this script to work. |
| 122 | + displayName: 'Deploy PBIX file to Power BI Workspace using PowerShell' |
| 123 | +``` |
| 124 | +The remaining step is to save, check-in, and then watch it automatically deply |
| 125 | +
|
| 126 | +
|
| 127 | +
|
| 128 | +
|
| 129 | +
|
| 130 | +
|
| 131 | +
|
0 commit comments