<legend id='WymCb'><style id='WymCb'><dir id='WymCb'><q id='WymCb'></q></dir></style></legend>

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

      1. <small id='WymCb'></small><noframes id='WymCb'>

        <tfoot id='WymCb'></tfoot>
        • <bdo id='WymCb'></bdo><ul id='WymCb'></ul>

        Azure Functions 错误 - 无法将参数绑定到字符串类型

        Azure Functions error - Cannot bind parameter to type String(Azure Functions 错误 - 无法将参数绑定到字符串类型)
          <legend id='IQYKu'><style id='IQYKu'><dir id='IQYKu'><q id='IQYKu'></q></dir></style></legend>

            <tbody id='IQYKu'></tbody>

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

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

                  本文介绍了Azure Functions 错误 - 无法将参数绑定到字符串类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 Azure 函数将文件保存到 FTP.json是这样的:

                  I am trying to save files to FTP by using an Azure Function. The json is this:

                  {
                        "type": "apiHubFile",
                        "name": "outputFile",
                        "path": "{folder}/ps-{DateTime}.txt",
                        "connection": "ftp_FTP",
                        "direction": "out"
                  }
                  

                  功能代码是这样的:

                  public static void Run(string myEventHubMessage, TraceWriter log, string folder, out string outputFile)
                  {
                      var model = JsonConvert.DeserializeObject<PalmSenseMeasurementInput>(myEventHubMessage);
                  
                      folder = model.FtpFolderName;
                  
                      outputFile = $"{model.Date.ToString("dd.MM.yyyy hh:mm:ss")};{model.Concentration};{model.Temperature};{model.ErrorMessage}";
                  
                  
                      log.Info($"C# Event Hub trigger Save-to-ftp function saved to FTP: {myEventHubMessage}");
                  
                  }
                  

                  我得到的错误是这样的:

                  The error I get is this:

                  函数 ($SaveToFtp) 错误:Microsoft.Azure.WebJobs.Host:错误索引方法'Functions.SaveToFtp'.Microsoft.Azure.WebJobs.Host:无法将参数文件夹"绑定到字符串类型.确定参数绑定支持类型.如果您使用绑定扩展(例如 ServiceBus、Timers 等)确保您已调用启动代码中扩展的注册方法(例如config.UseServiceBus()、config.UseTimers() 等).

                  Function ($SaveToFtp) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.SaveToFtp'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'folder' 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.).

                  如果我将 {folder} 替换为文件夹名称,它会起作用:

                  If I replace {folder} with a folder name it works:

                  "path": "psm/ps-{DateTime}.txt"
                  

                  为什么?难道不能从代码中改变路径吗?

                  Why? Is it not possible to change the path from the code?

                  推荐答案

                  文件夹是你的函数的输入参数,它不会影响输出绑定.

                  folder is an input parameter of your function, it can't affect the ouput binding.

                  {folder} 语法的意思是运行时会尝试在您的输入项中找到 folder 属性,并绑定到它.

                  What {folder} syntax means is that the runtime will try to find folder property in your input item, and bind to it.

                  因此请尝试以下方法:

                  public static void Run(PalmSenseMeasurementInput model, out string outputFile)
                  {
                      outputFile = $"{model.Date.ToString("dd.MM.yyyy hh:mm:ss")};{model.Concentration};{model.Temperature};{model.ErrorMessage}";
                  }
                  

                  带有function.json:

                  {
                        "type": "apiHubFile",
                        "name": "outputFile",
                        "path": "{FtpFolderName}/ps-{DateTime}.txt",
                        "connection": "ftp_FTP",
                        "direction": "out"
                  }
                  

                  您可以阅读更多这里,在绑定表达式和模式"和绑定到绑定表达式中的自定义输入属性"部分.

                  You can read more here, in "Binding expressions and patterns" and "Bind to custom input properties in a binding expression" sections.

                  这篇关于Azure Functions 错误 - 无法将参数绑定到字符串类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 是否相等(按值,而不是按引用)?)

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

                1. <i id='eB8Yc'><tr id='eB8Yc'><dt id='eB8Yc'><q id='eB8Yc'><span id='eB8Yc'><b id='eB8Yc'><form id='eB8Yc'><ins id='eB8Yc'></ins><ul id='eB8Yc'></ul><sub id='eB8Yc'></sub></form><legend id='eB8Yc'></legend><bdo id='eB8Yc'><pre id='eB8Yc'><center id='eB8Yc'></center></pre></bdo></b><th id='eB8Yc'></th></span></q></dt></tr></i><div id='eB8Yc'><tfoot id='eB8Yc'></tfoot><dl id='eB8Yc'><fieldset id='eB8Yc'></fieldset></dl></div>
                2. <legend id='eB8Yc'><style id='eB8Yc'><dir id='eB8Yc'><q id='eB8Yc'></q></dir></style></legend>
                      • <bdo id='eB8Yc'></bdo><ul id='eB8Yc'></ul>
                            <tbody id='eB8Yc'></tbody>
                          <tfoot id='eB8Yc'></tfoot>