gpt4 book ai didi

c# - 如何从 Azure 函数中的声明性绑定(bind)引用 {rand-guid} 值?

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

我有一个 C# 脚本 Azure 函数,并且正在将一个 blob 绑定(bind)为 function.json 中的输出:

"bindings": [
...
{
"type": "blob",
"name": "eventOutputBlob",
"path": "event-receiver-queue-container/{rand-guid}",
"connection": "DomBlobStorage",
"direction": "out"
}
],
"disabled": false
}

我无法弄清楚如何在 run.csx 代码中引用 {rand-guid} 参数,以便我可以将其存储在队列中以供以后处理。这可能吗?

这不起作用,但符合我希望在 run.csx 中得到的内容:

public static async Task<HttpResponseMessage> Run(
HttpRequestMessage req,
string rand-guid,
Stream eventOutputBlob,
TraceWriter log) {
...
}

最佳答案

事实证明,执行此操作的方法是更改​​方法签名以绑定(bind)到 CloudBlockBlob 而不是 Stream:

public static async Task Run(
HttpRequestMessage req,
<s>string rand-guid,</s>
<s>Stream eventOutputBlob,</s> CloudBlockBlob queueOutputBlob,
TraceWriter log) {
...
}

并根据此修改 function.json 以包含 inout Github issue :

"bindings": [
...
{
"type": "blob",
"name": "eventOutputBlob",
"path": "event-receiver-queue-container/{rand-guid}",
"connection": "DomBlobStorage",
<s>"direction": "out"</s> "direction": "inout"
}
],
"disabled": false
}

现在我可以调用 queueOutputBlob.Name 来获取 blob 的名称,在本例中等于 {rand-guid}

关于c# - 如何从 Azure 函数中的声明性绑定(bind)引用 {rand-guid} 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52172941/

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