【问题标题】:Azure Function in ASE not triggred when receiving a message in an event hub在事件中心接收消息时未触发 ASE 中的 Azure 函数
【发布时间】:2023-03-05 12:21:01
【问题描述】:

我们正在尝试在独立应用服务计划中的应用服务环境中部署 Azure 函数。 每次我们在事件中心收到消息时都应触发此 Azure 函数。 不幸的是,即使我们尝试了不同的网络配置,它似乎也不起作用:

  1. 事件中心命名空间中网络部分的授权 ASE 子网
  2. 白名单子网 IP 范围和 ASE 出站 IP 地址。
  3. 并允许受信任的 Microsoft 服务。

能否请您帮助我们调试这种情况,以了解为什么我们的 Azure Function 没有被触发。

【问题讨论】:

  • “ASE 中的 Azure 函数未触发...”、“Azure 函数已触发...”:现在怎么办?而且“它似乎不起作用”没有帮助。请具体说明您期望发生什么以及会发生什么。提供您观察到的确切行为的详细信息,包括错误消息、日志输出等。
  • 我的意思是我们的 Azure Function 是基于 Event Hub 事件接收触发的
  • 我已经编辑了帖子以使其清晰
  • 您能否检查是否确实有消息发送到事件中心?客户有时会非常关注消费者方面,而错过了首先检查生产者问题。
  • 是的,我使用事件中心资源管理器完成了

标签: azure azure-functions azure-eventhub azure-app-service-envrmnt app-service-environment


【解决方案1】:

以下是创建在 EventHub 中生成事件时触发的函数应用程序的步骤,尝试检查这些步骤并在代码中进行必要的更改以执行您的要求。

在您的local.settings.json 文件 z 中添加以下代码

{

"IsEncrypted": false,

"Values": {

"FUNCTIONS_WORKER_RUNTIME": "python",

"AzureWebJobsStorage": [Paste the Storage account connection string which is linked with your Azure function that you have Created on Azure Portal],

"FUNCTIONS_EXTENSION_VERSION": "~2",

"receiverConnectionString": [Paste the Endpoint Connection String of the EventHubNamespace here in double quotes and remove these brackets.],

"MyStorageConnectionString": [Paste the Endpoint Connection String of the blob storage account here in double quotes and remove these brackets.]

},

"ConnectionStrings": {}

}

下面是将azure函数与EventHub绑定的代码,这样当EventHub中产生任何事件时,它会自动触发消息。

{

"scriptFile": "__init__.py",

"bindings": [{

"type": "eventHubTrigger",

"name": "events",

"direction": "in",

"eventHubName": [Enter the name of your event hub in double quotes and remove these brackets.],

"connection": "receiverConnectionString",

"cardinality": "many","consumerGroup": "$Default",

"dataType": "binary"

},


{
"name": "outputblob",
       
"type": "blob", 
      
"path": [Enter the path of the folder where you want to store the data in double quotes and remove these brackets.], 
      
"connection": "MyStorageConnectionString",
       
"direction": "out"

}]

}

完整信息请查看Azure Functions and EventHub。

另外,请查看这些 SO 线程以获取相关信息。 SO1、SO2 和这些Microsoft Q&A

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-06
    • 2017-10-07
    • 1970-01-01
    • 2021-04-16
    • 1970-01-01
    • 1970-01-01
    • 2021-07-17
    相关资源
    最近更新 更多