gpt4 book ai didi

本地开发时未创建 Azure Functions 表绑定(bind)

转载 作者:行者123 更新时间:2023-12-03 01:39:55 24 4
gpt4 key购买 nike

我正在尝试使用与 Azure Function V2(节点)绑定(bind)的输出表。

我已将表绑定(bind)添加到 function.json,如 documentation 中所述。 .

{
"tableName": "Person",
"connection": "MyStorageConnectionAppSetting",
"name": "tableBinding",
"type": "table",
"direction": "out"
}

然后我尝试再次使用 documentation 中描述的示例将一些内容插入到该表中。 .

for (var i = 1; i < 10; i++) {
context.bindings.tableBinding.push({
PartitionKey: "Test",
RowKey: i.toString(),
Name: "Name " + i
});
}

为了确认 - 我还在 local.settings.json 中添加了一个名为 MyStorageConnectionAppSetting 的设置,并使用有效的存储帐户连接字符串作为其值。

遗憾的是,这失败了,我看到以下错误 -

System.Private.CoreLib: Exception while executing function: Functions.config. System.Private.CoreLib: Result: Failure
Exception: TypeError: Cannot read property 'push' of undefined

似乎绑定(bind)对象没有按预期创建,但我不知道为什么。

Microsoft.Azure.WebJobs.Extensions.Storage包含在extensions.csproj中,当我调用func start时,Function App启动得很好.

虽然我相信没有与存储帐户发生连接,但我确实尝试在表存在和不存在时运行我的函数。

最佳答案

使用前请确保参数已初始化。输出绑定(bind)未定义,除非已初始化或赋值。

context.bindings.tableBinding = [];

关于本地开发时未创建 Azure Functions 表绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54826852/

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