Azure function app restaring with unexpected error

Esmee Lucassen 5 Reputation points
2025-02-18T15:38:45.04+00:00

I have a function app running. The function app restarts about every 10 minutes with the following exception:
An unhandled exception has occurred. Host is shutting down.

The full exception looks as following:

Full Exception :
 System.ArgumentNullException : Value cannot be null. (Parameter 'key')
    at System.ThrowHelper.ThrowArgumentNullException(String name)
    at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key,TValue& value)
    at Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Listeners.SharedBlobQueueListenerFactory.SharedBlobQueueProcessor.GetPoisonQueue(QueueMessage message)
    at Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Listeners.SharedBlobQueueListenerFactory.SharedBlobQueueProcessor.CopyMessageToPoisonQueueAsync(QueueMessage message,QueueClient poisonQueue,CancellationToken cancellationToken)
    at async Microsoft.Azure.WebJobs.Host.Queues.QueueProcessor.HandlePoisonMessageAsync(QueueMessage message,CancellationToken cancellationToken)
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at async Microsoft.Azure.WebJobs.Host.Queues.QueueProcessor.BeginProcessingMessageAsync(QueueMessage message,CancellationToken cancellationToken)
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at async Microsoft.Azure.WebJobs.Extensions.Storage.Common.Listeners.QueueListener.ProcessMessageAsync(QueueMessage message,TimeSpan visibilityTimeout,CancellationToken cancellationToken)
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,440 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Suwarna S Kale 786 Reputation points
    2025-02-18T16:27:02.64+00:00

    Hello Esmee Lucassen,

    Thank you for posting your question in the Microsoft Q&A forum.

    The exception you're encountering indicates that the function app is failing due to a System.ArgumentNullException in the SharedBlobQueueProcessor class. Specifically, the issue occurs when trying to retrieve a value from a ConcurrentDictionary using a null key. This is causing the function app to restart repeatedly.

    The error suggests that the function app is processing a message from a queue (likely a Storage Queue or Blob Trigger) and encountering a null key when attempting to handle a poison message. Poison messages are messages that fail repeatedly and are moved to a poison queue for further inspection.

    You may need to try inspecting the queue or blob that the function app is processing. Look for messages with missing or null properties that could cause the key parameter to be null. Use tools like Azure Storage Explorer or the Azure Portal to examine the queue messages.

    Try to verify below steps:

    • Add error handling and logging to the function app to catch and log exceptions before they cause the host to shut down.
    • Ensure that the queue or blob trigger is correctly configured in the host.json and local.settings.json files.
    • Check the poison queue for any messages that might be causing the issue.
    • Ensure that the Microsoft.Azure.WebJobs.Extensions.Storage package is up to date
    • Enable Application Insights for the function app to capture detailed logs and exceptions. In the Azure Portal, navigate to your function app, go to Settings > Application Insights, and enable it.
    • Restart the function app to clear any transient issues.
    • Ensure that the storage account used by the function app is properly configured and accessible.

    The issue is likely caused by a malformed message or a misconfiguration in the queue or blob trigger. By inspecting the messages, updating the code, and enabling detailed logging, you should be able to identify and resolve the root cause.

    Some useful links you may refer:

    If the above answer helped, please do not forget to "Accept Answer" as this may help other community members to refer the info if facing a similar issue.

    0 comments No comments

Your answer

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