简体   繁体   中英

How to create a Power BI DataSet Scheduled Refresh programatically

Requirement : To create a Power BI Dataset scheduled refresh through code and use it in DevOps process, so that I do not have to create scheduled refresh explicitly from Power BI web portal.

What I tried/research : I could not find Power BI API explicitly to create scheduled refresh. So, I tried to use update refresh schedule datasets API: https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/refreshSchedule Refer: MicrosoftDocs

Observed : If the schedule is OFF - this API turns ON the schedule and updates the refresh schedule of the dataset. However, to achieve this I had to create schedule at least once using the Power BI web portal. Then if I turn off the schedule and run the above API, it turns ON the schedule and updates refresh schedule timings.

Are any workarounds to setup a Power BI Dataset scheduled refresh via API?

Yes there is by using the 'Update refresh schedule in group' endpoint:

https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/refreshSchedule

Refer: Microsoft

In the body you can specify your schedule. I use this in a python script to set my schedules automatically. As body I use:

 {"value": 
    {"days":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
     "times": ["05:00"],
     "enabled": 'true',
     "localTimeZoneId": "UTC"
  }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM