|
| 1 | +# Deployment |
| 2 | + |
| 3 | +The report can be deployed many different ways. Publishing from PowerBI Desktop is likely the fastest. For a more automated version which would include report version, you should use a repository. Below are the instructions on how to deploy your report in Azure DevOps repos, into your Power BI Workspace using a Azure DevOps Pipeline. |
| 4 | + |
| 5 | +### Installing the ADO Extension |
| 6 | + |
| 7 | +Install the extension |
| 8 | +These instructions will show you how to install the Power BI Action extension that we are going to use for this tutorial, |
| 9 | + |
| 10 | +1. Sign in to your Azure DevOps organization. |
| 11 | +1. Go to Organization Settings. |
| 12 | +1. Select Extensions. |
| 13 | +1. Click on Browse Marketplace at the top right. |
| 14 | +1. Search for and install `Power BI Actions`. [Power BI Actions Extension!](https://marketplace.visualstudio.com/items?itemName=maikvandergaag.maikvandergaag-power-bi-actions) |
| 15 | +<img width="600" alt="Screenshot 2024-07-17 at 8 19 15 AM" src="https://github.com/user-attachments/assets/c79c98c2-55a4-4772-ba62-8cccc7a83bef"> |
| 16 | + |
| 17 | + |
| 18 | +### Get the PBI Workspace ID. Open Powershell in Administrative Mode and run: |
| 19 | +1. Install Power BI Management module |
| 20 | + `Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser -Force` |
| 21 | + |
| 22 | +1. Sign in to Power BI |
| 23 | + `Login-PowerBI` |
| 24 | + |
| 25 | +3. List all workspaces |
| 26 | + `Get-PowerBIWorkspace -Scope Organization` |
| 27 | + |
| 28 | +Write down the Workpace ID and save it for later |
| 29 | + |
| 30 | +### Create the App Registration |
| 31 | +1. Go to Entra AD |
| 32 | +<img width="600" alt="Screenshot 2024-07-17 at 8 04 48 AM" src="https://github.com/user-attachments/assets/1f4af117-5383-42cb-8403-1f59c162486e"> |
| 33 | + |
| 34 | +1. Set `API Permissions -> Add a permission` |
| 35 | +1. Power BI Service |
| 36 | +1. Chose Delegated permissions |
| 37 | +1. Chose: |
| 38 | + - Tenant.Read.All |
| 39 | + - Tenant.ReadWrite.All |
| 40 | + - Report.ReadWrite.All |
| 41 | +<img width="600" alt="Screenshot 2024-07-17 at 8 06 50 AM" src="https://github.com/user-attachments/assets/238ed9b4-6caa-4f2c-8b13-4c0893dd4c67"> |
| 42 | + |
| 43 | +### Power BI |
| 44 | + |
| 45 | +Setting up the tenant |
| 46 | +The next step is to configure your Power BI, |
| 47 | + |
| 48 | +1. Sign in to the Power BI portal. |
| 49 | +1. Click the gear icon on the top right and select Admin portal. |
| 50 | +1. Select the Tenant settings and scroll down to Developer Settings and allow service principals to use Power BI APIs |
| 51 | +<img width="600" alt="Screenshot 2024-07-17 at 7 53 01 AM" src="https://github.com/user-attachments/assets/cb52ca8c-ada2-4446-ba43-b973f16bdcce"> |
| 52 | + |
| 53 | +### Configure a workspace |
| 54 | +Now create the workspace where your pipeline will publish the reports and grant permission to your Azure AD App to do this, |
| 55 | + |
| 56 | +1. Select Workspaces tab. |
| 57 | +1. Click the three vertical dots on the right of your new workspace. |
| 58 | +1. Click Manage access. |
| 59 | +<img width="600" alt="Screenshot 2024-07-17 at 8 02 30 AM" src="https://github.com/user-attachments/assets/9cdcbc1e-a790-4c82-b0c5-c62277af104c"> |
| 60 | + |
| 61 | +4. Search the app that you have previously registered in Azure AD and grant it the permission of **Admin**. |
| 62 | +<img width="600" alt="Screenshot 2024-07-17 at 7 58 15 AM" src="https://github.com/user-attachments/assets/5fed83f5-491b-4098-96fe-4a99fd8ba4bc"> |
| 63 | + |
| 64 | +### Create a new service connection |
| 65 | +1. Go to Project Settings. |
| 66 | +1. Select Service connections. |
| 67 | +1. Click the New service connection button and select Power BI Service Connection. |
| 68 | +<img width="600" alt="Screenshot 2024-07-17 at 8 11 27 AM" src="https://github.com/user-attachments/assets/b5dd095f-c210-43b5-b041-a00587b79226"> |
| 69 | + |
| 70 | +4. Fill in the parameters for the service connection and allow all pipelines to use this connection option. Be sure to pick the type of _Service Principal_ |
| 71 | +1. Click OK to create the connection. |
| 72 | +<img width="600" alt="Screenshot 2024-07-17 at 8 14 41 AM" src="https://github.com/user-attachments/assets/01b6f4c9-3290-4de4-b076-b7a5fdd1c757"> |
| 73 | + |
| 74 | + |
| 75 | +### Creating the Build Pipeline |
| 76 | +It is time to create your build pipeline. |
| 77 | + |
| 78 | +1. From the dashboard, select Pipelines. |
| 79 | +1. Click the New pipeline button. |
| 80 | +1. Select Azure Git Repos as a source that will trigger our pipeline. |
| 81 | +1. Azure DevOps will suggest several templates, select the Starter Pipeline, to begin with a bare bone pipeline. |
| 82 | +1. Create 4 variables for: |
| 83 | + - AppId |
| 84 | + - AppSecret |
| 85 | + - TenantId |
| 86 | + - WorkspaceId |
| 87 | +<img width="600" alt="Screenshot 2024-07-17 at 8 16 38 AM" src="https://github.com/user-attachments/assets/0bbe7b5b-697c-4d4b-8f94-d8c8f8994903"> |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | +1. Add the following YAML snippet to your pipeline |
| 92 | +``` yaml |
| 93 | +trigger: |
| 94 | +- main |
| 95 | + |
| 96 | +pool: |
| 97 | + vmImage: 'ubuntu-latest' |
| 98 | + |
| 99 | +steps: |
| 100 | + Install Power BI Actions |
| 101 | +- task: PowerShell@2 |
| 102 | + inputs: |
| 103 | + targetType: 'inline' |
| 104 | + script: | |
| 105 | + Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser -Force |
| 106 | + Install-Module -Name MicrosoftPowerBIMgmt.Profile -Scope CurrentUser -Force |
| 107 | + Install-Module -Name MicrosoftPowerBIMgmt.Reports -Scope CurrentUser -Force |
| 108 | + displayName: 'Install Power BI Actions' |
| 109 | + |
| 110 | +Deploy PBIX file using PowerShell with Service Principal Authentication |
| 111 | +- task: PowerShell@2 |
| 112 | + inputs: |
| 113 | + targetType: 'inline' |
| 114 | + script: | |
| 115 | + # Authenticate with Power BI Service using Service Principal |
| 116 | + $tenantId = "$(TenantId)" |
| 117 | + $appId = "$(AppId)" |
| 118 | + $appSecret = "$(AppSecret)" |
| 119 | + $secureAppSecret = ConvertTo-SecureString -String $appSecret -AsPlainText -Force |
| 120 | + $credential = New-Object System.Management.Automation.PSCredential($appId, $secureAppSecret) |
| 121 | + Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -Tenant $tenantId |
| 122 | + |
| 123 | + # Ensure the MicrosoftPowerBIMgmt.Reports module is imported |
| 124 | + Import-Module MicrosoftPowerBIMgmt.Reports |
| 125 | +
|
| 126 | + # Publish PBIX file |
| 127 | + New-PowerBIReport -Path './samples/GitHubCopilotTelemetrySample.pbix' -WorkspaceId "$(WorkspaceId)" -Name 'copilot_metrics_usage_sample' |
| 128 | + |
| 129 | + # Note: Ensure that the necessary modules and credentials are correctly set up for this script to work. |
| 130 | + displayName: 'Deploy PBIX file to Power BI Workspace using PowerShell' |
| 131 | +``` |
| 132 | +The remaining step is to save, check-in, and then watch it automatically deploy as the trigger is set to monitor the main branch |
| 133 | +
|
| 134 | +
|
| 135 | +
|
| 136 | +
|
| 137 | +
|
| 138 | +
|
| 139 | +
|
0 commit comments