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

Azure Python函数无法从Azure IoT Hub事件触发的排查求助

Azure Python函数无法从Azure IoT Hub事件触发的排查求助

我现在遇到个头疼的问题,想请大家帮忙排查下:我有一个Azure IoT Hub,还有一个用Python编写的Azure Function App,目标是让这个函数在IoT Hub收到消息时自动触发执行。

目前IoT Hub是公开可访问的,我已经能成功给它发送消息,而且通过Azure CLI确认了JSON格式的消息 payload 确实被Hub接收到了。

我是通过VS Code的Azure扩展部署的这个函数,我的function.json配置内容如下:

{
    "scriptFile": "__init__.py",
    "bindings": [
        {
            "type": "iotHubTrigger",
            "name": "event",
            "direction": "in",
            "eventHubName": "iothub-ehub-[redacted]-36471244-3e33dca112",
            "connection": "IoTHubConnectionString",
            "cardinality": "one",
            "consumerGroup": "mydevices"
        }
    ]
}

我的Python函数入口(写在__init__.py里)是这样的:

def main(event: func.IoTHubEvent) -> None:
...

另外,我已经在Azure门户的Function App中,通过Settings > Environmental Variables路径设置了环境变量IoTHubConnectionString,其值为Endpoint=sb://ihsuprodlnres017dednamespace.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=[redacted];EntityPath=iothub-ehub-[redacted]-36471244-3e33dca112。

折腾了好一阵子,函数就是没有触发的迹象,而且Function App的日志里完全没有相关记录,我完全摸不着头绪。有没有大佬能告诉我该从哪些方面入手排查这个问题?

备注:内容来源于stack exchange,提问作者gazm2k5

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.13 19:29:34