【Azure 应用服务】Azure Function Python函数部署到Azure后遇见 Value cannot be null. (Parameter 'receiverConnectionString') 错误

问题描述

使用VS Code创建Python Function,处理Event Hub中的数据。当部署到Azure Function App后,函数无法执行,查看 Function 日志出现 Value cannot be null. (Parameter 'receiverConnectionString') 错误。

错误信息2023-01-04T09:12:06.725 [Error] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.EventHubTrigger1'. Microsoft.Azure.WebJobs.EventHubs: Value cannot be null. (Parameter 'receiverConnectionString').

 

问题解答

这是因为在 function.json 文件中配置的 Event Connection String 方式错误。 不能直接使用Event Hub Namespace Connection String设置在 function.json 文件的 connection 值。 

而是需要通过Function App 的 Application Setting 来设置。 

 

步骤一:在Function App门户中,添加名称为 receiverConnectionString 的配置参数,它的值就是Event Hub的Connection String。

配置结果如图:

 

步骤二:把第一步中的receiverConnectionString 值,配置到function.json中的connection上。修改如下:

复制代码
{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "events",
      "direction": "in",
      "eventHubName": "testmessage2",
      "connection": "receiverConnectionString",
      "cardinality": "many",
      "consumerGroup": "functiongroup"
    }
  ]
}
复制代码

重新发布后, Value cannot be null. (Parameter 'receiverConnectionString')  错误就已经被解决了。

 

参考资料

适用于 Azure Functions 的 Azure 事件中心触发器https://docs.azure.cn/zh-cn/azure-functions/functions-bindings-event-hubs-trigger?tabs=in-process%2Cfunctionsv2%2Cextensionv5&pivots=programming-language-python#connection-string

 

posted @   路边两盏灯  阅读(95)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示