From bb06d859bc63c8fb7f704087f5327074b4430744 Mon Sep 17 00:00:00 2001 From: yaroslavtykhonchuk Date: Wed, 10 Jan 2024 17:01:31 +0200 Subject: [PATCH] Log BlobNotFound exception --- AzureBatchQueue/MessageQueue.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/AzureBatchQueue/MessageQueue.cs b/AzureBatchQueue/MessageQueue.cs index 47eef02..03fddef 100644 --- a/AzureBatchQueue/MessageQueue.cs +++ b/AzureBatchQueue/MessageQueue.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using Azure; using Azure.Storage.Blobs; using Azure.Storage.Blobs.Specialized; using Azure.Storage.Queues; @@ -187,8 +188,16 @@ async Task> ToQueueMessage(QueueMessage m, CancellationToken ct) var payload = m.Body.ToMemory(); if (IsBlobRef(m.Body, out var blobRef)) { - var blobData = await container.GetBlobClient(blobRef!.BlobName).DownloadContentAsync(ct); - payload = blobData.Value.Content.ToMemory(); + try + { + var blobData = await container.GetBlobClient(blobRef!.BlobName).DownloadContentAsync(ct); + payload = blobData.Value.Content.ToMemory(); + } + catch (RequestFailedException ex) when (ex.Status == 404) + { + logger.LogError(ex, "Blob with name {blobRef!.BlobName} is not found for {messageId}", blobRef.BlobName, m.MessageId); + throw; + } } var item = serializer.Deserialize(payload);