c# - Azure Functions error - Cannot bind parameter to type String -


i trying save files ftp using azure function. json this:

{       "type": "apihubfile",       "name": "outputfile",       "path": "{folder}/ps-{datetime}.txt",       "connection": "ftp_ftp",       "direction": "out" } 

the function code this:

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 ftp: {myeventhubmessage}");  } 

the error this:

function ($savetoftp) error: microsoft.azure.webjobs.host: error indexing method 'functions.savetoftp'. microsoft.azure.webjobs.host: cannot bind parameter 'folder' type string. make sure parameter type supported binding. if you're using binding extensions (e.g. servicebus, timers, etc.) make sure you've called registration method extension(s) in startup code (e.g. config.useservicebus(), config.usetimers(), etc.).

if replace {folder} folder name works:

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

why? not possible change path code?

folder input parameter of function, can't affect ouput binding.

what {folder} syntax means runtime try find folder property in input item, , bind it.

so try following instead:

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}"; } 

with function.json:

{       "type": "apihubfile",       "name": "outputfile",       "path": "{ftpfoldername}/ps-{datetime}.txt",       "connection": "ftp_ftp",       "direction": "out" } 

you can read more here, in "binding expressions , patterns" , "bind custom input properties in binding expression" sections.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -