gpt4 book ai didi

azure - 如何通过绑定(bind)到 Blob 存储的 Azure 事件网格触发 Azure 函数

转载 作者:行者123 更新时间:2023-12-03 01:45:20 25 4
gpt4 key购买 nike

尝试重制 Azure Grid Image Resize使用 Visual Studio 的 C# 示例,但在使 Azure 函数触发器由事件网格触发并绑定(bind)到 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"
}

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

预期的function.json:

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

最佳答案

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

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

关于azure - 如何通过绑定(bind)到 Blob 存储的 Azure 事件网格触发 Azure 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47591879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com