I am new to Azure Functions, and attempting to put them to good use in conjunction with Blob Storage.
I have downloaded Visual Studio 2017 Preview which has given me access to creating an Azure Function project template (https://marketplace.visualstudio.com/items?itemName=AndrewBHall-MSFT.AzureFunctionToolsforVisualStudio2017)
Then following this example https://blogs.msdn.microsoft.com/webdev/2017/05/10/azure-function-tools-for-visual-studio-2017/ I am able to create a new Function in VS, then publish to Azure.
When I then look on Azure, I can see my new Function, but it just shows json from within a function.json
file.
So this works fine when my Function code is just
public static void Run([BlobTrigger("images/{name}",
Connection = "fakename_STORAGE")]Stream myBlob, string name, TraceWriter log)
However, when I want to start playing around with outputs and I change my code to include out string myOutputBlob
public static void Run([BlobTrigger("images/{name}",
Connection = "fakename_STORAGE")]Stream myBlob, string name, out string myOutputBlob, TraceWriter log)
Then Publish to Azure, I see an error:
Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'myOutputBlob' to type String&. Make sure the parameter Type is supported by the binding.
I can get round this buy updating the function.json file on Azure to include additional information,
but every time I publish to Azure, this file is overwritten.
I have tried adding a function.json file to my project which matches the config required, but this does not work. Am I missing something?
How can I ensure the function.json file is not overwritten every time? Do I need to configure my project to allow me to manage the file?
You have to decorate your output parameter with an attribute to configure what kind of output binding you need:
public static void Run(
[BlobTrigger("images/{name}", Connection = "fakename_STORAGE")]Stream myBlob,
string name,
[Blob("images/copy-{name}", Connection = "fakename_STORAGE")]out string myOutputBlob,
TraceWriter log)
which will add the required lines in your function.json
during the publish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With