【发布时间】:2020-07-02 02:24:22
【问题描述】:
我正在尝试使用计时器触发的 azure 函数从 azure eventthub 获取事件。在本地机器上运行时,我可以使用简单的 nodejs 代码成功获取事件。但是,如果我通过 node js azure 函数执行相同的代码,它就不起作用。我收到以下错误消息。有什么我想念的吗?
TypeError: EventHubConsumerClient is not a constructor' Stack: TypeError: EventHubConsumerClient is not a constructor at Object.<anonymous>
下面是示例代码
const { ContainerClient } = require("@azure/storage-blob");
const { BlobCheckpointStore } = require("@azure/eventhubs-checkpointstore-blob");
const connectionString = "Endpoint=xxxx";
const eventHubName = "yyyy";
const consumerGroup = "default";
const storageConnectionString = "abcd";
const containerName = "eventhubcontainer";
module.exports = async function (context, myTimer) {
const containerClient = new ContainerClient(storageConnectionString, containerName);
const checkpointStore = new BlobCheckpointStore(containerClient);
const consumerClient = new EventHubConsumerClient(consumerGroup, connectionString, eventHubName, checkpointStore);
}
请帮忙
【问题讨论】:
标签: javascript node.js azure azure-functions azure-eventhub