public TestFixture() { string connection = Environment.GetEnvironmentVariable("AzureWebJobsTestHubConnection"); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); var host = new HostBuilder() .ConfigureDefaultTestHost <EventHubTestJobs>(b => { b.AddAzureStorage() .AddEventHubs(); }) .ConfigureServices(services => { services.AddSingleton <EventHubConfiguration>(serviceProvider => { var configuration = serviceProvider.GetRequiredService <IConfiguration>(); var eventHubConfig = new EventHubConfiguration(configuration); eventHubConfig.AddSender(TestHubName, connection); eventHubConfig.AddReceiver(TestHubName, connection); return(eventHubConfig); }); }) .Build(); Host = host.GetJobHost(); Host.StartAsync().GetAwaiter().GetResult(); }
public void EntityPathInConnectionString(string expectedPathName, string connectionString) { EventHubConfiguration config = new EventHubConfiguration(); // Test sender config.AddSender("k1", connectionString); var client = config.GetEventHubClient("k1", null); Assert.Equal(expectedPathName, client.Path); }
public override Collection <Attribute> GetAttributes() { Collection <Attribute> attributes = new Collection <Attribute>(); string eventHubName = Context.GetMetadataValue <string>("path"); if (!string.IsNullOrEmpty(eventHubName)) { eventHubName = _nameResolver.ResolveWholeString(eventHubName); } string connectionString = Context.GetMetadataValue <string>("connection"); if (!string.IsNullOrEmpty(connectionString)) { connectionString = _nameResolver.Resolve(connectionString); } if (Context.IsTrigger) { var attribute = new EventHubTriggerAttribute(eventHubName); string consumerGroup = Context.GetMetadataValue <string>("consumerGroup"); if (consumerGroup != null) { consumerGroup = _nameResolver.ResolveWholeString(consumerGroup); attribute.ConsumerGroup = consumerGroup; } attributes.Add(attribute); _eventHubConfiguration.AddReceiver(eventHubName, connectionString); } else { attributes.Add(new EventHubAttribute(eventHubName)); _eventHubConfiguration.AddSender(eventHubName, connectionString); } return(attributes); }
public TestFixture() { var config = new JobHostConfiguration() { TypeLocator = new FakeTypeLocator(typeof(EventHubTestJobs)) }; var eventHubConfig = new EventHubConfiguration(); string connection = Environment.GetEnvironmentVariable("AzureWebJobsTestHubConnection"); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); eventHubConfig.AddSender(TestHubName, connection); eventHubConfig.AddReceiver(TestHubName, connection); connection = Environment.GetEnvironmentVariable(TestHub2Connection); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); config.UseEventHub(eventHubConfig); Host = new JobHost(config); Host.StartAsync().GetAwaiter().GetResult(); }
public EventHubEndToEndTests() { var config = new JobHostConfiguration() { TypeLocator = new FakeTypeLocator(typeof(EventHubTestJobs)) }; var eventHubConfig = new EventHubConfiguration(); string connection = Environment.GetEnvironmentVariable("AzureWebJobsTestHubConnection"); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); eventHubConfig.AddSender(TestHubName, connection); eventHubConfig.AddReceiver(TestHubName, connection); connection = Environment.GetEnvironmentVariable(TestHub2Connection); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); config.UseEventHub(eventHubConfig); _host = new JobHost(config); EventHubTestJobs.Result = null; }
// Please set the following connection strings in app.config for this WebJob to run: // AzureWebJobsDashboard and AzureWebJobsStorage static void Main() { var config = new JobHostConfiguration(); if (config.IsDevelopment) { config.UseDevelopmentSettings(); } var eventHubConfig = new EventHubConfiguration(); string eventHubName = "log"; eventHubConfig.AddSender(eventHubName, "Endpoint=sb://pocabus.servicebus.cloudapi.de/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=/Soixr306N0ZHlI0d/2agJ6zXSShQ5D/FzHVCSGtIyU="); eventHubConfig.AddReceiver(eventHubName, "Endpoint=sb://pocabus.servicebus.cloudapi.de/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=/Soixr306N0ZHlI0d/2agJ6zXSShQ5D/FzHVCSGtIyU="); config.UseEventHub(eventHubConfig); var host = new JobHost(config); // The following code ensures that the WebJob will be running continuously host.RunAndBlock(); }