EventProcessorHost没有在web api中监听azure服务器

时间:2018-03-31 09:03:32

标签: azure azureservicebus azure-eventhub azure-eventhub-capture

我使用EventProcessorHost来监听azure事件中心。我已经使用事件中心配置在RegisterEventProcessorAsync的类中创建了一个异步方法。并在我的Startup.cs类中使用此async方法。它在本地工作正常,但在Azure上部署它不起作用。 这是我的注册事件中心和startup.cs类的方法。

    public static class ProcesssRTS
{
    private static string EhConnectionString =""
    private static string EhEntityPath =""
    private static string StorageContainerName =""
    private static string StorageAccountName =""
    private static string StorageAccountKey =""

    private static readonly string StorageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", StorageAccountName, StorageAccountKey);

    public static async Task MainAsync()
    {
        Console.WriteLine("Registering EventProcessor...");

        var eventProcessorHost = new EventProcessorHost(
            EhEntityPath,
            PartitionReceiver.DefaultConsumerGroupName,
            EhConnectionString,
            StorageConnectionString,
            StorageContainerName);

        await eventProcessorHost.RegisterEventProcessorAsync<RTSEventProcessor>();

        Console.WriteLine("Receiving. Press ENTER to stop worker.");
        Console.ReadLine();
        await eventProcessorHost.UnregisterEventProcessorAsync();
    }
}

 public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ProcesssRTS.MainAsync();
        app.Map("/signalr", map =>
        {
            map.UseCors(CorsOptions.AllowAll);
            var hubConfiguration = new HubConfiguration { };
            map.RunSignalR(hubConfiguration);
        });

    }
}

0 个答案:

没有答案