azureazure-webappsqueuetrigger

Azure WebJob QueueTrigger execution


I am running multiple simultaneous instances of a QueueTrigger within an Azure webjob. It is a single function, but called multiple times in parallel.

My function uses static variables to cache data that is used multiple times.

Sometimes when the functions get run I have collisions on the static objects that could only be explained by multiple processes trying to access them at the same time, but I was lead to believe that each instance of a queuetrigger runs in isolation.

So my questions are;

Are queuetrigger instances executed in isolation?

If not, is there a specific event that triggers when the "instance" is loaded so that static objects can be loaded?


Solution

  • Figured it out with some experimentation.

    QueueTrigger instances are run as part of the process that the WebJob runs inside, and are not executed in isolation.

    WebJobs automatically shut themselves down if they are not told to stay open and will lose all static data. This can cause confusing behavior, but is by design.