Azure WebJob BlobTrigger-输出Blob使触发器不触发

时间:2019-08-23 15:13:59

标签: c# azure-functions azure-storage-blobs azure-webjobs

当我的函数方法签名如下时,我有一个v3 WebJob成功触发:

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

但是,当我添加输出blob 时,BlobTrigger永远不会触发。

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

我要遵循的文档在这里:https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob#output

1 个答案:

答案 0 :(得分:0)

如果要使用Azure WebJob BlobTrigger并使用输出绑定,可以按照我的步骤进行。

在我这方面,它工作正常。

1。创建一个控制台应用程序并安装所需的所有内容。您可以遵循此doc。这将告诉您如何使用WebJob SDK。

这是我的代码:

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"
}

您会发现我已经在blobtrigger中添加了输出绑定,只需遵循您输入的doc。我将图像上传到图像容器,控制台显示登录信息,图像也已上传到表单容器。

事情在我这边起作用,如果您还有其他问题,请显示更多详细信息。希望我的回答能对您有所帮助。