I'm working on some automation work for azure activities with powershell, as a part of it we are using queuetrigger functions. But whenever an error occurs the poison queue for those messages is not creating. We are able to log the errors in app-insights using try catch block but we are not able see the poison queue creation for those messages
-
are you handling the error in catch block? or throwing again from catch causing function failure? – Kamesh Jan 20 '21 at 07:05
-
We are catching the error in catch block and loging into App-insights, if that is an issue you think I tried it by removing the try catch block also but no use – Krushna Kumar Jan 20 '21 at 07:08
-
You should let the function fail, it will be moved to poison queue only when it has exhausted the retries and it fails all times. So by default it is moved to poison queue when the function fails for 5 consecutive times for same record in main queue – Kamesh Jan 20 '21 at 07:10
-
Could you please post the error message? – Doris Lv Jan 20 '21 at 07:14
-
I removed the try catch block and it was showing errors in azure logs but I was not able to see poison queue – Krushna Kumar Jan 20 '21 at 07:15
-
We are failing the function by wrong cmdlet name for database storage and it was showing error like inser-sqltable not found check the cmdlet name... Etc like this – Krushna Kumar Jan 20 '21 at 07:28
-
Does it help you? – Harshita Singh Jan 29 '21 at 06:53
1 Answers
Follow below steps and see if you missed out on anything.
Create a queue message handler:
If you fail for some reason to handle message properly (read - you throw exceptions during the handling), runtime will decide at some point to move your message to poison queue. You can read more about this mechanism here. You can of course do
try\catch
option here as well, but then question is what exactly are you going to do insidecatch
to make a retry later? Best option is to just let an exception fly up to the runtime and delegate dequeue on next round.When you fail to handle message properly (there is even a threshold how many times runtime will retry to give you your message for processing before moving to the poison queue):
Please note: The poison queue will be {your-queue-name}-poison
. There should not be any permissions (RBAC) restrictions on your blob storage. If there is, please give your function app appropriate permissions.
Additional information: If you want to handle poison messages, you can go through this step by step guide: Capture Exception in Azure Functions Poison Queue Trigger

- 4,590
- 1
- 10
- 13