My goal is to set up an Azure DevOps pipeline that can publish a report to the Development workspace.
The below code uses a service principle account to authenticate and then successfully publishes my test .pbix file (LocalReportModel.pbix") this file is a simple report and model structure
Import-Module MicrosoftPowerBIMgmt
$clientId = "****"
$clientSecret = "****"
$tenantId = "****"
$secpasswd = ConvertTo-SecureString $clientSecret -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($clientId, $secpasswd)
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $tenantId
$workspaceName = "Development"
$workspace = Get-PowerBIWorkspace -Name $workspaceName
$file = "C:\Tasks\BI\LocalReportModel.pbix"
New-PowerBIReport -Path $file -Workspace $workspace -ConflictAction CreateOrOverwrite
We use On Premises Gateways so our model/dataset it not stored within the .pbix file When I try the above with the file ReportOnly.pbix I get the error
New-PowerBIReport: Operation returned an invalid status code 'BadRequest'
How can I add the link to the dataset currently within the workspace so that it will publish?
Thank you for any help you can offer.
I am trying to add a connection to the current dataset within my workspace and then publish my report (without a dataset) - The solution must be automated with no interaction
Detailed error after running Resolve-PowerBIError -Last
RequestId : b61fca07-257c-4b72-831c-720f663781f0
Response : Bad Request (400): {"error":{"code":"PowerBIModelNotFoundException","pbi.error":{"code":"PowerBIMode
lNotFoundException","parameters":{},"details":[],"exceptionCulprit":1}}}
PowerBIErrorInfo : PowerBIModelNotFoundException
ResponseDate : Tue, 06 Jun 2023 12:57:49 GMT
RequestMethod : POST
RequestUri : https://api.powerbi.com/v1.0/myorg/groups/ac77d540-4689-4c0a-be9a-afa7a77he6aa/imports?datasetDispla
yName=Sales Margin Model.pbix&nameConflict=CreateOrOverwrite
InvocationInfo : {New-PowerBIReport}
Line : New-PowerBIReport -Path $file -Workspace $workspace -ConflictAction CreateOrOverwrite
Position : At line:1 char:1
+ New-PowerBIReport -Path $file -Workspace $workspace -ConflictAction C …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
StackTrace : at Microsoft.PowerBI.Api.V2.Imports.UploadFile(String groupId, Stream file, String
datasetDisplayName, String nameConflict, Nullable`1 skipReport, Dictionary`2 customHeaders,
CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.V2.Imports.PostImportFileWithHttpMessage(String groupId, Stream file,
String datasetDisplayName, String nameConflict, Nullable`1 skipReport, Dictionary`2 customHeaders,
CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.V2.ImportsExtensions.PostImportWithFileInGroup(IImports operations,
String groupId, Stream fileStream, String datasetDisplayName, String nameConflict, Nullable`1
skipReport)
at Microsoft.PowerBI.Common.Api.Reports.ReportsClient.PostImportForWorkspace(Guid workspaceId,
String datasetDisplayName, String filePath, ImportConflictHandlerModeEnum nameConflict)
at Microsoft.PowerBI.Common.Api.Reports.ReportsClient.PostReportForWorkspace(Guid workspaceId,
String reportName, String filePath, ImportConflictHandlerModeEnum nameConflict, Int32 timeout)
at Microsoft.PowerBI.Commands.Reports.NewPowerBIReport.ExecuteCmdlet()
at Microsoft.PowerBI.Commands.Common.PowerBICmdlet.ProcessRecord()