我試圖通過使用Azure函數將文件保存到FTP。 JSON的是這樣的:Azure函數錯誤 - 無法將參數綁定到字符串
{
"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}");
}
我得到的錯誤是這樣的:
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.).
如果我更換{文件夾}與文件夾命名作品:
"path": "psm/ps-{DateTime}.txt"
爲什麼?是否無法更改代碼的路徑?
它的工作原理! :)你在哪裏閱讀過這些東西......我沒有在文檔中看到它......或者我錯過了它...... –
@AlexAlbu添加了一個鏈接到我的答案。這不是很詳細,但有一個例子。 – Mikhail