Azure Functions with blob storage. How to create a BlobTrigger to a sub-folder?

大城市里の小女人 提交于 2019-12-23 17:19:01

问题


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:


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.



来源:https://stackoverflow.com/questions/50976715/azure-functions-with-blob-storage-how-to-create-a-blobtrigger-to-a-sub-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!