3

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!

5
  • The second configuration should work. Make sure you upload to the right folder and your subfolder name is right. Commented Jun 22, 2018 at 1:58
  • 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. Commented Jun 22, 2018 at 1:58
  • 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. Commented Jun 22, 2018 at 9:58
  • @Semuserable Did you run this trigger locally or on portal, which is your runtime version, v1 or v2? Commented Jun 25, 2018 at 2:50
  • I try to run it on a portal, runtime version is ~1. Commented Jun 25, 2018 at 8:06

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, you are right. It's working, but it runs very strangely. Sometimes its instantaneous and other times it takes up to 5 minutes. Can find any correlation, unfortunately.
@Semuserable You probably met cold start in consumption plan, and some reliable research for you to refer.
Thank you for the links! I'll definitely research this behavior in depth.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.