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

标签 c# asp.net azure azure-functions

我有一个 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/

相关文章:

c# - 数据绑定(bind) : Does not contain a property with then name '(columnName)'

javascript - Telerik asp.net 客户端验证

Azure:联合已被弃用,那么如何实现 'custom sharding' ?

c# - 为什么我的 KendoGrid "update"参数在 Controller 中始终为空?

c# - 如何在自定义 XML 序列化方法中使用默认 XML 序列化

c# - WSDL2REST - 有 C# 版本吗? (将 SOAP 转换为 RESTful Web 服务)

ASP.NET 母版页和 View 状态

c# - Lotus Notes 客户端中的日历项目正在另存为草稿

azure - 单个授权请求中的多个资源

azure - 使用 API 在 Azure AD 中注册应用程序(应用程序注册)?