microsoft / microsoft/powerbi-powershell

New-PowerBIReport : Operation returned an invalid status code 'BadRequest' - Azure Pipeline CI/CD

Open
#313 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
413
Forks
134
Avg merge
33m
Merged PRs (30d)
1

Description

Hey Guys,

Did you have the same problem? I am getting the below error:

image

New-PowerBIReport : Operation returned an invalid status code 'BadRequest' when trying to create report from *.pbix file in workspace using Azure pipeline (SPN auth)

When I am running the same script from my local computer I am not getting such an error.

Would you be able to help me, please

Here is my code:

`

      Write-Output "Connecting with Azure..."
      Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $AzureTenant
      Write-Output "Connected to Azure"

      Get-ChildItem "D:\a\1\s\Reports_files\"
      $files_reports = Get-ChildItem -Path 'D:\a\1\s\Reports_files\' -Recurse -Filter *.pbix

      Add-Type -AssemblyName System.Net.Http

      $PBIWorksSpaceIDTarget = (Get-PowerBIWorkspace -Name $PBIWorkspace) | Select-Object Id

      foreach ($file_report in $files_reports) {

            Write-Output "Publishing file" $file_report.Name
            
            $pathtoreport = 'D:\a\1\s\Reports_files\'+$file_report.Name
            $reportName = $file_report.Name.Substring(0, $file_report.Name.lastIndexOf('.'))
            
            Write-Output "Path to report:" $pathtoreport

            $result = New-PowerBIReport -Path $pathtoreport -Name $reportName -WorkspaceId $PBIWorksSpaceIDTarget.Id -ConflictAction CreateOrOverwrite   
            Write-Output "Status of upload:" $result.WebUrl

            $fileCount++
       }`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the posted PowerShell script and the New-PowerBIReport invocation; compare its local and Azure Pipeline execution under service-principal authentication, including the workspace ID and PBIX path. Reproduce the BadRequest if possible and document the confirmed cause and required change or configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.