【问题标题】:What is the replacement for Microsoft.Azure.WebHosts.JobHostConfigurationMicrosoft.Azure.WebHosts.JobHostConfiguration 的替代品是什么
【发布时间】:2019-02-22 07:22:31
【问题描述】:

尝试关注 @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 相关,但在不同的上下文中

【问题讨论】:

    标签: c# azure azure-webjobs azure-webjobssdk


    【解决方案1】:

    您应该能够通过 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);
                    })
    

    【讨论】:

    • 您能否提供有关您的配置的更多信息?您使用的是 v3.0.0 还是预发布版?我尝试这个时看不到AddAzureStorageCoreServices
    • 没关系;我能够通过卸载并重新安装 Microsoft.Azure.WebJobs 3.0.0 来使其正常工作。
    • @Aaron 如果我可以确认它有效,我想将此标记为答案,但我无法在 Microsoft.Azure.WebJobs 3.0.0 nuget 包中找到 IWebJobsBuilder.AddAzureStorageCoreServices。您能否指定卸载/重新安装 Microsoft.Azure.WebJobs?
    • @noontz 需要添加Microsoft.Azure.WebJobs.Extensions.Storage nuget包@nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage
    • @noontz 也可以尝试添加包“Microsoft.Azure.WebJobs.Extensions”
    猜你喜欢
    • 2011-05-07
    • 2012-04-24
    • 2019-12-03
    • 2010-09-17
    • 2012-03-27
    • 2012-09-30
    • 2010-10-20
    • 2014-03-12
    • 1970-01-01
    相关资源
    最近更新 更多