gpt4 book ai didi

c# - Azure Functions 绑定(bind)不起作用

转载 作者:行者123 更新时间:2023-12-03 05:53:23 25 4
gpt4 key购买 nike

我收到此错误:

Microsoft.Azure.WebJobs.Host: Only the 'Read' FileAccess mode is supported for blob container bindings.

根据docs ,应该支持out吗?

我最初尝试在方法定义中添加Attributes。但是,我遇到了同样的错误,因此我删除了方法定义中的所有属性,因此新的方法定义是:

public static async Task RunAsync(CloudBlockBlob myBlob,  string name, 
IAsyncCollector<ProfilePictureUrl> client, CloudBlockBlob resizedBlob, TraceWriter log)

这是我的 function.json

{
"bindings": [
{
"type": "blobTrigger",
"path": "profile-pictures/{name}",
"direction": "in",
"name": "myBlob"
},
{
"type": "documentDB",
"databaseName": "TestDB",
"collectionName": "ResizedProfilePictures",
"createIfNotExists": true,
"direction": "out",
"name": "client"
},
{
"type": "blob",
"path": "resized-profile-pictures",
"direction": "out",
"name": "resizedBlob"
}
],
"disabled": false,
"scriptFile": "..\\Test.Functions.dll",
"entryPoint": "Test.Functions.ResizeImage.RunAsync"
}

我使用的是 Azure CLI beta 100。如果我从方法定义和 function.json 中删除了 resizedBlob,那么它就可以正常工作。

最佳答案

CloudBlobContainer 必须作为输入绑定(bind)进行绑定(bind)。这是一个有效的示例:

#r "Microsoft.WindowsAzure.Storage"

using Microsoft.WindowsAzure.Storage.Blob;

public static void Run(Stream input, Stream output,
CloudBlobContainer container, TraceWriter log)
{
var blobs = container.ListBlobs();
log.Info($"{blobs.Count()} blobs in container.");
}

以及对应的function.json:

{
"bindings": [
{
"name": "input",
"type": "blobTrigger",
"direction": "in",
"path": "input/{name}",
"connection": "test_STORAGE"
},
{
"name": "container",
"type": "blob",
"direction": "in",
"path": "input",
"connection": "test_STORAGE"
}
]
}

关于c# - Azure Functions 绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44868143/

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