Sitemap

How to Create Power BI Devops Release Pipeline to Publish Reports to Dev and Prod Environment

5 min readMay 15, 2025

Introduction

In modern data-driven organizations, managing Power BI report deployments across development (Dev) and production (Prod) environments manually can quickly become inefficient and error-prone. That’s where DevOps practices come into play. In this blog, we’ll walk through how to build a Power BI DevOps release pipeline that automates the publishing of reports to both Dev and Prod environments. Whether you’re new to Power BI automation or looking to enhance your existing deployment strategy, this guide will help you build a robust pipeline for reliable and scalable report publishing.

Files and Repos Setup

  1. Our Repository Structure is as Follows where we have two files in path Power_BI_Deployment → Perigen → Files.
Press enter or click to view image in full size

2. We need to setup an App Registration. Give the necessary Permissions to it like
User.Read
Group.Read.All

Power BI Service
App.Read.All

Capacity.ReadWrite.All

Dataset.ReadWrite.All

Environment.ReadWrite.All

Gateway.ReadWrite.All

Pipeline.ReadWrite.All
SQLDatabase.ReadWrite.All

Workspace.ReadWrite.All

3. We have developed a Powershell Script which will do the main tasks of the following as follows:

a. Determine which workspace to deploy to based on stage order i.e “0” = Dev and “1” = Prod

b. Get the PBIX report file info like the report and the report name.

c. Login to the Power BI workspace using a Service Principal.

d. Get the Workspace Id based on the workspace Name

e. Publish the PBIX file to the Workspace

f. Update the Data Source Settings based on the Environment

g. Take over the Dataset to have full control

h. Update the parameters

4. We have a .pbix file which has Excel as the Data Source.

Setup of the Devops Release Pipeline

  1. Create the artifacts — one for Dev and one for Prod
Press enter or click to view image in full size
Press enter or click to view image in full size

2. Configure the Pipeline variables as below

Press enter or click to view image in full size

3. Setup the Stages as below

Press enter or click to view image in full size

For the Dev task you need to Add a Power Shell Script Task and give the Script Path and Arguments as shown in Screenshot below.

Press enter or click to view image in full size

For the Prod Tasks add the task ‘Create a Pull Request’ for Pulling from Dev into Main Branch.

Press enter or click to view image in full size

Next add the PowerShell Script Task and configure as below for the Script Path and the Arguments.

Press enter or click to view image in full size

The PowerShell Script being used is as below:

param (
[string]$pbixPath = "C:\Power BI Reports\Perigen\OnPremiseReportPOC.pbix",
[string]$datasetRefresh = "No",
[string]$stageOrder = "0", # stage 1 is for production, 0 is for development
[string]$tenantId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
[string]$appId = "xxxxxxxxxxxxxxxxxxxxxxxxx",
[string]$appPassword = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
[string]$workspaceDev = "Perigen POC Workspace 2",
[string]$workspaceProd = "Perigen POC Workspace 3",
[string]$DatamodelFilename = "OnPremiseReportPOC"
)
# Install and import necessary Power BI module
Install-Module MicrosoftPowerBIMgmt -Force
Import-Module MicrosoftPowerBIMgmt
# Determine which workspace to deploy to based on stage order
$DeployToWorkspace = if ($stageOrder -eq 0) { $workspaceDev } elseif ($stageOrder -eq 1) { $workspaceProd } else { Write-Host "Invalid stage order specified. Exiting."; exit }
# Get the PBIX report file info
Write-Host "Start Get report file info"
Write-Host "PBIX Path: $pbixPath"
$report = Get-ChildItem $pbixPath
$reportFileToPublish = $report.Name
Write-Host "End Get report file info"
# Login to Power BI using Service Principal
Write-Host "Start login"
$applicationId = $appId
$securePassword = $appPassword | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword
try {
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $tenantId
Write-Host "Login successful."
} catch {
Write-Host "Error: Login failed. Exiting."
exit
}
# Get workspace ID based on workspace name
Write-Host "Start - Get workspace info"
$workspaceObject = Get-PowerBIWorkspace -Name $DeployToWorkspace
$groupid = $workspaceObject.Id
Write-Host "End - Get workspace info"
# Publish the PBIX file to the workspace
Write-Host "Start Publish report"
try {
$result = New-PowerBIReport -Path $pbixPath -Name $reportFileToPublish -Workspace $workspaceObject -ConflictAction CreateOrOverwrite
$reportid = $result.Id
Write-Host "End Publish report: $reportid"
} catch {
Write-Host "Error: Failed to publish report. $_"
exit
}
# Update data source settings based on stage environment
if ($stageOrder -eq 1) {
# Production deployment
Write-Host "Start Update data source on production"
$datasetName = $DatamodelFilename
$newSource = "C:\Power BI Reports\Perigen\Prod Financial Sample.xlsx"
} elseif ($stageOrder -eq 0) {
# Development deployment
Write-Host "Start Update data source on development"
$datasetName = $DatamodelFilename
$newSource = "C:\Power BI Reports\Perigen\UAT Financial Sample.xlsx"
} else {
Write-Host "Invalid stage order specified. Exiting."
exit
}
# Take over dataset to have full control
$dataset = Get-PowerBIDataset -WorkspaceId $groupid | Where-Object { $_.Name -eq $datasetName }
$datasetid = $dataset.Id
Write-Host "Dataset ID: $datasetid"
$TakeOverUrl = "https://api.powerbi.com/v1.0/myorg/groups/$groupid/datasets/$datasetid/Default.TakeOver"
Invoke-PowerBIRestMethod -Url $TakeOverUrl -Method Post
# Update parameters
$ParametersUrl = "https://api.powerbi.com/v1.0/myorg/groups/$groupid/datasets/$datasetid/Default.UpdateParameters"
$Source = "Source"
$Body = @{
updateDetails = @(
@{
name = $Source
newValue = $newSource
}
)
} | ConvertTo-Json
Invoke-PowerBIRestMethod -Url $ParametersUrl -Method Post -Body $Body -ContentType 'application/json'
Write-Host "End Update data source on $([System.Globalization.CultureInfo]::CurrentCulture.TextInfo.ToTitleCase($DeployToWorkspace))"

Conclusion

Implementing a DevOps release pipeline for Power BI not only simplifies report publishing but also introduces reliability, repeatability, and governance into your BI lifecycle. By automating deployments to Dev and Prod environments, you minimize the risk of human error, reduce deployment time, and maintain version consistency across workspaces.

As Power BI continues to grow in enterprise adoption, integrating it into your DevOps ecosystem becomes essential. With the right setup using Azure DevOps and Power BI REST APIs, you can confidently manage your BI assets like any other software product — securely, efficiently, and at scale.

--

--

Rushank Karekar
Rushank Karekar

Written by Rushank Karekar

Working as a Senior Azure Engineer with Hands-on experience on Azure Integration Services, Azure Data Engineering, Power BI, SSRS, SSIS and Tibco Scribe.

No responses yet