Azure WebJobs QueueTrigger not starting

I am trying to find what I am doing wrong with regard to the Azure WebJobs QueueTrigger method, which should start from the Azure storage queue.

I read several documents (as in msdn blogs / posts). But I still do not understand.

The main question / misunderstood aspect:

What should be the name of the connection string for the Azure Storage Console App.config application or Windows Azure Configuration (portal). So far I have the following name in both places.

  • AzureJobsStorage
  • AzureWebJobsStorage
  • AzureJobsRuntime
  • AzureJobsDashboard
  • AzureJobsData li>

Here is my WebJobs console application code.

static void Main() { JobHost host = new JobHost(); host.RunAndBlock(); } public static void CreateLeague([QueueTrigger("temp")] string msg) { var task = JsonConvert.DeserializeObject<QueueTask>(msg); if (task.TaskType == QueueTask.TaskTypes.Pdf) RenderPdf(task.Id); } 

This console application is constantly running on my Azure website.

I can access my debug page, where I can switch the output, and I can see that it is running / running.

My code for adding a queue (from my ASP.NET MVC application):

 CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]); CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); CloudQueue queue = queueClient.GetQueueReference("temp"); queue.CreateIfNotExists(); Common.QueueTask task = new Common.QueueTask(); task.TaskType = Common.QueueTask.TaskTypes.Pdf; task.Id = p.Id; CloudQueueMessage msg = new CloudQueueMessage(JsonConvert.SerializeObject(task) ); queue.AddMessage(msg); 

This code executes and the queue is added to my vault account. But they did not get a "dequeue" or read from WebJobs.

+5
source share
3 answers

Hmm, the WebJobs class must be publicly available.

 using Microsoft.Azure.WebJobs; using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.Blob; using Newtonsoft.Json; using Proceed.Common; using System; using System.Configuration; using System.IO; public class WebJobsTask { public static void Main() { JobHost host = new JobHost(); host.RunAndBlock(); } public static void CreateLeague([QueueTrigger("temp")] string msg) { var task = JsonConvert.DeserializeObject<QueueTask>(msg); if (task.TaskType == QueueTask.TaskTypes.Pdf) RenderPdf(task.Id); } } 

Also found a quick way to examine my queues: https://azurestorageexplorer.codeplex.com/ .

+19
source

In my case, I assumed that QueueTrigger was referring to service bus queues instead of Azure Queues , and I really needed to use ServiceBusTrigger .

+13
source
  • You can use the server explorer in VS to examine the contents of the storage queues.
  • Queue triggers for the WebJobs SDK will exponentially fall back if there is no work. There may be a delay between when the message is placed in the queue and when it is picked up. You can configure maximum returns using the JobHostConfiguration.Queues.MaxPollingInterval property.
  • For the latest SDK, you will need two lines of storage connection AzureWebJobsStorage and AzureWebJobsDashboard

This is a great place to get additional resources: https://docs.microsoft.com/en-us/azure/app-service-web/websites-webjobs-resources

0
source

Source: https://habr.com/ru/post/1204845/


All Articles