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 ReceiveTestWebJobs( string path, string connectionString, string storageConnectionString, int expected) { this._received = new int[expected]; this._expected = expected; JobHostConfiguration config = new JobHostConfiguration(); // Disable logging config.DashboardConnectionString = null; var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddReceiver(path, connectionString, storageConnectionString); config.UseEventHub(eventHubConfig); config.TypeLocator = new FakeTypeLocator(typeof(Program)); config.JobActivator = new JobActivator().Add(new Program(this)); var nm = new DictNameResolver(); nm.Add("eh", path); config.NameResolver = nm; //config.UseTimers(); _host = new JobHost(config); }
// 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) { string eventHubName = ConfigurationManager.AppSettings["EventHubName"]; string eventHubEndpoint = ConfigurationManager.AppSettings["EventHubEndpoint"]; config.UseDevelopmentSettings(); EventHubConfiguration hubConfig = new EventHubConfiguration(); hubConfig.AddReceiver(eventHubName, eventHubEndpoint); config.UseEventHub(hubConfig); } var host = new JobHost(config); // The following code ensures that the WebJob will be running continuously host.RunAndBlock(); }
private static JobHostConfiguration Configure() { //TODO: Make all configuration work in the same way across Nether Console.WriteLine("Configuring WebJob (from Environment Variables"); s_webJobDashboardAndStorageConnectionString = ConfigResolver.Resolve("NETHER_WEBJOB_DASHBOARD_AND_STORAGE_CONNECTIONSTRING"); Console.WriteLine($"webJobDashboardAndStorageConnectionString:"); ConsoleEx.WriteConnectionString(s_webJobDashboardAndStorageConnectionString, 4); s_ingestEventHubConnectionString = ConfigResolver.Resolve("NETHER_INGEST_EVENTHUB_CONNECTIONSTRING"); Console.WriteLine($"ingestEventHubConnectionString:"); ConsoleEx.WriteConnectionString(s_ingestEventHubConnectionString, 4); s_ingestEventHubName = ConfigResolver.Resolve("NETHER_INGEST_EVENTHUB_NAME"); Console.WriteLine($"ingestEventHubName:"); Console.WriteLine($" {s_ingestEventHubName}"); s_analyticsStorageConnecitonString = ConfigResolver.Resolve("NETHER_ANALYTICS_STORAGE_CONNECTIONSTRING"); Console.WriteLine(); // Setup Web Job Config var jobHostConfig = new JobHostConfiguration(s_webJobDashboardAndStorageConnectionString) { NameResolver = new NameResolver(), StorageConnectionString = s_webJobDashboardAndStorageConnectionString }; var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddReceiver(s_ingestEventHubName, s_ingestEventHubConnectionString); jobHostConfig.UseEventHub(eventHubConfig); jobHostConfig.UseTimers(); if (jobHostConfig.IsDevelopment) { jobHostConfig.UseDevelopmentSettings(); } return(jobHostConfig); }
static void Main(string[] args) { JobHostConfiguration config = new JobHostConfiguration(); config.Tracing.ConsoleLevel = System.Diagnostics.TraceLevel.Error; var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddReceiver(eventHubName, connectionString); config.UseEventHub(eventHubConfig); JobHost host = new JobHost(config); if (config.IsDevelopment) { config.UseDevelopmentSettings(); } //Send test messages Task.Run(() => { SendingRandomMessages(); }); host.RunAndBlock(); }
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 public static void Main() { // Read configuration //TODO: Make all configuration work in the same way across Nether Console.WriteLine("Configuring WebJob (from Environment Variables"); var webJobDashboardAndStorageConnectionString = Environment.GetEnvironmentVariable("NETHER_WEBJOB_DASHBOARD_AND_STORAGE_CONNECTIONSTRING"); Console.WriteLine($"webJobDashboardAndStorageConnectionString: {webJobDashboardAndStorageConnectionString}"); var ingestEventHubConnectionString = Environment.GetEnvironmentVariable("NETHER_INGEST_EVENTHUB_CONNECTIONSTRING"); Console.WriteLine($"ingestEventHubConnectionString: {ingestEventHubConnectionString}"); var ingestEventHubName = Environment.GetEnvironmentVariable("NETHER_INGEST_EVENTHUB_NAME"); Console.WriteLine($"ingestEventHubName: {ingestEventHubName}"); Console.WriteLine(); // Configure WebJob var jobHostConfig = new JobHostConfiguration(webJobDashboardAndStorageConnectionString); var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddReceiver(ingestEventHubName, ingestEventHubConnectionString); jobHostConfig.UseEventHub(eventHubConfig); if (jobHostConfig.IsDevelopment) { jobHostConfig.UseDevelopmentSettings(); } // Run and block var host = new JobHost(jobHostConfig); host.RunAndBlock(); }
// 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(); }
// 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(); } string eventHubName = ConfigurationManager.AppSettings["EventHubName"]; string eventHubConnectionString = ConfigurationManager.AppSettings["EventHubConnectionString"]; var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddReceiver(eventHubName, eventHubConnectionString); config.UseEventHub(eventHubConfig); using (var host = new JobHost(config)) { // The following code ensures that the WebJob will be running continuously host.RunAndBlock(); } }