Adding an EventHub sample function
This commit is contained in:
Родитель
5645798f87
Коммит
2dadebe182
|
@ -3,7 +3,9 @@
|
|||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Azure.EventHubs;
|
||||
using Microsoft.Azure.WebJobs;
|
||||
using Microsoft.Azure.WebJobs.ServiceBus;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SampleHost.Filters;
|
||||
|
@ -48,5 +50,14 @@ namespace SampleHost
|
|||
|
||||
log.LogInformation($"Message complete (Id={messageId})");
|
||||
}
|
||||
|
||||
public static void ProcessEvents([EventHubTrigger("testhub2", Connection = "TestEventHubConnection")] EventData[] events,
|
||||
ILogger log)
|
||||
{
|
||||
foreach (var evt in events)
|
||||
{
|
||||
log.LogInformation($"Event processed (Offset={evt.SystemProperties.Offset}, SequenceNumber={evt.SystemProperties.SequenceNumber})");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using Microsoft.Azure.WebJobs;
|
||||
using Microsoft.Azure.WebJobs.Logging;
|
||||
using Microsoft.Azure.WebJobs.ServiceBus;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace SampleHost
|
||||
|
@ -22,6 +23,7 @@ namespace SampleHost
|
|||
config.UseDevelopmentSettings();
|
||||
}
|
||||
|
||||
config.UseEventHub();
|
||||
config.UseServiceBus();
|
||||
|
||||
CheckAndEnableAppInsights(config);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.Azure.WebJobs.Extensions.EventHubs\WebJobs.EventHubs.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.Azure.WebJobs.Host\WebJobs.Host.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.Azure.WebJobs.Logging.ApplicationInsights\WebJobs.Logging.ApplicationInsights.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.Azure.WebJobs.ServiceBus\WebJobs.ServiceBus.csproj" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче