Saturday, 27 July 2019

azure function input and output

In VS Code if you do make a trigger with an input, then it will setup the input right.

But after than if you want to add another input or output, then VSCode cannot help.

You have to create and setup them on the web portal.

However, on VS Code there is no way to download these setup...  so if you deploy your app from VS code, you will find out these new created input and output are all gone.

so the only way is that after new input output created, then click the function, it will show you the source code of the function, then on the very right of the screen you can click "view files", from here you can see a file called function.json.   then copy the content and past to your local function.json file.

Another 2 things about input output you need to pay attention about are that:

1. You need to in the function.json (the integration setup) the first part of "path" is a container.

"path": "outcontainer/{DateTime}.json",

2. in your function.json, both input and output have "name", this is the parameter name you should use in your code.

input is easy, you are not possible to make mistake because VS code i will generate right code for you.

but output is not.... the sample code in the portal is wrong, so you need to make sure you:

context.bindings.outputBlobxxxxxx = { "hello":"world","ss":"peter" };

outputBlobxxxxxx is the value of "name" in your function.json

"bindings": [
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0,10,20,30,40,50 * * * * *"
"type": "blob",
"name": "outputBlobxxxxxx",
"path": "outcontainer/{DateTime}.json",
"connection": "AzureWebJobsStorage",
"direction": "out"
"scriptFile": "../dist/TimerTriggerPeter/index.js"

about path :

all things about blob:

js developer guide

No comments:

Post a comment