[英]How to open a blob triggered file using Python in an blob trigger Azure Function
[英]How to trigger an event-triggered function in azure when a blob is create
I created an event-triggered function in Azure (name of the function app: "stamevents", name of the function: "EventGridTrigger1". this is my function.json file:
{
"scriptFile": "__init__.py",
"bindings": [
{
"type": "eventGridTrigger",
"name": "event",
"direction": "in"
}
]
}
这是我的 init.py 文件:
import json
import logging
import azure.functions as func
def main(event: func.EventGridEvent):
result = json.dumps({
'id': event.id,
'data': event.get_json(),
'topic': event.topic,
'subject': event.subject,
'event_type': event.event_type,
})
logging.info('Python EventGrid trigger processed an event: %s', result)
现在,我想在上传 blob 时触发这个 function。 所以我去了我的存储帐户,按下“事件”并选择“Azure 功能”。 并创造。
接下来我选择了我刚刚创建的 function 应用程序和 function
但这就是我所看到的,我不明白接下来要做什么,以及在我上传 blob 后如何让这个 function 着火。
任何帮助将不胜感激!
我已经在我的环境中进行了复制,并且得到了预期的结果。 我遵循了这个解决方法:您可以在使用 azure 函数时使用Microsoft.Storage.BlobCreated ,如下所示:
点击端点类型中的 Azure 功能,然后点击端点如下:
上传如下 Blob:
上传 blob 后,检查事件网格 function 应用程序的日志如下,您将知道它已执行并且事件网格被触发如下:
您可以使用逻辑应用程序在创建 blob 时触发事件,如下所示:
当我上传一个像下面这样的 blob 时,它会运行并触发如下:
现在,当您检查运行历史记录时,它会触发如下:
您可以检查如下:
因此,最后您可以检查我创建的事件,如下所示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.