Is it possible to create alerts off of posion queue? I have a blob trigger function but when it fails x
number of times, it throws this message onto the poison queue. What I am trying to do is create an alert when that poison queue has a count of x
.
- I can do this with a sidecart approach, where I have an independant service that monitors poison queues
- Saw this approach https://stackoverflow.com/a/46334184/1134076
- Was hoping to use the
blobproperties
override to store somemetadata
so I can keep track of failures but there doesn't seem to be a way to do this? I was thinking on on the final attempt track an event to statemoving message to poison queue
Is there a better way of doing this?
[FunctionName("MyFunction")]
public async Task Run(
[BlobTrigger("input-queue", Connection = "ConnectionString")] Stream blobContent,
string name,
System.Uri uri,
IDictionary<string, string> metaData,
BlobProperties properties,
ILogger log)
EDIT Noticed this overload for function:
[FunctionName("MyFunction")]
public async Task Run(
[BlobTrigger("input-queue", Connection = "ConnectionString")] ICloudBlob blobContent,
string name,
System.Uri uri,
IDictionary<string, string> metaData,
BlobProperties properties,
ILogger log)
{
if (!blobContent.Metadata.ContainsKey("mycount"))
{
blobContent.Metadata["mycount"] = "1";
await blobContent.SetMetadataAsync();
}
else
{
var value = int.Parse(blobContent.Metadata["mycount"]);
value++;
blobContent.Metadata["mycount"] = value.ToString();
await blobContent.SetMetadataAsync();
}
throw new Exception(("Testing Function"));
}
Seems overkill but I can track failure count here and write logic to track custom events.