Skip to content

Repros the TaskCanceledException when reading from a Service Bus Queue from an Azure Function

Notifications You must be signed in to change notification settings

mikelor/TaskCanceledFunctionApp

Repository files navigation

TaskCanceledFunctionApp

Repros the Azure Functions throw TaskCanceledException #5216 when reading from a Service Bus Queue from an Azure Function

This sample writes to a Service Bus Queue via a Timer Trigger and reads from the queue via a Queue Trigger.

Also included is a createResourceGroup.sh shell script that will create the Azure Service Bus to write/read from.

This successfully reproduces the TaskCanceledException for me. See ReadMe for more info. You will need to add your own localsettings.json file to add a reference to the ServiceBusConnectionString generated by the script.

This sample will cause the following Exception to be thrown on every ReadQueueFunction invocation.

Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll: 'A task was canceled.'
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.MetricsEventManager.FunctionActivityTracker.<<-ctor>b__10_0>d.MoveNext() in C:\azure-functions-host\src\WebJobs.Script.WebHost\Diagnostics\MetricsEventManager.cs:line 363

Instructions

  1. az login to your Azure Subscription
  2. Execute .\createResourceGroup.sh to build Azure Resource Group
  3. Update your local.settings.json with the connection string returned from script
  4. Open in Visual Studio and Run

Version Information

Expected Behavior?

Source for MetricsEventManager.cs specifically these lines specifically eat the exception.

Thus, this may be the expected behavior. The exceptions are noted in the debugger, but exection continues, no harm, no foul.

About

Repros the TaskCanceledException when reading from a Service Bus Queue from an Azure Function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published