How Do I get the Name of The inputBlob That Triggered My Azure Function With Python(如何获取使用 Python 触发我的 Azure 函数的 inputBlob 的名称)
问题描述
我有一个 azure 函数,该函数由放入 blob 存储的文件触发,我想知道如何(如果可能)获取触发该函数的 blob(文件)的名称,我尝试过这样做:
I have an azure function which is triggered by a file being put into blob storage and I was wondering how (if possible) to get the name of the blob (file) which triggered the function, I have tried doing:
fileObject=os.environ['inputBlob']
message = "Python script processed input blob'{0}'".format(fileObject.fileName)
和
fileObject=os.environ['inputBlob']
message = "Python script processed input blob'{0}'".format(fileObject.name)
但这些都不起作用,它们都导致了错误.我可以得到一些帮助或一些建议吗?
but neither of these worked, they both resulted in errors. Can I get some help with this or some suggesstions?
谢谢
推荐答案
可以通过 Function.json 捕获 Blob 名称并作为绑定数据提供.请参阅下面的 {filename} 令牌.Function.json 与语言无关,适用于所有语言.
The blob name can be captured via the Function.json and provided as binding data. See the {filename} token below. Function.json is language agnostic and works in all languages.
请参阅 https://docs 上的文档.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings 了解详情.
{
"bindings": [
{
"name": "image",
"type": "blobTrigger",
"path": "sample-images/{filename}",
"direction": "in",
"connection": "MyStorageConnection"
},
{
"name": "imageSmall",
"type": "blob",
"path": "sample-images-sm/{filename}",
"direction": "out",
"connection": "MyStorageConnection"
}
],
}
这篇关于如何获取使用 Python 触发我的 Azure 函数的 inputBlob 的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何获取使用 Python 触发我的 Azure 函数的 inputBlob 的名称
基础教程推荐
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
