3
votes

I need to react to a blob that's added into a sub-folder. I know that blob storage doesn't recognize the folders, they are just virtual, but I still can't figure out how to create a blob trigger if files are added to sub-folders.

Example:

Excerpt from function.json: { "name": "myblob", "type": "blobTrigger", "direction": "in", "path": "rootContainer/{name}" }

OK, a function is triggered and I receive the blob

Excerpt from function.json: { "name": "subfolder/myblob", "type": "blobTrigger", "direction": "in", "path": "rootContainer/{name}" } or { "name": "myblob", "type": "blobTrigger", "direction": "in", "path": "rootContainer/subfolder/{name}" }

NOT OK, a function isn't triggered

There are not many questions regarding this problem and they still don't provide a normal answer. Can't find any info in documentation either.

Thanks!

1
The second configuration should work. Make sure you upload to the right folder and your subfolder name is right.Jerry Liu
Per my test, if we use "path": "rootContainer/subfolder/{name}", it works fine, this is my result screenshot, I find there is no connection in your function.json, may it caused by this? But you said it works with rootContainer/{name}, it is strange, I recommend you to change a storage account or explorer to try again.Joy Wang-MSFT
Yes, I omitted connection for brevity. I noticed that it's fired when a root is rootContainer, and blob which comes has the following name subfolder/{name}. It isn't fired for path being rootContainer/subfolder.Semuserable
@Semuserable Did you run this trigger locally or on portal, which is your runtime version, v1 or v2?Jerry Liu
I try to run it on a portal, runtime version is ~1.Semuserable

1 Answers

3
votes

Shortly speaking, "path": "rootcontainer/subfolder/{name}" should work.

Logs panel on function portal may not show logs in time, you can go to https://{functionappname}.scm.azurewebsites.net/DebugConsole, then navigate to D:\home\LogFiles\Application\Functions\function\yourblobtriggername to see log files.

If you use blob name in your function code, path should include {name}, otherwise function won't run due to runtime exception.

If you set path as a container like mycontainer or mycontainer/{name}, all files written to this container(including those uploaded to virtual subfolder) will trigger the function. As you have mentioned:

it's fired when a root is rootcontainer, and blob which comes has the following name subfolder/{name}

If you set it as a subfolder like mycontainer/subfolder/{name}, only files written to this subfolder will trigger the function.

If set to mycontainer/subfolder, not triggered as you have found.

Feel free to ask if you have further questions.