Deploy Power BI Paginated Reports with Azure DevOps in a Continuous Deployment scenario

To deploy Power BI reports I have written in the past a blog post: https://www.flip-design.de/?p=1092 But, if you have also Pagenated Reports, these must be also deployed to theworkspace to move them with the Power BI deployment pipelines to the different stages.
so, for example I created a simple report and deployed them to my workspace:

Next, I have added the RDL file to an Azure DevOps repo. To deploy the reports, there is no Task inside DevOps pipelines available, but to achieve a deployment, I created a small PowerShell script.

[CmdletBinding()]
param (
    $ParamUser,
    $ParamPassword,
    $Paramreport,
    $ParamGroupId
)

$Path = "abc"
function Publish-ImportRDLFile 
{
    param
    (
        [string]$RdlFilePath,
        [string]$GroupId,
        [string]$nameConflict = "Overwrite"
    )

    # Get file content and create body
    $fileName = [IO.Path]::GetFileName($RdlFilePath)
    $boundary = [guid]::NewGuid().ToString()
    $fileBody = Get-Content -Path $RdlFilePath -Encoding UTF8

    $body = @"
---------FormBoundary$boundary
Content-Disposition: form-data; name="$filename"; filename="$filename"
Content-Type: application/rdl

$fileBody 
---------FormBoundary$boundary--

"@

    # Get AccessToken and set it as header.
    $headers = Get-PowerBIAccessToken

    $url = "https://api.powerbi.com/v1.0/myorg/groups/$GroupId/imports?datasetDisplayName=$Paramreport&nameConflict=$nameConflict"

    # Create import
    $report = Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $body -ContentType "multipart/form-data"   
    $report.id
}

$moduleName = "MicrosoftPowerBIMgmt.Profile"
$module = Get-Module $moduleName -ListAvailable -ErrorAction SilentlyContinue

if (!$module) 
{
	Install-Module -Name $moduleName -Force -Scope CurrentUser -SkipPublisherCheck 
}

$myPassword = $ParamPassword
$myUsername = $ParamUser

$password = ConvertTo-SecureString $myPassword -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($myUsername, $password)

Login-PowerBIServiceAccount -Credential $credential
# End Parameters =======================================

Publish-ImportRDLFile -GroupId $groupId -RdlFilePath $report

Next, I’ve added the script also to a repo.

Then I have created a release pipeline by using an Azure PowerShell task to call the script and provide the parameters.

After running the pipeline, the new RDL file was successfully deployed.

Categorized: Allgemein

Comments are closed.