0
votes

I am facing the below issue with Azure Data Factory using Logic App.

I am using the Azure Data Factory pipeline for migration and Logic App for sending "Success & Failure" notification to the technical team. Now success is working fine as the message is hardcoded, but failure is not as the Logic App web activity is not able to parse data factory pipeline error.

Here is the input that is going to Logic App web activity Input

{
"url": "https://xxxxxxxxxxxxxxxxx",
"method": "POST",
"headers": {},
"body": "{\n \"title\": \"PIPELINE RUN FAILED\",\n \"message\":\"Operation on target Migration Validation failed: Execution fail against sql server. Sql error number: 50000. Error Message: The DELETE statement conflicted with the REFERENCE constraint \"FK_cmclientapprovedproducts_cmlinkclientchannel\". The conflict occurred in database \"Core7\", table \"dbo.cmClientApprovedProducts\", column 'linkclientchannelid'.\",\n \"color\": \"Red\",\n \"dataFactoryName\": \"LFC-TO-MCP-ADF\",\n \"pipelineName\": \"LFC TO MCP MIGRATION\",\n \"pipelineRunId\": \"f4f84365-58f0-4da1-aa00-64c3a4daa9e1\",\n \"time\": \"2020-07-31T22:44:01.6477435Z\"\n}"
}

Here is the error logic app is throwing

failures
    {
    "errorCode": "2108",
    "message": "{\"error\":{\"code\":\"InvalidRequestContent\",\"message\":\"The request content is not valid and could not be deserialized: 'After parsing a value an unexpected character was encountered: F. Path 'message', line 3, position 202.'.\"}}",
    "failureType": "UserError",
    "target": "Send Failed Notification",
    "details": []
    }

I have tried various options, like set variable and convert by using various existing methods (string, json, replace etc), but no luck e.g @string(activity('LOS migration').Error.Message) Struggling almost all day this...please suggest if anyone faced a similar issue...

Below is the data flow activity enter image description here

enter image description here

3

3 Answers

1
votes

For the failure case, pass the error output use @{activity('LOS migration').error.message.

For sending email, it doesn't know if it's going to send a failure or success email. We have to adapt the body so the activity can use parameters, which we'll define later:

{
   "DataFactoryName": "@{pipeline().DataFactory}",
   "PipelineName": "@{pipeline().Pipeline}",
   "Subject": "@{pipeline().parameters.Subject}",
   "ErrorMessage": "@{pipeline().parameters.ErrorMessage}",
   "EmailTo": "@pipeline().parameters.EmailTo"
}

We can reference this variables in the body by using the following format: @pipeline().parameters.parametername. For more details, you could refer to this article.

1
votes

now it is working... Pasting body content into the body text field box WITHOUT clicking on 'Add Dynamic Content' in web activity calling Logic App.

0
votes

If you want to use the direct error message of the data factory activity as an input to the logic app email expression, you could try.

"ErrorMessage": "@{string(replace(activity('activity_name').Error.Message, '"',''''))}"

Replace 'activity_name' with your failing activity name.