1

I have an Azure WebJob which has a similar code inside:

public class Functions
{
    public static void GenerateImagesForViewer(
    [QueueTrigger("resize-images-queue")] BlobInformation blobInfo,
    [Blob("unprocessed-pdf-storage-container/{BlobName}", FileAccess.Read)] Stream input,
    [Blob("unprocessed-pdf-storage-container/{BlobNameWithoutExtention}-pdf.jpg")] CloudBlockBlob outputPdf)
    {            
        //Do something here
        string connectionString = "myConnectionString";
        TopicClient Client = 
        TopicClient.CreateFromConnectionString(connectionString, "resize- 
        images-topic");
        var topicMessage = new BrokeredMessage(blobInfo);
        Client.Send(topicMessage);
    }

    public static void GenerateImagesForViewerW80(
    [ServiceBusTrigger("resize-images-topic", "SizeW80")] BlobInformation blobInfo,
    [Blob("unprocessed-pdf-storage-container/{BlobNameWithoutExtention}-pdf.jpg", FileAccess.Read)] Stream input,
    [Blob("processed-image-storage-container/{BlobNameWithoutExtention}-h0-w80.jpg")] CloudBlockBlob outputBlob_0_80)
    {
      // It never comes here
      //Do something here
    }
}

After uploading data (BlobInformation object) to my Queue there is no problem triggering the first method (GenerateImagesForViewer). But when I try to send data (BlobInformation object) to the topic it never triggers any of the subscribers(GenerateImagesForViewerW80). Is there something wrong in the code, or there is a required configuration in Azure?

IvanD
  • 107
  • 2
  • 11

1 Answers1

1

In Program.cs, config.UseServiceBus(); is necessary for usage of ServiceBus trigger. We won't see warning if there are other trigger or bindings in Functions, like your case.

See code sample below and check official guidance for more details.

        var config = new JobHostConfiguration();

        if (config.IsDevelopment)
        {
            config.UseDevelopmentSettings();
        }
        config.UseServiceBus();
        var host = new JobHost(config);
        host.RunAndBlock();

Besides, I see some suspicious blank in your input and output blob path. If it's the same as your original code, just remove them otherwise the trigger won't execute code related to blob operation correctly.

Jerry Liu
  • 15,636
  • 2
  • 27
  • 45
  • I fixed the suspicious blanks in the parameters it was a typo here. And I added the `config.UseServiceBus();` in the `Program.cs` but so far nothing has changed. Any other suggestions? – IvanD Nov 06 '18 at 06:55
  • @IvanD Do you add `config.UseServiceBus();` before `host.RunAndBlock();`? – Jerry Liu Nov 06 '18 at 07:06
  • This is how my code in the `Program.cs` looks like: `public static void Main() { JobHostConfiguration config = new JobHostConfiguration(); config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(15); config.UseServiceBus(); var host = new JobHost(); host.RunAndBlock(); }` – IvanD Nov 06 '18 at 07:16
  • @IvanD Gotcha, when we initialize JobHost, the config should be passed as constructor parameter. My mistake, should have posted the complete sample earlier. – Jerry Liu Nov 06 '18 at 07:29
  • That was the issue. Thanks a lot for the help! Amazing!! – IvanD Nov 06 '18 at 07:37