Forum Discussion
Send email notification for Refresh Failure
i am using Azure Data Factory and Logic App, i want to send email notification if semantic model refresh failure happens, what are the steps to perform using logic app? below is the existing workflow available in logic app, i want to add one more step for send notification
Hi powerbiexpert22 ,
You can do this by adding an email action after “Refresh a dataset” and configuring it to run only when the refresh fails.
- Click the + below “Refresh a dataset” and choose Add an action.
- Search for Office 365 Outlook and pick Send an email (V2). Sign in with the account that should send the notification.
- Fill in the recipient, a subject like “Power BI refresh failed”, and a body with whatever details you want. You can use dynamic content here, for example the dataset name or utcNow() for the time.
- Open the three dots (…) on the email action and select Configure run after. Select the “Refresh a dataset” step, uncheck is successful, and check has failed and has timed out. Click Done.
- Save and test. To trigger the failure path, you can temporarily give the refresh step an invalid dataset ID and confirm the email arrives.
One thing to be aware of: the Power BI refresh action only kicks off the refresh request, so in some cases the step shows as successful even if the refresh itself fails a few minutes later. If you need to catch those failures too, a more reliable approach is to add an Until loop that calls the Power BI REST API (GET /groups/{groupId}/datasets/{datasetId}/refreshes) and checks the latest refresh status, then send the email if the status is “Failed”.
Also, if your Logic App is called from an ADF Web activity, you can add a Response action that returns a 500 status on failure so the pipeline is marked as failed as well.
6 Replies
- Ritaf1983
Super User
Hi powerbiexpert22 ,
You can do this by adding an email action after “Refresh a dataset” and configuring it to run only when the refresh fails.
- Click the + below “Refresh a dataset” and choose Add an action.
- Search for Office 365 Outlook and pick Send an email (V2). Sign in with the account that should send the notification.
- Fill in the recipient, a subject like “Power BI refresh failed”, and a body with whatever details you want. You can use dynamic content here, for example the dataset name or utcNow() for the time.
- Open the three dots (…) on the email action and select Configure run after. Select the “Refresh a dataset” step, uncheck is successful, and check has failed and has timed out. Click Done.
- Save and test. To trigger the failure path, you can temporarily give the refresh step an invalid dataset ID and confirm the email arrives.
One thing to be aware of: the Power BI refresh action only kicks off the refresh request, so in some cases the step shows as successful even if the refresh itself fails a few minutes later. If you need to catch those failures too, a more reliable approach is to add an Until loop that calls the Power BI REST API (GET /groups/{groupId}/datasets/{datasetId}/refreshes) and checks the latest refresh status, then send the email if the status is “Failed”.
Also, if your Logic App is called from an ADF Web activity, you can add a Response action that returns a 500 status on failure so the pipeline is marked as failed as well.
- powerbiexpert22
Impactful Individual
Thanks Ritaf1983 , i want to apply these steps using service princpial for both refreshing dataset and sending email notification , can you suggest me steps for same
- jubinsoni
Continued Contributor
Hi powerbiexpert22,
To follow up on your service principal question: the built-in "Refresh a dataset" and Office 365 Outlook connectors both run as a signed-in user. To use an SP (or, simpler, the Logic App's managed identity), replace both with plain HTTP actions.
One-time setup
Fabric admin portal -> enable "Service principals can call Fabric public APIs" (scope it to a security group that contains the SP / MI) workspace -> Manage access -> add the SP / MI as Contributor Entra app (or MI) -> Microsoft Graph application permission Mail.Send -> admin consent -> limit it to one mailbox with an Exchange application access policy1. Trigger the refresh (HTTP action, authentication = Managed identity, or Active Directory OAuth with the SP's client ID/secret):
{ "method": "POST", "uri": "https://api.powerbi.com/v1.0/myorg/groups/<workspaceId>/datasets/<datasetId>/refreshes", "body": { "type": "full", "retryCount": 1 }, "authentication": { "type": "ManagedServiceIdentity", "audience": "https://analysis.windows.net/powerbi/api" } }2. Wait for the real result. The POST returns 202 as soon as the refresh is queued, which is why "succeeded" can still mean a failed refresh. Add an Until loop with a 1-minute Delay that GETs the latest refresh:
GET .../datasets/<datasetId>/refreshes?$top=1 (same auth) Until: status is not "Unknown" ("Unknown" = still running) then Condition: status equals "Failed" -> send the email@body('Get_refresh')?['value'][0]['status'] @body('Get_refresh')?['value'][0]['serviceExceptionJson']3. Send the email as the app through Graph (HTTP action, audience https://graph.microsoft.com):
POST https://graph.microsoft.com/v1.0/users/[email protected]/sendMail { "message": { "subject": "Semantic model refresh failed", "body": { "contentType": "Text", "content": "@{body('Get_refresh')?['value'][0]['serviceExceptionJson']}" }, "toRecipients": [ { "emailAddress": { "address": "[email protected]" } } ] } }So my overall approach would be:
managed identity / SP -> workspace Contributor + Graph Mail.Send -> HTTP POST refreshes -> Until loop on GET refreshes?$top=1 -> status Failed -> Graph sendMail with serviceExceptionJson -> Response 500 so the ADF Web activity is marked failed tooAI-assisted drafting: AI was used to help structure and phrase this response. I reviewed and validated the technical content before posting.
- maruthisp
Super User
Hi powerbiexpert22,
Just a thought here, why can't you add the USER's email address in the "Refresh" settings on the Semantic Model in Power BI Service?
By adding user's email address, Power Bi will send an email with any errors related to Semantic Model refresh failures.
You can see in the below image, "These Contacts" --> add all the users email addresses.Best Regards,
Maruthi
LinkedIn - http://www.linkedin.com/in/maruthi-siva-prasad/
X - Maruthi Siva Prasad - (@MaruthiSP) / X- RossEdwardsRio
Resolver I
The reason is because that only works for scheduled refreshes. OP is calling a refresh via API. One of the difficulties of API refresh is that the source generally doesn't get a pass/fail message.
Fabric Pipelines offering that ability was a game changer for me.
For documentation to show it only emails on scheduled refreshes:
Data refresh in Power BI - Power BI | Microsoft Learn.
From the note in the section 'Getting Refresh Failure Notifications': "NoteOn-demand refreshes and refreshes triggered programmatically such as through Power Automate don't trigger email notifications."
- RossEdwardsRio
Resolver I
I would recommend using a Fabric Pipeline for this. So instead of having your Datafactory call for the refresh directly, get it to call the Fabric Pipeline: Invoke pipeline activity - Microsoft Fabric | Microsoft Learn
A fabric pipeline can organise the refresh, handle multiple refreshes if there is a failure (retry) and can also have refreshes in serial (incase you have a source like a dataflow that needs a refresh first).
The pipeline can detect if the dataset failed to refresh after the nominated number of retries and then can have a node that sends your required email.