Using Notebooks or Dataflow to add Pipeline error details to storage

Stephen Connell 21 Reputation points
2021-04-30T07:55:06.437+00:00

Hi. I'm trying to capture error logging in Notebooks or Dataflows in Azure Synapse Workspace.

I have tried a few approaches, passing the string value from the activity as a Dynamic Content.

92809-2021-04-30-08-24-00-azrswsd02-azure-synapse-analyt.png

Raise and Error here simply takes input and uses it for the following method: throw new InvalidOperationException(message); I then use the dynamic content to attempt to store this in storage using the dynamic content. activity('Raise an Error').error.errorCode

The above example is a dataflow but I've tried this with notebooks in pyspark and .Net Spark(C#). I invariably get different errors. The input into my second activity I get it is "ErrorDescription": "'System.InvalidOperationException: File creation\n at Submission#18.<<Initialize>>d__0.MoveNext()\n--- End of stack trace from previous location where exception was thrown ---\n at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsyncTResult'" The errors I get include 1. Pyspark: EOL error 2. .NET Spark: errors similar to "Evalue": "(1,205): error CS1056: Unexpected character '`'\n(1,206): error CS1002: ; expected", 3. Dataflows: Expression cannot be parsed. Details:Parameter stream has parsing errors\nLine 13 Position 17: extraneous input ''' expecting {DECIMAL_LITERAL, HEX_LITERAL, OCT_LITERAL, BINARY_LITERAL, '-', '!', '$', '~', ':', '(', '#', '[', '@(', '[]', FLOAT_LITERAL, HEX_FLOAT_LITERAL, STRING_LITERAL, REGEX_LITERAL, 'parameters', 'functions', 'as', 'input', 'output', 'constant', 'expression', 'integer', 'short', 'long', 'double', 'float', 'decimal', 'boolean', 'timestamp', 'date', 'byte', 'binary', 'integral', 'number', 'fractional', 'any', IDENTIFIER, ANY_IDENTIFIER, META_MATCH, '$$', OPEN_INTERPOLATE}","failureType":"UserError","target":"Data flow1","errorCode":"DF-Executor-ParseError"}

I have tried replace() on the error code and trim() for leading \n\n\n - which works for simple strings but not for actual error messages. I have also tried to convert the error using binary(). In this last case my output is: ErrorDescription": { "value": { "$content-type": "application/octet-stream", "$content": "U3lzdGVtLkludmFsaWRPcGVyYXRpb25FeGNlcHRpb246IEZpbGUgY3JlYXRpb24KICAgYXQgU3VibWlzc2lvbiMxOC48PEluaXRpYWxpemU+PmRfXzAuTW92ZU5leHQoKQotLS0gRW5kIG9mIHN0YWNrIHRyYWNlIGZyb20gcHJldmlvdXMgbG9jYXRpb24gd2hlcmUgZXhjZXB0aW9uIHdhcyB0aHJvd24gLS0tCiAgIGF0IE1pY3Jvc29mdC5Db2RlQW5hbHlzaXMuU2NyaXB0aW5nLlNjcmlwdEV4ZWN1dGlvblN0YXRlLlJ1blN1Ym1pc3Npb25zQXN5bmNbVFJlc3VsdF0oSW1tdXRhYmxlQXJyYXlgMSBwcmVjZWRpbmdFeGVjdXRvcnMsIEZ1bmNgMiBjdXJyZW50RXhlY3V0b3IsIFN0cm9uZ0JveGAxIGV4Y2VwdGlvbkhvbGRlck9wdCwgRnVuY2AyIGNhdGNoRXhjZXB0aW9uT3B0LCBDYW5jZWxsYXRpb25Ub2tlbiBjYW5jZWxsYXRpb25Ub2tlbik=" }, "type": "string" }, This seems promising as I suspect if I can get the $content: portion I suspect I code decode it but can't find any advice on how to handle the resultng System.Collections.Generic.Dictionary`2[System.String,System.Object]. Any suggestions on the approach to take would be helpful. I'm happy to put in the work but just have currently exhausted my ideas.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
{count} votes

1 answer

Sort by: Most helpful
  1. Samara Soucy - MSFT 5,141 Reputation points
    2021-05-11T04:19:25.11+00:00

    I did get this working in python and I have two possible solutions to look at. The problem there is definitely with the line breaks. The issue with a plain replace for /n is that Pipelines sees the string '/n' and the newline character as two different things. There are a couple workarounds for this:

    1. (I tested with this one) is to actually hit enter in the expression view instead of typing '/n'-- @replace(activity('Error').error.message,'<hit the enter key here>', ''). It looks the same when in code view, but it does behave differently behind the scenes.
    2. The officially recommended way to strip special characters is to URL encode the string, strip the characters based on the encoded version, then URL decode the string back to its original form. The one for newline would be '%0A'

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.