如何使用队列触发器Azure功能创建Blob输出绑定

问题描述 投票:0回答:1

将Blob名称传递到Azure功能时,在向Queue添加消息时无法触发

不工作

#r "Newtonsoft.Json"
using System;
using Newtonsoft.Json;

public static void Run(string myQueueItem, 
 Stream outputBlob, 
ILogger log)
{
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
    dynamic data = JsonConvert.DeserializeObject(myQueueItem);
    log.LogInformation($"We got a new Queue Request Type: {data.MessageType}");
    if(data.MessageType == "Create Blob")
    {
        //  outputBlob = data.Message;
    }
    // outputBlob = "";
    string blobFileName = "tettet.script";
}

工作

我希望创建文件作为队列消息包含在正文部分。

还需要从队列对象中分配Blob文件名作为参数。(uploadedscript / {blobFileName})

blob azure-functions azure-blob-storage
1个回答
0
投票

使用以下代码:

using System;

public static void Run(string myQueueItem,out string outputBlob,ILogger log)
{
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");

    outputBlob=myQueueItem;
}

而function.json:

{
  "bindings": [
    {
      "name": "myQueueItem",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "queue",
      "connection": "AzureWebJobsStorage"
    },
    {
      "type": "blob",
      "name": "outputBlob",
      "path": "container/{queueTrigger}",
      "connection": "AzureWebJobsStorage",
      "direction": "out"
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.