static void JobHost() { var config = new JobHostConfiguration(); var host = new JobHost(config); host.RunAndBlock(); host.Start(); }
private void InvokeQueueFunctionAndWaitForResult(MethodInfo function, CloudQueueMessage message = null) { if (message == null) { message = new CloudQueueMessage(POCO.JsonSample); } string queueName = CreateQueueName(function, input: true); CloudQueueClient queueClient = StorageAccount.CloudStorageAccount.CreateCloudQueueClient(); CloudQueue queue = queueClient.GetQueueReference(queueName); queue.CreateIfNotExists(); queue.AddMessage(message); JobHostConfiguration hostConfiguration = new JobHostConfiguration(StorageAccount.ConnectionString) { TypeLocator = new ExplicitTypeLocator( typeof(QueueArgumentsDisplayFunctions), typeof(DoneNotificationFunction)) }; using (JobHost host = new JobHost(hostConfiguration)) using (DoneNotificationFunction._doneEvent = new ManualResetEvent(initialState: false)) { host.Start(); DoneNotificationFunction._doneEvent.WaitOne(); host.Stop(); } }
static void Main() { CreateDemoData(); JobHost host = new JobHost(); host.Start(); }
static void Main(string[] args) { JobHostConfiguration config = new JobHostConfiguration(); //config.Tracing.Trace = new ConsoleTraceWriter(TraceLevel.Verbose); config.UseRedis(); JobHost host = new JobHost(config); host.Start(); // Give subscriber chance to startup Task.Delay(5000).Wait(); host.Call(typeof(Functions).GetMethod("SendSimplePubSubMessage")); host.Call(typeof(Functions).GetMethod("SendPubSubMessage")); host.Call(typeof(Functions).GetMethod("SendPubSubMessageIdChannel")); host.Call(typeof(Functions).GetMethod("AddSimpleCacheMessage")); host.Call(typeof(Functions).GetMethod("AddCacheMessage")); host.Call(typeof(Functions).GetMethod("AddCacheMessage")); Console.CancelKeyPress += (sender, e) => { host.Stop(); }; while (true) { Thread.Sleep(500); } }
static void Main() { CreateDemoData(); JobHostConfiguration configuration = new JobHostConfiguration(); // Demonstrates the global queue processing settings that can // be configured configuration.Queues.MaxPollingInterval = TimeSpan.FromSeconds(30); configuration.Queues.MaxDequeueCount = 10; configuration.Queues.BatchSize = 16; configuration.Queues.NewBatchThreshold = 20; // Demonstrates how queue processing can be customized further // by defining a custom QueueProcessor Factory configuration.Queues.QueueProcessorFactory = new CustomQueueProcessorFactory(); JobHost host = new JobHost(configuration); host.Start(); // Stop the host if Ctrl + C/Ctrl + Break is pressed Console.CancelKeyPress += (sender, args) => { host.Stop(); }; while(true) { Thread.Sleep(500); } }
// Please set the following connection strings in app.config for this WebJob to run: // AzureWebJobsDashboard and AzureWebJobsStorage static void Main() { AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnProcessExit; var jobStorageSecret = GetStorage(10); try { var host = new JobHost(new JobHostConfiguration(jobStorageSecret)); // The following code ensures that the WebJob will be running continuously host.Start(); } catch (Exception ex) { Console.WriteLine("Failed to connect to storage --- assuming development?"); Console.WriteLine(ex.Message); } var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "binaries\\selenium-server-standalone-2.47.1.jar"); var process = new ProcessStartInfo("D:\\Program Files (x86)\\Java\\jdk1.8.0_25\\bin\\java.exe", "-Djava.net.preferIPv4Stack=true -jar " + path + " -role hub") { CreateNoWindow = true, UseShellExecute = false }; var local = new ProcessStartInfo("java.exe", "-jar " + path) { UseShellExecute = false, CreateNoWindow = false }; try { var proc = Process.Start(process); wait(proc); } catch { try { var dunc = Process.Start(local); wait(dunc); } catch (Exception e) { throw new Exception("Failed to start selenium" + e.Message); } } }
static void Main() { CreateDemoData(); JobHost host = new JobHost(); host.Start(); // Stop the host if Ctrl + C/Ctrl + Break is pressed Console.CancelKeyPress += (sender, args) => { host.Stop(); }; while(true) { Thread.Sleep(500); } }
private async Task RunTimerJobTest(Type jobClassType, Func<bool> condition) { ExplicitTypeLocator locator = new ExplicitTypeLocator(jobClassType); JobHostConfiguration config = new JobHostConfiguration { TypeLocator = locator }; config.UseTimers(); JobHost host = new JobHost(config); host.Start(); await TestHelpers.Await(() => { return condition(); }); host.Stop(); }
private void InvokeBlobFunctionAndWaitForResult( MethodInfo function, string triggerMessage = null, string inputMessage = null) { if (triggerMessage ==null) { triggerMessage = "trigger-content-"; } if (inputMessage ==null) { inputMessage = "input-content"; } string blobPartialName = function.Name.ToLowerInvariant(); CloudBlobClient blobClient = StorageAccount.CloudStorageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(BlobArgumentsDisplayFunctions.ContainerName); container.CreateIfNotExists(); container .GetBlockBlobReference(blobPartialName + "-trigger") .UploadText(triggerMessage); container .GetBlockBlobReference(blobPartialName + "-in") .UploadText(inputMessage); JobHostConfiguration hostConfiguration = new JobHostConfiguration(StorageAccount.ConnectionString) { TypeLocator = new ExplicitTypeLocator( typeof(BlobArgumentsDisplayFunctions), typeof(BlobArgumentsDisplayFunctions.POCOBinder), typeof(DoneNotificationFunction)) }; using (JobHost host = new JobHost(hostConfiguration)) using (DoneNotificationFunction._doneEvent = new ManualResetEvent(initialState: false)) { host.Start(); DoneNotificationFunction._doneEvent.WaitOne(); host.Stop(); } }
// Please set the following connection strings in app.config for this WebJob to run: // AzureWebJobsDashboard and AzureWebJobsStorage static void Main() { var client = new KeyVault(new Uri(CloudConfigurationManager.GetSetting("KeyVault"))); var jobStorage = client.Secret.GetSecretByName("JobStorage"); var sb = client.Secret.GetSecretByName("ServiceBus"); if (jobStorage.Value != CloudConfigurationManager.GetSetting("JobStorage")) { jobStorage = new Secret() { ContentType = "String", Name = "JobStorage", Value = CloudConfigurationManager.GetSetting("JobStorage") }; jobStorage = client.Secret.CreateSecret("JobStorage", jobStorage); } if (sb.Value != CloudConfigurationManager.GetSetting("ServiceBus")) { sb = new Secret() { ContentType = "String", Name = "ServiceBus", Value = CloudConfigurationManager.GetSetting("ServiceBus") }; sb = client.Secret.CreateSecret("ServiceBus", sb); } var jobStorageConnString = jobStorage.Value; var host = new JobHost(new JobHostConfiguration(jobStorageConnString)); host.Start(); Console.WriteLine("Bootstrapped"); host.Stop(); }
static void Main(string[] vargStrings) { var configuration = new JobHostConfiguration(); configuration.Queues.MaxPollingInterval = TimeSpan.FromSeconds(30); configuration.Queues.MaxDequeueCount = 10; configuration.Queues.BatchSize = 1; var host = new JobHost(configuration); host.Start(); // Stop the host if Ctrl + C/Ctrl + Break is pressed Console.CancelKeyPress += (sender, args) => { host.Stop(); }; while (true) { Thread.Sleep(500); } }
private void RunEndToEnd() { // create the initial messgage that starts the function chain CreateStartMessage(); using (JobHost host = new JobHost(_hostConfiguration)) using (DoneNotificationFunction._doneEvent = new ManualResetEvent(initialState: false)) { host.Start(); DoneNotificationFunction._doneEvent.WaitOne(); host.Stop(); } }