How can I handle exception in Azure Logic App - azure

I'm using Azure Logic App. This is the architecture:
I have a Scope Insert Row that include an insert statement in database.
I would like to send via mail the message of the exception of the insertion.
For example if the Insert statement failed with Foreign key exception, i would like to send this message.
How can I refer to this error message inside the 'Send error Msg' feature?
Thanks a lot guys :)

You could set the Configure run after value to implement it. Set the Send an email action run after Insert row has failed.
If the Insert action success, the send mail won't execute and if it fails the send mail would work. You could also add the run after action value like the time out or is skipped, they are all kind of exceptions.
UPDATE: If this is your error message, you could add it with #{body('Insert_row')?['message']} in code view mode.
And here is my error message and the subject setting.

You can make use of Filter Array and result function to capture the actual error of an action failed in a Scope.
For more insights with example see following article - How can I handle exception in Azure Logic App
Thanks,
Maheshkumar Tiwari
TechFindings...by Maheshkumar Tiwari

Related

Send email notification failure Azure data factory Pipeline not working (Web Job)

I have a pipeline where the following activities takes place
Lookup-> Lookup ->ForEach->(Stored Procedure)-> Send Success Email/ Send Failure Email
Once the pipeline successfully completed its execution, I see a successful email in my inbox, however for any reason the foreach activity fails I don't see a Failure Email.
Inside Foreach Stored procedure might get executed dynamically sometimes based on N number of times.
Inside foreach I have only one activity (Stored Procedure execution).
This is the configuration for Email Failure message, I do try to pull the dynamic error message, so I have added a code as "ErrorMessage":"#{activity('Lookup').output.message}", It shows me
Error.Message is not a property, Moreover I wanted to get a Failure email
Configuration for Success Email, works perfectly fine
I have achieved the above task by modifying my pipeline with
Lookup->Lookup->ForEach(Stored Procedure -> If Condition-> WaitTrue/WaitFalse -> WebJob to send email which I have added to a separate pipeline)
Under if condition activity checking for Error status from previous activity
#contains(activity('Load Tables').Status,'Succeeded')
In case of Failure, the status would be Error and catching the message as
"errorMessage":"#{activity('Load Tables').Error.message}"

How do I register 400 errors in Azure Function Apps as failures in Application Insights?

I want to treat 4xx HTTP responses from a function app (e.g. a 400 response after sending a HTTP request to my function app) as failures in application insights. The function app is being called by another service I control so a 4xx response probably means an implementation error and so I'd like to capture that to ultimately run an alert on it (so I can get an email instead of checking into Azure everytime).
If possible, I'd like it to appear here:
If not, are there any alternative approaches that might fit my use case?
Unless an unhandled exception occurs the function runtime will mark the invocation as succesful, whether the status code is actually denoting an error or not. Since this behavior is defined by the runtime there are 2 things you can do: throw an exception in the code of the function and/or remove exception handling so the invocation is marked as not succesful.
Since you ultimately want to create an alert, you better alert on this specific http status code using a "Custom log search" alert
requests
| where toint(resultCode) >= 400

The remote server returned an error: (404) Not Found While deleting message from queue

We are using Azure Queue for our printing job but when deleting message from queue by queue.DeleteMessage(message), the method throws below exception.
The remote server returned an error: (404) Not Found
Above exception was handled but still looking for workaround.
Can anyone please suggest how to fix it.
Thanks,
Sneh
According to this article, we can find that:
After a client retrieves a message with the Get Messages operation,
the client is expected to process and delete the message. To delete
the message, you must have two items of data returned in the response
body of the Get Messages operation:
The message ID, an opaque GUID value that identifies the message in the queue.
A valid pop receipt, an opaque value that indicates that the message has been retrieved.
If a message with a matching pop receipt is not found, the service returns error code 404 (Not Found). And Pop receipts remain valid until one of the following events occurs:
The message has expired.
The message has been deleted using the last pop receipt received
either from Get Messages or Update Message.
The invisibility timeout has elapsed and the message has been
dequeued by a Get Messages request. When the invisibility timeout
elapses, the message becomes visible again. If it is retrieved by
another Get Messages request, the returned pop receipt can be used
to delete or update the message.
The message has been updated with a new visibility timeout. When the
message is updated, a new pop receipt will be returned.
I ran into this issue today and the root cause was ownership issues between two different queues. We had setup two queues, one to hold our message awaiting processing and one for messages that had errored out. The problem came with the logic of how the message was moved between queues.
If our processing failed, we would perform the following logic:
_errorQueue.AddMessage(msg);
_queue.DeleteMessage(msg);
The DeleteMessage would also return a (404) Not Found because the msg had been moved to the errorQueue. There were two solutions that I found to this issue:
1. Switch Logic
If you switch the logic than the msg will be deleted before being added to the errorQueue which will avoid the ownership swap.
_queue.DeleteMessage(msg);
_errorQueue.AddMessage(msg);
2. Insert Copy of Message
Solution #1 has the potential to lose the message if something happens between deletion and insertion (small chance but a chance nonetheless). The solution I went with inserted a copy of the msg with the same payload so it didn't run into this ownership issue because it was a different object.
_errorQueue.AddMessage(new CloudQueueMessage(msg.AsString));
_queue.DeleteMessage(msg);
Debugging Tip
One useful tip I encountered while debugging it making sure the exception your catching isn't the default Exception. Catch the StorageException instead to get access to Azure Storage related error information.
try
{
_queue.DeleteMessage(msg);
}
catch (StorageException ex) //use this instead of base Exception
{
var info = ex.RequestInformation; //has useful information
}
If can provide more information to help you debug your real issue.

Azure Data Factory - Use GetRunRecord(runid) to get complete Error Details

I just tried running a first data copy job inside Azure Data Factory - it failed almost immediately, and displays the message:
Failed Execution: Error message too large to be returned. Use
GetRunRecord(runid) to get complete Error Details.
Can someone tell me where exactly I'm supposed to use this GetRunRecord command? Googling this error brought me exactly one relevant result, and it was no help.
Thanks.
do you have a RunID in your error messages which you could pass to GetRunRecord(runid)?
if yes, you might try the API call described here and pass in the RunID: https://learn.microsoft.com/en-us/rest/api/datafactory/data-factory-slice-run#save-run-log

SoapHttpClientProtocol automatically retry after exception?

I am just curious about this. I am making a change in this project, that is using NetSuite web service, and sometimes it throws a SoapException at random, "Only one request may be made against a session at a time".
private NetSuiteService _service;
SessionResponse response = _service.login(passport); //if SoapException, retries??
Status status = response.status;
Reference.cs:
public partial class NetSuiteService :
System.Web.Services.Protocols.SoapHttpClientProtocol
My question is: If I am in debug mode, I trace this, and I hit F5, and it seems to automatically retry after exception is thrown (the code keeps running, with no try catch block implemented, no while loop) until successful (status.isSuccess == true). When I run it in release mode, as a windows service, the log shows it stops running after exception is thrown.
How is this possible? Is it better to catch this exception in a try catch block and retry?
NS Server refuses a request if its already processing one from the same user.
If you want to make sure that your request succeeds than you have to catch this exception and retry.
This was not the experience I had. We thought this related to netsuite sessions but turned out to be nothing to do with that at all and in fact was not even hitting netsuite (according to netsuite log)​​. Turned out we were trying to execute too many commands in a single request and it totally refused to send it to netsuite. Never seen this error before, may be it is a new thing with the new version!

Resources