简体   繁体   中英

Azure WebJob BlobTrigger - Output Blob makes trigger not fire

I have a v3 WebJob that successfully fires when my function method signature is as follows:

  public static void ProcessQueueMessage( [BlobTrigger("process/{name}", Connection = "storage-connection")] Stream blob, ILogger log ) 

However when I add an output blob the BlobTrigger never fires.

 public static void ProcessQueueMessage( [BlobTrigger("process/{name}", Connection = "storage-connection")] Stream blob, [Blob("output/{name}", FileAccess.Write, Connection = "storage-connection")] Stream processedBlob, ILogger log ) 

The documentation I'm following is here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob#output

If you want to use Azure WebJob BlobTrigger and also use a Output binding, you can follow my steps.

In my side, it works fine.

1.create a console app and install everything needed. You can follow by this doc . This will tell you how to use the WebJob SDK.

This is my code:

Functions.cs:

using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using System.IO;

namespace ConsoleApp1
{
    public class Functions
    {
        public static void ProcessQueueMessage(
            [BlobTrigger("images/{name}")]Stream myBlob, 
            [Blob("form/{name}", FileAccess.Write)] Stream imageSmall, 
            string name, 
            ILogger log
            )
        {
            log.LogInformation("webjobs blob trigger works!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        }
    }
}

Program.cs:

using System;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var builder = new HostBuilder();
            builder.ConfigureWebJobs(b =>
            {
                b.AddAzureStorage();
                b.AddAzureStorageCoreServices();
            });
            builder.ConfigureLogging((context, b) =>
            {
                b.AddConsole();
            });

            builder.ConfigureWebJobs(b =>
            {
                b.AddAzureStorageCoreServices();
                b.AddAzureStorage();
            });

            var host = builder.Build();
            using (host)
            {
                host.Run();
            }
        }
    }
}

appsettings.json:

{  
  "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=bowmanimagestorage02;AccountKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSAHfYi1d2yc+BU3NG9hkbGEPU/lJP5wtqYZ3pdDq1lGEkdUx7w==;EndpointSuffix=core.windows.net"
}

You can find that I have already add the output binding in the blobtrigger, Just follow the doc you give. I upload a image to the images container and the console show the loginformation, the image also been upload to the form container.

Things works in my side, if you have more questions, please show more details. I hope my answer can give you some help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM