2
votes

I wanted to create a console app as a WebJob using .NET Core but the WebJobs SDK is not yet available in .NET Core.

I've been advised to handle the scenario of reading messages from Azure Storage Queue manually. Looks like all the WebJobs SDK does is to keep polling the queue anyway.

Is the following code the basic idea in doing this? It doesn't look very sophisticated but not sure how it can be more sophisticated.

static void Main(string[] args)
{
   var runContinuously = true;
   while (runContinuously)
   {
      ReadAndProcessMessage();
      System.Threading.Thread.Sleep(1000);
   };
}

private static void ReadAndProcessMessage()
{
   // Read message
   ReadMessage();

   // Process message and handle the work
   HandleWork();
}
1

1 Answers

3
votes

That will work. And I like simplicity.

The QueueTriggerAttribute makes use of a random exponential back-off algorithm to help minimize your transaction costs. If you'd like to trace through the logic of how this is accomplished, starting with the QueueListener class is a good way to go. Clone the project and then hop over to the RandomizedExponentialBackoffStrategy class.