maikvandergaag / msft-extensions

Repository for extensions mainly used for Azure DevOps Extensions
https://msftplayground.com
MIT License
126 stars 81 forks source link

400 (BadRequest) when executing Power BI Action - Set refresh schedule #422

Closed MichiPL closed 1 year ago

MichiPL commented 1 year ago

Describe the issue When executing the Power BI Action 'Set Refresh Schedule' it returns a 400 (Bad Request) error. Other actions are a success with the same Service Connection, workspace name & dataset name. The JSON that I am sending with the request is the example provided ({'value': {'days': ['Sunday'],'times': ['07:00'],'localTimeZoneId': 'UTC'}}).

Extension

To Reproduce Steps to reproduce the behavior:

  1. Add Power BI Action to the release pipeline
  2. Add the Service connection, workspace & dataset, the JSON file
  3. Run the release pipeline

Expected behavior The targeted Power BI dataset has a refresh schedule set using the parameters provided in the JSON file.

Situation (please complete the following information):

Log info tasklog_12.log

Additional information YAML of the PBI Action:

Your build pipeline references an undefined variable named ‘workspacename’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

steps:

maikvandergaag commented 1 year ago

@MichiPL: After the PowerBI report is deployed are you able to change the refresh schedule manually or do you have to perform a specific action first?

MichiPL commented 1 year ago

I have to take over the dataset as it is configured by the Service Connection, but after that i can add & adjust a refresh schedule. I've also tried it directly via powershell, but i'm experiencing the same errors (on different datasets). image image

maikvandergaag commented 1 year ago

What steps are you using when doing it via PowerShell?

Could you try a take over dataset action in your pipeline first and than setting the schedule?

MichiPL commented 1 year ago

I'm currently already doing a dataset takeover action in my pipeline, the actions i perform are the following (in order): Publish, take over, SQL credentials update, Refresh schedule, delete report (so only dataset remains). The steps in the Powershell are the following: connect to the PBI service, find & list the workspace & report/dataset, send the request to update the refresh schedule (using the Invoke PowerBI rest method, patch method)

maikvandergaag commented 1 year ago

that is strange i will check what I can find out.

maikvandergaag commented 1 year ago

I have found the solution. By default when setting a refresh schedule through the API of the interface the dataset owner will receive a notification.

When using a service principal for example this will not work as the spn is unable to receive notifications. So you need to disable this in the config.

Sample message will then be:

{'value': {'notifyOption':'NoNotification', 'enabled': true, 'days': ['Monday'],'times': ['07:00'],'localTimeZoneId': 'UTC'}}

MichiPL commented 1 year ago

I have just tested & validated your solution, this seems to work perfectly! Thank you for the feedback, I was breaking my head on the error messages and couldn't figure it out myself. image