<tfoot id='KCrDk'></tfoot>
      <bdo id='KCrDk'></bdo><ul id='KCrDk'></ul>
  • <legend id='KCrDk'><style id='KCrDk'><dir id='KCrDk'><q id='KCrDk'></q></dir></style></legend>

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

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

        ApiHubFile Azure 函数绑定的动态输出文件名(一个驱动器,投递箱等)

        Dynamic output file name of ApiHubFile Azure Function binding (one drive, drop box etc)(ApiHubFile Azure 函数绑定的动态输出文件名(一个驱动器,投递箱等))

          <tfoot id='z7g1j'></tfoot>
            <bdo id='z7g1j'></bdo><ul id='z7g1j'></ul>
          • <legend id='z7g1j'><style id='z7g1j'><dir id='z7g1j'><q id='z7g1j'></q></dir></style></legend>
            <i id='z7g1j'><tr id='z7g1j'><dt id='z7g1j'><q id='z7g1j'><span id='z7g1j'><b id='z7g1j'><form id='z7g1j'><ins id='z7g1j'></ins><ul id='z7g1j'></ul><sub id='z7g1j'></sub></form><legend id='z7g1j'></legend><bdo id='z7g1j'><pre id='z7g1j'><center id='z7g1j'></center></pre></bdo></b><th id='z7g1j'></th></span></q></dt></tr></i><div id='z7g1j'><tfoot id='z7g1j'></tfoot><dl id='z7g1j'><fieldset id='z7g1j'></fieldset></dl></div>
          • <small id='z7g1j'></small><noframes id='z7g1j'>

              <tbody id='z7g1j'></tbody>

                1. 本文介绍了ApiHubFile Azure 函数绑定的动态输出文件名(一个驱动器,投递箱等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个带有计时器触发器的 Azure 函数,然后我想生成一个具有动态(在运行时定义)名称和内容的文件并将其保存到例如OneDrive.

                  I have an Azure Function with Timer Trigger, and then I want to generate a file with dynamic (defined in runtime) name and contents and save it to e.g. OneDrive.

                  我的功能码:

                  public static void Run(TimerInfo myTimer, out string filename, out string content)
                  {
                      filename = $"{DateTime.Now}.txt";
                      content = $"Generated at {DateTime.Now} by Azure Functions";    
                  }
                  

                  还有function.json:

                  {
                    "bindings": [
                      {
                        "name": "myTimer",
                        "type": "timerTrigger",
                        "direction": "in",
                        "schedule": "0 */5 * * * *"
                      },
                      {
                        "type": "apiHubFile",
                        "name": "content",
                        "path": "{filename}",
                        "connection": "onedrive_ONEDRIVE",
                        "direction": "out"
                      }
                    ],
                    "disabled": false
                  }
                  

                  虽然失败了,但

                  Error indexing method 'Functions.TimerTriggerCSharp1'. Microsoft.Azure.WebJobs.Host: 
                  Cannot bind parameter 'filename' to type String&. Make sure the parameter Type 
                  is supported by the binding. If you're using binding extensions 
                  (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method 
                  for the extension(s) in your startup code (e.g. config.UseServiceBus(), 
                  config.UseTimers(), etc.).
                  

                  推荐答案

                  你可以这样做:

                  #r "Microsoft.Azure.WebJobs.Extensions.ApiHub"
                  
                  using System;
                  using System.IO;
                  using Microsoft.Azure.WebJobs;
                  using Microsoft.Azure.WebJobs.Host.Bindings.Runtime;
                  
                  public static async Task Run(TimerInfo myTimer, TraceWriter log, Binder binder)
                  {
                      log.Info($"C# Timer trigger function executed at: {DateTime.Now}");    
                  
                      var fileName = "mypath/" + DateTime.Now.ToString("yyyy-MM-ddThh-mm-ss") + ".txt";
                  
                      var attributes = new Attribute[]
                      {    
                          new ApiHubFileAttribute("onedrive_ONEDRIVE", fileName, FileAccess.Write)
                      };
                  
                  
                      var writer = await binder.BindAsync<TextWriter>(attributes);
                      var content = $"Generated at {DateTime.Now} by Azure Functions"; 
                  
                      writer.Write(content);
                  }
                  

                  还有function.json文件:

                      {
                    "bindings": [
                      {
                        "name": "myTimer",
                        "type": "timerTrigger",
                        "direction": "in",
                        "schedule": "10 * * * * *"
                      },
                      {
                        "type": "apiHubFile",
                        "name": "outputFile",
                        "connection": "onedrive_ONEDRIVE",
                        "direction": "out"
                      }
                    ],
                    "disabled": false
                  }
                  

                  您实际上并不需要 function.json 中的 apiHubFile 声明,但由于我今天注意到的一个错误,它应该仍然存在.我们会修复这个错误.

                  You shouldn't really need the apiHubFile declaration in your function.json but because of a bug I noticed today it should still be there. we will fix that bug.

                  这篇关于ApiHubFile Azure 函数绑定的动态输出文件名(一个驱动器,投递箱等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  HashSet conversion to List(HashSet 转换为 List)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)
                    • <bdo id='FcAYU'></bdo><ul id='FcAYU'></ul>
                        1. <small id='FcAYU'></small><noframes id='FcAYU'>

                            <tbody id='FcAYU'></tbody>
                          <legend id='FcAYU'><style id='FcAYU'><dir id='FcAYU'><q id='FcAYU'></q></dir></style></legend>
                        2. <tfoot id='FcAYU'></tfoot>

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