1

尝试使用 Visual Studio 在 c# 中重新制作Azure Grid Image Resize示例,但在使事件网格触发 azure 函数触发器并绑定到 blob 存储时遇到问题。

当前代码:

using Microsoft.Azure.WebJobs.Extensions.EventGrid;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs;
using Microsoft.WindowsAzure.Storage.Blob;

namespace FunctionApp
{
    public static class CreateIndex
    {
        [FunctionName("CreateIndex")]
        [StorageAccount("backup_STORAGE")]
        public static void Run(
            [EventGridTrigger()] EventGridEvent myEvent, 
            [Blob("{data.url}")] CloudBlockBlob inputBlob, 
            TraceWriter log)
        {
            log.Info(myEvent.ToString());
            log.Info(inputBlob.ToString());
        }
    }
}

生成的function.json:

{
  "generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.6",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "eventGridTrigger",
      "name": "myEvent"
    }
  ],
  "disabled": false,
  "scriptFile": "../bin/FunctionApp.dll",
  "entryPoint": "FunctionApp.CreateIndex.Run"
}

绑定适用于事件网格触发器,但不适用于 Blob 输入。

预期的function.json:

{
  "bindings": [
    {
      "type": "EventGridTrigger",
      "name": "myEvent",
      "direction": "in"
    },
    {
      "type": "blob",
      "name": "inputBlob",
      "path": "{data.url}",
      "connection": "myblobstorage_STORAGE",
      "direction": "in"
    }
  ],
  "disabled": false
}
4

1 回答 1

2

预编译函数function.json会为您生成,但它们只在其中放置触发器绑定。您的 blob 绑定不在此文件中,这没关系。

输入 Blob 绑定仍然有效:运行时将根据您的属性选择它。

于 2017-12-01T11:15:41.697 回答