Skip to content

Commit cdb2140

Browse files
committed
docs: Add deployment instructions for Power BI integration
1 parent 791b531 commit cdb2140

File tree

2 files changed

+169
-0
lines changed

2 files changed

+169
-0
lines changed

deploy/README.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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+
![Screenshot 2024-07-17 at 8.19.15 AM.png](/.attachments/Screenshot%202024-07-17%20at%208.19.15 AM-062f9c11-0286-4e88-9ac1-da90eabad8c5.png =600x)
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+
![Screenshot 2024-07-17 at 8.04.48 AM.png](/.attachments/Screenshot%202024-07-17%20at%208.04.48 AM-41944f47-aaab-415b-9cb9-e75ab5ec5967.png =600x)
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+
![Screenshot 2024-07-17 at 8.06.50 AM.png](/.attachments/Screenshot%202024-07-17%20at%208.06.50 AM-f9a7ce5a-6e64-4475-a4ec-eaec70089f50.png =600x)
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+
![Screenshot 2024-07-17 at 7.53.01 AM.png](/.attachments/Screenshot%202024-07-17%20at%207.53.01 AM-79bb65df-dfc9-4989-86c1-146f60b49600.png)
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+
![Screenshot 2024-07-17 at 8.02.30 AM.png](/.attachments/Screenshot%202024-07-17%20at%208.02.30 AM-5acc2b30-bb83-4bbb-88d1-153c2f4216fd.png)
46+
47+
1. Search the app that you have previously registered in Azure AD and grant it the permission of **Admin**.
48+
![Screenshot 2024-07-17 at 7.58.15 AM.png](/.attachments/Screenshot%202024-07-17%20at%207.58.15 AM-361bfcf7-4837-4d56-8918-87514c7286b7.png =600x)
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+
![Screenshot 2024-07-17 at 8.11.27 AM.png](/.attachments/Screenshot%202024-07-17%20at%208.11.27 AM-e5f10640-66ba-4961-b4bc-88a33760cd22.png =600x)
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+
![Screenshot 2024-07-17 at 8.14.41 AM.png](/.attachments/Screenshot%202024-07-17%20at%208.14.41 AM-99f4ceb3-9e59-4c91-a105-3a32532f7248.png =600x)
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+
![Screenshot 2024-07-17 at 8.16.38 AM.png](/.attachments/Screenshot%202024-07-17%20at%208.16.38 AM-5668d9bb-fda4-4102-95c9-84f6f8418a29.png =600x)
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+

deploy/azure-pipelines.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
trigger:
2+
- main
3+
4+
pool:
5+
vmImage: 'ubuntu-latest'
6+
7+
steps:
8+
# Install Power BI Actions
9+
- task: PowerShell@2
10+
inputs:
11+
targetType: 'inline'
12+
script: |
13+
Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser -Force
14+
Install-Module -Name MicrosoftPowerBIMgmt.Profile -Scope CurrentUser -Force
15+
Install-Module -Name MicrosoftPowerBIMgmt.Reports -Scope CurrentUser -Force
16+
displayName: 'Install Power BI Actions'
17+
18+
# Deploy PBIX file using PowerShell with Service Principal Authentication
19+
- task: PowerShell@2
20+
inputs:
21+
targetType: 'inline'
22+
script: |
23+
# Authenticate with Power BI Service using Service Principal
24+
$tenantId = "$(TenantId)"
25+
$appId = "$(AppId)"
26+
$appSecret = "$(AppSecret)"
27+
$secureAppSecret = ConvertTo-SecureString -String $appSecret -AsPlainText -Force
28+
$credential = New-Object System.Management.Automation.PSCredential($appId, $secureAppSecret)
29+
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -Tenant $tenantId
30+
31+
# Ensure the MicrosoftPowerBIMgmt.Reports module is imported
32+
Import-Module MicrosoftPowerBIMgmt.Reports
33+
34+
# Publish PBIX file
35+
New-PowerBIReport -Path '../samples/GitHubCopilotTelemetrySample.pbix' -WorkspaceId "$(WorkspaceId)" -Name 'copilot_metrics_usage_sample'
36+
37+
# Note: Ensure that the necessary modules and credentials are correctly set up for this script to work.
38+
displayName: 'Deploy PBIX file to Power BI Workspace using PowerShell'

0 commit comments

Comments
 (0)