You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Python Azure BlobTrigger函数中读取路径变量与绑定数据

如何在Python Azure BlobTrigger函数中读取路径中的{email}变量?

要获取路径里的{email}变量,只需把它作为参数添加到main函数的参数列表中,Azure Functions会自动将匹配到的路径值注入到这个参数里。

修改后的代码示例:

function.json(无需修改,保持原配置即可)

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "myBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "folder1/{email}/{filename}",
      "connection": "..."
    }
  ]
}

init.py(添加email参数并直接使用)

import logging
import azure.functions as func

def main(myBlob: func.InputStream, email: str):
    logging.info(f"Email: {email}")

原理很直接:function.json中path里定义的占位符(比如{email})会自动映射到同名的函数参数上,你可以直接在代码中调用这个参数获取对应的值。

内容的提问来源于stack exchange,提问作者Mikeon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 22:12:04