Forum Discussion
Anonymous
1 year agoNot applicable
Duplicate reports are creating while deploying the report using Azure DevOps pipeline
HI Team, Test Case 1: I am trying to deploy PBIX file (which is having only Report) into PowerBI service using Azure DevOps services using CI CD pipelines. While am trying to deploy it's duplica...
Anonymous
1 year agoNot applicable
https://gallery.technet.microsoft.com/AzureDevOps-CICD-for-fefd58b8
Provided link is not working, We have two workspaces 1 workspace for Dataset and 1 workspace for Report.
When we are deploying the report using Devops pipelines the report is not being overwrite it is creating the new report id
steps:
# Step 1: Copy PBIX File to Artifact Staging Directory
- task: CopyFiles@2
displayName: 'Copy PBIX File'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '${{ parameters.reportName }}.pbix'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
OverWrite: true
# Step 2: Publish Build Artifacts (PBIX file)
- task: PublishBuildArtifacts@1
displayName: 'Publish Build Artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- task: maikvandergaag.maikvandergaag-power-bi-actions.PowerBIActions.PowerBIActions@5
displayName: 'Report Deployment'
inputs:
PowerBIServiceEndpoint: 'Power BI for CICD'
WorkspaceName: ${{ parameters.ReportWorkspaceName }}
PowerBIPath: '$(System.DefaultWorkingDirectory)/${{ parameters.reportName }}.pbix'
Overwrite: true
Create: false
# # Step 3: Report Deployment using Azure CLI (Replace or Create Report)
# - task: AzureCLI@2
# displayName: 'Report Deployment'
# inputs:
# azureSubscription: 'Power Bi Service Principal'
# scriptType: ps
# scriptLocation: inlineScript
# inlineScript: |
# Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser -Force -AllowClobber
# Import-Module MicrosoftPowerBIMgmt
# # Set up Service Principal credentials
# $applicationId = "<Client-id>"
# $securePassword = "<Secure-Password>" | ConvertTo-SecureString -AsPlainText -Force
# $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword
# $tenantId = "<Tenant-ID>"
# # Connect to Power BI Service using Service Principal
# Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $tenantId
# # Define variables
# $workspaceName = "<reportName>" # Name of the workspace
# $workspaceId = (Get-PowerBIWorkspace -Name $workspaceName).Id # Dynamically retrieve workspace ID
# $reportPath = '$(System.DefaultWorkingDirectory)/${{ parameters.reportName }}.pbix' # Path to the PBIX file
# $reportName = "CI-CD Test" # Name of the report in Power BI
# if (-Not $workspaceId) {
# Write-Host "Workspace '$workspaceName' not found. Please check the workspace name."
# exit
# }
# if (-Not (Test-Path $reportPath)) {
# Write-Host "Report file not found at path '$reportPath'. Please check the file path."
# exit
# }
# try {
# # Get the existing report in the workspace
# $existingReport = Get-PowerBIReport -WorkspaceId $workspaceId | Where-Object { $_.Name -eq $reportName }
# if ($existingReport) {
# # Get the report ID of the existing report
# $reportId = $existingReport.Id
# Write-Host "Existing report found. Report ID: $reportId"
# # Replace the report using Import-PowerBIReport with -ConflictAction Replace
# New-PowerBIReport -Path $reportPath -WorkspaceId $workspaceId -ConflictAction Overwrite
# Write-Host "Report '$reportName' (ID: $reportId) successfully replaced in workspace '$workspaceId'."
# } else {
# # Create a new report if it doesn't exist
# New-PowerBIReport -Path $reportPath -WorkspaceId $workspaceId
# Write-Host "Report '$reportName' successfully created in workspace '$workspaceId'."
# }
# } catch {
# Write-Host "An error occurred: $_"
# }
# addSpnToEnvironment: true
# Step 4: Dataset Deployment
- task: PowerBIActions@5
displayName: 'Dataset Deployment'
inputs:
PowerBIServiceEndpoint: '$(powerBIServiceEndpoint)'
WorkspaceName: ${{ parameters.DatasetWorkspaceName }}
PowerBIPath: '$(System.DefaultWorkingDirectory)/${{ parameters.reportName }}.pbix'
# Step 5: Dataset Rebinding (Rebind report to the dataset)
- task: PowerBIActions@5
displayName: 'Dataset Update'
inputs:
PowerBIServiceEndpoint: '$(powerBIServiceEndpoint)'
Action: 'RebindReport'
CrossWorkspaceRebinding: true
WorkspaceName: ${{ parameters.DatasetWorkspaceName }}
ReportWorkspaceName: ${{ parameters.ReportWorkspaceName }}
DatasetName: ${{ parameters.reportName }}
ReportName: ${{ parameters.reportName }}