<small id='R9G3w'></small><noframes id='R9G3w'>

        <bdo id='R9G3w'></bdo><ul id='R9G3w'></ul>

    1. <i id='R9G3w'><tr id='R9G3w'><dt id='R9G3w'><q id='R9G3w'><span id='R9G3w'><b id='R9G3w'><form id='R9G3w'><ins id='R9G3w'></ins><ul id='R9G3w'></ul><sub id='R9G3w'></sub></form><legend id='R9G3w'></legend><bdo id='R9G3w'><pre id='R9G3w'><center id='R9G3w'></center></pre></bdo></b><th id='R9G3w'></th></span></q></dt></tr></i><div id='R9G3w'><tfoot id='R9G3w'></tfoot><dl id='R9G3w'><fieldset id='R9G3w'></fieldset></dl></div>

      1. <legend id='R9G3w'><style id='R9G3w'><dir id='R9G3w'><q id='R9G3w'></q></dir></style></legend>
        <tfoot id='R9G3w'></tfoot>

        在 Async 方法中绑定到输出 blob 时,将 Blob 绑定到 IAsyncCollector 时出错

        时间:2023-10-05

          <i id='pnAFp'><tr id='pnAFp'><dt id='pnAFp'><q id='pnAFp'><span id='pnAFp'><b id='pnAFp'><form id='pnAFp'><ins id='pnAFp'></ins><ul id='pnAFp'></ul><sub id='pnAFp'></sub></form><legend id='pnAFp'></legend><bdo id='pnAFp'><pre id='pnAFp'><center id='pnAFp'></center></pre></bdo></b><th id='pnAFp'></th></span></q></dt></tr></i><div id='pnAFp'><tfoot id='pnAFp'></tfoot><dl id='pnAFp'><fieldset id='pnAFp'></fieldset></dl></div>

            <small id='pnAFp'></small><noframes id='pnAFp'>

              • <tfoot id='pnAFp'></tfoot>
                  <tbody id='pnAFp'></tbody>
              • <legend id='pnAFp'><style id='pnAFp'><dir id='pnAFp'><q id='pnAFp'></q></dir></style></legend>

                  <bdo id='pnAFp'></bdo><ul id='pnAFp'></ul>
                • 本文介绍了在 Async 方法中绑定到输出 blob 时,将 Blob 绑定到 IAsyncCollector 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在这篇文章之后以异步方法绑定到 blob 输出:如何将输出值绑定到我的异步 Azure 函数?

                  I'm trying to bind to a blob output in an Async method following this post: How can I bind output values to my async Azure Function?

                  我有多个输出绑定,所以只返回不是一个选项

                  I have multiple output bindings so just returning is not an option

                  public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, IAsyncCollector<string> collection, TraceWriter log)
                  {
                      if (req.Method == HttpMethod.Post) 
                      {
                          string jsonContent = await req.Content.ReadAsStringAsync();
                  
                          // Save to blob 
                          await collection.AddAsync(jsonContent);
                  
                          return req.CreateResponse(HttpStatusCode.OK);
                      }
                      else 
                      {
                          return req.CreateResponse(HttpStatusCode.BadRequest);
                  
                      }
                  }
                  

                  我对 blob 的绑定是:

                  My binding for the blob is :

                  {
                    "bindings": [
                      {
                        "authLevel": "function",
                        "name": "req",
                        "type": "httpTrigger",
                        "direction": "in"
                      },
                      {
                        "name": "$return",
                        "type": "http",
                        "direction": "out"
                      },
                      {
                        "type": "blob",
                        "name": "collection",
                        "path": "testdata/{rand-guid}.txt",
                        "connection": "test_STORAGE",
                        "direction": "out"
                      }
                    ],
                    "disabled": false
                  }
                  

                  但每当我这样做时,我都会得到以下信息:

                  But whenever I do this I get the following:

                  错误:函数($WebHook)错误:Microsoft.Azure.WebJobs.Host:索引方法错误'Functions.WebHook'.Microsoft.Azure.WebJobs.Host:无法绑定要键入的 Blob'Microsoft.Azure.WebJobs.IAsyncCollector`1[System.String]'

                  Error: Function ($WebHook) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.WebHook'. Microsoft.Azure.WebJobs.Host: Can't bind Blob to type 'Microsoft.Azure.WebJobs.IAsyncCollector`1[System.String]'

                  推荐答案

                  Blob 输出绑定不支持收集器,请参阅此 问题.

                  Collectors are not supported for Blob output bindings, see this issue.

                  对于可变数量的输出 blob(在您的情况下为 0 或 1,但可以是任意数量),您必须使用命令式绑定.从您的 function.json 中删除 collection 绑定,然后执行以下操作:

                  For variable amount of output blobs (0 or 1 in your case, but can be any), you would have to use imperative bindings. Remove collection binding from your function.json and then do this:

                  public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, Binder binder)
                  {
                      if (req.Method == HttpMethod.Post) 
                      {
                          string jsonContent = await req.Content.ReadAsStringAsync();
                  
                          var attributes = new Attribute[]
                          {    
                              new BlobAttribute("testdata/{rand-guid}.txt"),
                              new StorageAccountAttribute("test_STORAGE")
                          };
                  
                          using (var writer = await binder.BindAsync<TextWriter>(attributes))
                          {
                              writer.Write(jsonContent);
                          }
                  
                          return req.CreateResponse(HttpStatusCode.OK);
                      }
                      else 
                      {
                          return req.CreateResponse(HttpStatusCode.BadRequest);    
                      }
                  }
                  

                  这篇关于在 Async 方法中绑定到输出 blob 时,将 Blob 绑定到 IAsyncCollector 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Azure 函数不通知我的机器人(机器人框架) 下一篇:函数监听器无法启动.Azure 函数应用时间触发器

                  相关文章

                  <small id='rJoDN'></small><noframes id='rJoDN'>

                  <tfoot id='rJoDN'></tfoot>
                  <legend id='rJoDN'><style id='rJoDN'><dir id='rJoDN'><q id='rJoDN'></q></dir></style></legend>

                        <bdo id='rJoDN'></bdo><ul id='rJoDN'></ul>
                    1. <i id='rJoDN'><tr id='rJoDN'><dt id='rJoDN'><q id='rJoDN'><span id='rJoDN'><b id='rJoDN'><form id='rJoDN'><ins id='rJoDN'></ins><ul id='rJoDN'></ul><sub id='rJoDN'></sub></form><legend id='rJoDN'></legend><bdo id='rJoDN'><pre id='rJoDN'><center id='rJoDN'></center></pre></bdo></b><th id='rJoDN'></th></span></q></dt></tr></i><div id='rJoDN'><tfoot id='rJoDN'></tfoot><dl id='rJoDN'><fieldset id='rJoDN'></fieldset></dl></div>