使用EventHub的WebJob的任何示例吗? [英] Any Example of WebJob using EventHub?
问题描述
我尝试从WebJobsSDK gitHub中的示例中提出一些建议
var eventHubConfig = new EventHubConfiguration();
string eventHubName = "MyHubName";
eventHubConfig.AddSender(eventHubName,"Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=SendRule;SharedAccessKey=xxxxxxxx");
eventHubConfig.AddReceiver(eventHubName, "Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=ReceiveRule;SharedAccessKey=yyyyyyy");
config.UseEventHub(eventHubConfig);
JobHost host = new JobHost(config);
但是,对于我有限的技能"来说,这恐怕还远远不够!
-
我找不到具有UseEventHub属性的JobHostConfiguration实例(使用Microsoft.AzureWebJobs软件包的v1.2.0-alpha-10291版本),因此无法将EventHubConfiguration传递给JobHost./p>
-
我以前使用过EventHub,而不是在WebJob上下文中使用过.如果使用WebJob触发器,我是否仍不需要EventHostProcessor ...还是WebJob触发器本质上充当EventHostProcessor?
无论如何,如果有人拥有像我这样的简单人的更完整的例子,那将是非常美好的!谢谢
从文档 I've tried to come up with something from the example in the WebJobsSDK gitHub But I'm afraid that's not far enough for someone of my limited "skillset"! I can find no instance of JobHostConfiguration that has a UseEventHub property (using the v1.2.0-alpha-10291 version of the Microsoft.AzureWebJobs package), so I can't pass the EventHubConfiguration to the JobHost. I've used EventHub before, not within the WebJob context. I don't see if the EventHostProcessor is still required if using the WebJob triggering...or does the WebJob trigger essentially act as the EventHostProcessor? Anyway, if anyone has a more complete example for a simpleton like me that would be really sweet! Thanks From the documentation here, you should have all the information you need. What you are missing is a reference of the The Otherwise your configuration seems ok.
Here is an example on how to receive or send messages from/to an EventHub:
这篇关于使用EventHub的WebJob的任何示例吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!var eventHubConfig = new EventHubConfiguration();
string eventHubName = "MyHubName";
eventHubConfig.AddSender(eventHubName,"Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=SendRule;SharedAccessKey=xxxxxxxx");
eventHubConfig.AddReceiver(eventHubName, "Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=ReceiveRule;SharedAccessKey=yyyyyyy");
config.UseEventHub(eventHubConfig);
JobHost host = new JobHost(config);
Microsoft.Azure.WebJobs.ServiceBus.1.2.0-alpha-10291
nuget package.UseEventHub
is an extension method that is declared in this package.public class BasicTest
{
public class Payload
{
public int Counter { get; set; }
}
public static void SendEvents([EventHub("MyHubName")] out Payload x)
{
x = new Payload { Counter = 100 };
}
public static void Trigger(
[EventHubTrigger("MyHubName")] Payload x,
[EventHub("MyHubName")] out Payload y)
{
x.Counter++;
y = x;
}
}