gpt4 book ai didi

c# - Microsoft.Azure.WebHosts.JobHostConfiguration 的替代品是什么

转载 作者:行者123 更新时间:2023-11-30 12:20:20 24 4
gpt4 key购买 nike

尝试关注@matthoneycutttutorial on Azure IoT Hub这好像是Microsoft.Azure.WebHosts.JobHostConfiguration 在 3.0.0-beta5 之间消失Microsoft.Azure.WebHosts nuget 包中的 Microsoft.Azure.WebHosts.Host 和 3.0.0-rc1 版本?

在 Microsoft.Azure.WebHosts 3.0.0-rc1 中运行此代码的方法是什么?

var processorHost = new EventProcessorHost(hubName, consumerGroupName, iotHubConnectionString, storageConnectionString,storageContainerName);
processorHost.RegisterEventProcessorAsync<LoggingEventProcessor>().Wait();
var eventHubConfig = new EventHubConfiguration();
eventHubConfig.AddEventProcessorHost(hubName, processorHost);
var configuration = new JobHostConfiguration(storageConnectionString);
configuration.UseEventHub(eventHubConfig);
var host = new JobHost(configuration);
host.RunAndBlock();

似乎与 this post 相关,尽管在不同的上下文中

最佳答案

您应该能够通过 AddEventHubs 扩展方法(在 Microsoft.Azure.WebJobs.Extensions.EventHubs 包中提供)来执行此操作

var builder = new HostBuilder()
.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices()
.AddAzureStorage()
.AddEventHubs(eventHubOptions => {
var hubName = "hubName";
var iotHubConnectionString = "iotHubConnectionString";
var storageContainerName = "storageContainerName";
var storageConnectionString = "storageConnectionString";
var consumerGroupName = "consumerGroupName";

var processorHost = new EventProcessorHost(hubName, consumerGroupName, iotHubConnectionString, storageConnectionString, storageContainerName);
eventHubOptions.AddEventProcessorHost("eventHubName", processorHost);
})

关于c# - Microsoft.Azure.WebHosts.JobHostConfiguration 的替代品是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52383479/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com