Forum Discussion
Retrieving scheduled refresh events using the Power BI API
Hi,
We have a requirement to identify failed refreshes in the Power BI service programtically so that we can setup alerts.
I'm using the following PowerShell code:
Ok thanks, i'll give that a go this week and accept the solution if it works.
12 Replies
- andrewsommerSuper User
Using the PBI REST API for model refreshed try this:
# First, authenticate Connect-PowerBIServiceAccount # Get all workspaces $workspaces = Get-PowerBIWorkspace -All foreach ($ws in $workspaces) { $datasets = Get-PowerBIDataset -WorkspaceId $ws.Id foreach ($ds in $datasets) { $refreshes = Invoke-PowerBIRestMethod -Url "groups/$($ws.Id)/datasets/$($ds.Id)/refreshes" -Method Get | ConvertFrom-Json foreach ($r in $refreshes.value) { if ($r.status -eq "Failed") { Write-Host "FAILED REFRESH FOUND:" Write-Host " Workspace: $($ws.Name)" Write-Host " Dataset: $($ds.Name)" Write-Host " Refresh Type: $($r.refreshType)" Write-Host " Start Time: $($r.startTime)" Write-Host " End Time: $($r.endTime)" Write-Host " Service Exception: $($r.serviceExceptionJson)" } } } }For dataflows you can use this:
GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/dataflows/{dataflowId}/refreshesPlease mark this post as solution if it helps you. Appreciate Kudos.
- SamRobinson120Helper I
Hi,
Yes I've seen that you can obtain the refresh history for each dataset. The issue is we already have over 1200 workspaces with several datasets that have auto-refresh switched on. I am looking for a solution that doesn't require us to loop through every workspaces and dataset as it can be slow. Activity events seems to get us close, I just don't understand why scheduled refreshes aren't included in the response.
Regards
- DekuSuper User
If you have Log Analytics Intergration setup you can look at the command event for the refresh and get the status (succeeded/failed)
- AnonymousNot applicable
Hi SamRobinson120,
Thank you for reaching out to the Microsoft Fabric Forum Community.
Also, a big thanks to Deku and andrewsommer for the prompt and helpful response.
For this scenario, Log Analytics Integration is the most effective solution.
Steps to Implement:
1. Enable Log Analytics Integration, Make sure your workspaces are assigned to Power BI Premium or Fabric Capacity. Connect Power BI to Log Analytics through the Admin Portal.2. Use Kusto Query to Detect Refresh Failures.
3. Set Up Alerts in Azure, Create an Alert Rule based on the query. Configure notifications via Email, Microsoft Teams, Logic Apps, etc.
If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.
Thank you & regards,
Prasanna Kumar- SamRobinson120Helper I
Ok thanks, i'll give that a go this week and accept the solution if it works.
- AnonymousNot applicable
Hi SamRobinson120,
Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.
If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful — this will benefit others in the community as well.
Best regards,
Prasanna Kumar
- SamRobinson120Helper I
Hi, we're still looking into this at the moment. Can you confirm which of the event categories listed here show failed scheduled refresh events?
- AnonymousNot applicable
Hi SamRobinson120,
Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.
If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful — this will benefit others in the community as well.
Best regards,
Prasanna Kumar
- SamRobinson120Helper I
Hi Prasanna,
We've delayed this work now until a later date so I can't confirm it's an accepted solution at this point.
Regards
Sam
- AnonymousNot applicable
Hi SamRobinson120,
Just a gentle reminder has your issue been resolved? If so, we’d be grateful if you could mark the solution that worked as Accepted Solution, or feel free to share your own if you found a different fix.
This not only closes the loop on your query but also helps others in the community solve similar issues faster.
Thank you for your time and feedback!
Best,
Prasanna Kumar
- SamRobinson120Helper I
Hi,
I've already responded with the below:
We've delayed this work now until a later date so I can't confirm it's an accepted solution at this point.
Regards
Sam
- AnonymousNot applicable
Hi SamRobinson120,
Thank you for getting back to us and for engaging with the Microsoft Fabric Forum Community.
As we haven’t received any further updates and there are no outstanding queries at the moment, we’ll go ahead and close this thread for now. If you have any additional questions in the future, please don’t hesitate to start a new thread we’re always here to help.
Warm regards,
Prasanna Kumar