具有Blob存储的Azure功能.如何创建BlobTrigger到子文件夹? [英] Azure Functions with blob storage. How to create a BlobTrigger to a sub-folder?

查看:110
本文介绍了具有Blob存储的Azure功能.如何创建BlobTrigger到子文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对添加到子文件夹中的Blob做出反应.我知道Blob存储无法识别文件夹,它们只是虚拟的,但是我仍然不知道如果将文件添加到子文件夹中,如何创建Blob触发器.

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.

示例:

摘录自function.json: { "name": "myblob", "type": "blobTrigger", "direction": "in", "path": "rootContainer/{name}" }

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

好的,一个函数被触发了,我收到了斑点

OK, a function is triggered and I receive the blob

摘录自function.json: { "name": "subfolder/myblob", "type": "blobTrigger", "direction": "in", "path": "rootContainer/{name}" } 或者 { "name": "myblob", "type": "blobTrigger", "direction": "in", "path": "rootContainer/subfolder/{name}" }

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}" }

不好,没有触发功能

关于此问题的问题并不多,并且仍然无法提供正常的答案.在文档中也找不到任何信息.

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.

谢谢!

推荐答案

简而言之,"path": "rootcontainer/subfolder/{name}"应该可以工作.

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

功能门户上的日志"面板可能无法及时显示日志,您可以转到https://{functionappname}.scm.azurewebsites.net/DebugConsole,然后导航到D:\home\LogFiles\Application\Functions\function\yourblobtriggername以查看日志文件.

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.

如果在功能代码中使用blob名称,则path应包含{name},否则由于运行时异常,功能将无法运行.

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

如果将path设置为mycontainermycontainer/{name}之类的容器,则写入该容器的所有文件(包括上传到虚拟子文件夹的文件)都将触发该功能. 正如您提到的:

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:

当根为rootcontainer时会被触发,并且出现的blob具有以下名称subfolder/{name}

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

如果将其设置为类似于mycontainer/subfolder/{name}的子文件夹,则只有写入该子文件夹的文件才会触发该功能.

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

如果设置为mycontainer/subfolder,则不会像发现的那样触发.

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

随时询问您是否还有其他问题.

Feel free to ask if you have further questions.

这篇关于具有Blob存储的Azure功能.如何创建BlobTrigger到子文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆