pbi-tools / pbi-tools

Power BI DevOps & Source Control Tool
https://pbi.tools/cli
GNU Affero General Public License v3.0
322 stars 60 forks source link

Error with File deployment - RequestedFileIsEncryptedOrCorrupted #101

Closed TonyGaul closed 2 years ago

TonyGaul commented 2 years ago

Hi Mathias,

I am getting an error when doing a File deployment via DevOps pipeline using pbi-tools.core. I can successfully do a Folder deployment though. Is there any advice or a way I can investigate this further?

Notes:

Interestingly, the following works:

Error from pipeline log for File deployment:

 .\.tool\win-x64\pbi-tools.core.exe deploy . "Files" "DEV"
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    PROFILE: Files
    ENVIRONMENT: DEV
    PBI_CLIENT_SECRET: ***
Reading PBIXPROJ settings from: D:\a\decoda-powerbi\decoda-powerbi\.pbixproj.json
Starting deployment 'Files' into environment: DEV ...
Found 1 source files to deploy.
Access token received. Expires On: 03/07/2022 07:25:29 +00:00
Resolved workspace ID 'b7979b4e-ca87-XXXX-XXXX-XXXXXXXXXXXX' for workspace: 'Decoda Dev'
An unhandled exception occurred.
System.AggregateException: One or more errors occurred. (HTTP Error: BadRequest
{
  "error": {
    "code": "RequestedFileIsEncryptedOrCorrupted",
    "pbi.error": {
      "code": "RequestedFileIsEncryptedOrCorrupted",
      "parameters": {},
      "details": [],
      "exceptionCulprit": 1
    }
  }
})
 ---> PbiTools.Deployments.DeploymentException: HTTP Error: BadRequest
{
  "error": {
    "code": "RequestedFileIsEncryptedOrCorrupted",
    "pbi.error": {
      "code": "RequestedFileIsEncryptedOrCorrupted",
      "parameters": {},
      "details": [],
      "exceptionCulprit": 1
    }
  }
}
 ---> Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'BadRequest'
   at Microsoft.PowerBI.Api.ImportsOperations.UploadFile(Nullable`1 groupId, Stream file, String datasetDisplayName, Nullable`1 nameConflict, Nullable`1 skipReport, Nullable`1 overrideReportLabel, Nullable`1 overrideModelLabel, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.PowerBI.Api.ImportsOperations.PostImportFileWithHttpMessage(Nullable`1 groupId, Stream file, String datasetDisplayName, Nullable`1 nameConflict, Nullable`1 skipReport, Nullable`1 overrideReportLabel, Nullable`1 overrideModelLabel, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.PowerBI.Api.ImportsOperationsExtensions.PostImportWithFileAsyncInGroup(IImportsOperations operations, Guid groupId, Stream fileStream, String datasetDisplayName, Nullable`1 nameConflict, Nullable`1 skipReport, Nullable`1 overrideReportLabel, Nullable`1 overrideModelLabel, CancellationToken cancellationToken)
   at PbiTools.Deployments.DeploymentManager.ImportReportAsync(ReportDeploymentInfo args, IPowerBIClient powerbi, String workspace, IDictionary`2 workspaceIdCache) in X:\pbi-tools\BRANCHES\1.0.0-rc.1\src\PBI-Tools\Deployments\DeploymentManager.cs:line 443
   at PbiTools.Deployments.DeploymentManager.DeployReportAsync(PbiDeploymentManifest manifest, String label, String environment) in X:\pbi-tools\BRANCHES\1.0.0-rc.1\src\PBI-Tools\Deployments\DeploymentManager.cs:line 184
   --- End of inner exception stack trace ---
   at PbiTools.Deployments.DeploymentManager.DeployReportAsync(PbiDeploymentManifest manifest, String label, String environment) in X:\pbi-tools\BRANCHES\1.0.0-rc.1\src\PBI-Tools\Deployments\DeploymentManager.cs:line 188
   at PbiTools.Deployments.DeploymentManager.DeployAsync(String profileName, String environment) in X:\pbi-tools\BRANCHES\1.0.0-rc.1\src\PBI-Tools\Deployments\DeploymentManager.cs:line 99
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at PbiTools.Cli.CmdLineActions.Deploy(String folder, String label, String environment, String basePath, Boolean whatIf) in X:\pbi-tools\BRANCHES\1.0.0-rc.1\src\PBI-Tools\Cli\Deploy.cs:line 41
--- End of stack trace from previous location ---
   at PowerArgs.ArgAction.Invoke()
   at PbiTools.Program.Main(String[] args) in X:\pbi-tools\BRANCHES\1.0.0-rc.1\src\PBI-Tools\Program.cs:line 88
Error: Process completed with exit code 1.

Here is a pipeline Folder deployment, which runs successfully for the same pbix which has been extracted.

   .\.tool\win-x64\pbi-tools.core.exe deploy . "Folders" "DEV"
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    PROFILE: Folders
    ENVIRONMENT: DEV
    PBI_CLIENT_SECRET: ***
Reading PBIXPROJ settings from: D:\a\decoda-powerbi\decoda-powerbi\.pbixproj.json
Starting deployment 'Folders' into environment: DEV ...
Found 1 source folders to deploy.
Creating PBIX from report source at: 'C:\Users\RUNNER~1\AppData\Local\Temp\498d01cb-71da-XXXX-XXXX-XXXXXXXXXXXX\live_connection_report.pbix'...
Reading PBIXPROJ settings from: D:\a\decoda-powerbi\decoda-powerbi\Reports\live_connection_report\.pbixproj.json
Generating PBIX file at 'C:\Users\RUNNER~1\AppData\Local\Temp\498d01cb-71da-XXXX-XXXX-XXXXXXXXXXXX\live_connection_report.pbix'...
Package part written: /Version
Package part written: /Settings
Package part written: /Metadata
Package part written: /DiagramLayout
Package part written: /Report/Layout
Package part written: /Connections
Package part written: /Report/StaticResources/SharedResources/BaseThemes/CY21SU11.json
Access token received. Expires On: 03/07/2022 07:49:20 +00:00
Resolved workspace ID 'b7979b4e-ca87-XXXX-XXXX-XXXXXXXXXXXX' for workspace: 'Decoda Dev'
Import succeeded: 549c97d4-0de2-XXXX-XXXX-XXXXXXXXXXXX (live_connection_report.pbix)
    Report: 02dde1dd-9a18-XXXX-XXXX-XXXXXXXXXXXX "live_connection_report"
    Url: https://app.powerbi.com/groups/b7979b4e-ca87-XXXX-XXXX-XXXXXXXXXXXX/reports/02dde1dd-9a18-XXXX-XXXX-XXXXXXXXXXXX
Report Created: 03/07/2022 06:49:23
Report Updated: 03/07/2022 06:49:23
Deployment completed successfully.

Here I took the pipeline File deployment script and ran it locally. In this example I have 2 reports that deployed successfully. 1 x Live Connection and 1 x Data Model.

.\.tool\win-x64\pbi-tools.core.exe deploy . "Files" "DEV"
Reading PBIXPROJ settings from: D:\Work\Repos\APM\decoda-powerbi\.pbixproj.json
Starting deployment 'Files' into environment: DEV ...
Found 2 source files to deploy.
Access token received. Expires On: 03/07/2022 07:35:17 +00:00
Resolved workspace ID 'b7979b4e-ca87-XXXX-XXXX-XXXXXXXXXXXX' for workspace: 'Decoda Dev'
Import: null, State: Publishing (Id: e3284e81-2996-XXXX-XXXX-XXXXXXXXXXXX)
Import: null, State: Publishing (Id: e3284e81-2996-XXXX-XXXX-XXXXXXXXXXXX)
Import: data_model_report.pbix, State: Publishing (Id: e3284e81-2996-XXXX-XXXX-XXXXXXXXXXXX)
Import: data_model_report.pbix, State: Publishing (Id: e3284e81-2996-XXXX-XXXX-XXXXXXXXXXXX)
Import: data_model_report.pbix, State: Publishing (Id: e3284e81-2996-XXXX-XXXX-XXXXXXXXXXXX)
Import: data_model_report.pbix, State: Publishing (Id: e3284e81-2996-XXXX-XXXX-XXXXXXXXXXXX)
Import: data_model_report.pbix, State: Publishing (Id: e3284e81-2996-XXXX-XXXX-XXXXXXXXXXXX)
Import succeeded: e3284e81-2996-XXXX-XXXX-XXXXXXXXXXXX (data_model_report.pbix)
        Report: 6de70efe-f459-XXXX-XXXX-XXXXXXXXXXXX "data_model_report"
        Url: https://app.powerbi.com/groups/b7979b4e-ca87-XXXX-XXXX-XXXXXXXXXXXX/reports/6de70efe-f459-XXXX-XXXX-XXXXXXXXXXXX
Report Created: 03/07/2022 06:35:30
Report Updated: 03/07/2022 06:35:30
Import: live_connection_report.pbix, State: Publishing (Id: b6207538-6948-XXXX-XXXX-XXXXXXXXXXXX)
Import succeeded: b6207538-6948-XXXX-XXXX-XXXXXXXXXXXX (live_connection_report.pbix)
        Report: 307fdb10-f885-XXXX-XXXX-XXXXXXXXXXXX "live_connection_report"
        Url: https://app.powerbi.com/groups/b7979b4e-ca87-4e36-89aa-817be52d45cb/reports/307fdb10-f885-XXXX-XXXX-XXXXXXXXXXXX
Report Created: 03/07/2022 06:35:36
Report Updated: 03/07/2022 06:35:36
Deployment completed successfully.

Here is some info .\.tool\win-x64\pbi-tools.core.exe info

{
  "version": "1.0.0-rc.1",
  "edition": "Core",
  "build": "1.0.22066.0008",
  "pbixProjVersion": "0.11",
  "amoVersion": "19.36.0.0",
  "toolPath": "D:\\Work\\Repos\\APM\\decoda-powerbi\\.tool\\win-x64\\pbi-tools.core.exe",
  "locale": {
    "system": "en-AU (3081)",
    "ui": "en-GB (2057)"
  },
  "settings": {
    "PBITOOLS_LogLevel": null,
    "PBITOOLS_PbiInstallDir": null,
    "PBITOOLS_AppDataDir": null,
    "PBITOOLS_Debug": null,
    "PBITOOLS_UICulture": null
  },
  "runtime": {
    "platform": "Microsoft Windows 10.0.19044",
    "architecture": "X64",
    "framework": ".NET 6.0.2"
  }
}

Thanks Tony

mthierba commented 2 years ago

Hi Tony, This error message occurs when you're using git-lfs in your repo without having LFS support enabled in your pipeline. Both GitHub and Azure require an explicit "LFS" flag to be set on the checkout step. Mathias

mthierba commented 2 years ago

Line 34 is the crucial one here: https://dev.azure.com/pbi-tools/Samples/_git/single-workspace-with-pbix?path=/azure-pipelines.yml

TonyGaul commented 2 years ago

Uh huh! I missed copying those LFS lines across when setting up the File deployment. I started with the single-workspace project file. My bad, thanks for the explanation. I have fixed my code and it all works perfectly now! Can you please close this.

I also got Git Hub working from this link, but I have no doubt you and others are aware of this. Just linking for other people like me that might stumble on this. https://stackoverflow.com/questions/61463578/github-actions-actions-checkoutv2-lfs-true-flag-not-converting-pointers-to-act