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

运行Azure Event Hub触发器函数本地报错:unexpected status code: 400

本地运行Azure Event Hub触发器函数时遇到400错误的排查

我在VS Code中本地运行Azure Event Hub触发器的基础模板函数,代码如下:

import logging

import azure.functions as func


def main(event: func.EventHubEvent):
    logging.info('Python EventHub trigger processed an event: %s',
                 event.get_body().decode('utf-8'))

执行时出现unexpected status code: 400错误。本地Functions服务已正常运行,且已确认function.json中的Event Hub实例名称正确:

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "event",
      "direction": "in",
      "eventHubName": "homeeventhub",
      "connection": "",
      "cardinality": "many",
      "consumerGroup": "$Default"
    }
  ]
}

完整错误日志如下:

[2022-11-02T23:14:53.401Z] Executing HTTP request: {
[2022-11-02T23:14:53.403Z]   requestId: "0000-0000-0000-0000-0000",
[2022-11-02T23:14:53.404Z]   method: "GET",
[2022-11-02T23:14:53.406Z]   userAgent: "ms-rest-js/2.6.0 Node/v16.14.2 OS/(x64-Windows_NT-10.0.22000) vscode-azurefunctions/1.8.3",
[2022-11-02T23:14:53.407Z]   uri: "/"
[2022-11-02T23:14:53.408Z] }
[2022-11-02T23:14:53.511Z] Executed HTTP request: {
[2022-11-02T23:14:53.512Z] Executing HTTP request: {
[2022-11-02T23:14:53.514Z]   requestId: "0000-0000-0000-0000-0000",
[2022-11-02T23:14:53.512Z]   requestId: "0000-0000-0000-0000-0000",
[2022-11-02T23:14:53.515Z]   method: "POST",
[2022-11-02T23:14:53.516Z]   identities: "",
[2022-11-02T23:14:53.517Z]   userAgent: "ms-rest-js/2.6.0 Node/v16.14.2 OS/(x64-Windows_NT-10.0.22000) vscode-azurefunctions/1.8.3",
[2022-11-02T23:14:53.518Z]   status: "200",
[2022-11-02T23:14:53.518Z]   uri: "/admin/functions/ehtest2"
[2022-11-02T23:14:53.519Z]   duration: "108"
[2022-11-02T23:14:53.520Z] }
[2022-11-02T23:14:53.520Z] }
[2022-11-02T23:14:53.599Z] Executing StatusCodeResult, setting HTTP status code 400
[2022-11-02T23:14:53.603Z] Executed HTTP request: {
[2022-11-02T23:14:53.604Z]   requestId: "0000-0000-0000-0000-0000",
[2022-11-02T23:14:53.605Z]   identities: "(WebJobsAuthLevel:Admin, WebJobsAuthLevel:Admin)",
[2022-11-02T23:14:53.606Z]   status: "400",
[2022-11-02T23:14:53.606Z]   duration: "91"
[2022-11-02T23:14:53.607Z] }

我认为这是本地配置问题,但不知道还需要排查哪些项。我另有一个HTTP函数可正常本地运行,请问还有哪些配置需要设置?


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.14 08:10:30