• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# JobHostConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中JobHostConfiguration的典型用法代码示例。如果您正苦于以下问题:C# JobHostConfiguration类的具体用法?C# JobHostConfiguration怎么用?C# JobHostConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JobHostConfiguration类属于命名空间,在下文中一共展示了JobHostConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InvokeQueueFunctionAndWaitForResult

        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();
            }
        }
开发者ID:farukc,项目名称:azure-webjobs-sdk-dashboard-tests,代码行数:29,代码来源:QueueArgumentsDisplayFixture.cs


示例2: Run

        public static void Run(string connectionString)
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
            CreateTestQueues(queueClient);

            try
            {
                CloudQueue firstQueue = queueClient.GetQueueReference(_nameResolver.ResolveInString(FunctionChainingPerfTest.FirstQueueName));
                firstQueue.AddMessage(new CloudQueueMessage("Test"));

                _startBlock = MeasurementBlock.BeginNew(0, HostStartMetric);

                JobHostConfiguration hostConfig = new JobHostConfiguration(connectionString);
                hostConfig.NameResolver = _nameResolver;
                hostConfig.TypeLocator = new FakeTypeLocator(typeof(FunctionChainingPerfTest));

                JobHost host = new JobHost(hostConfig);
                _tokenSource = new CancellationTokenSource();
                Task stopTask = null;
                _tokenSource.Token.Register(() => stopTask = host.StopAsync());
                host.RunAndBlock();
                stopTask.GetAwaiter().GetResult();
            }
            finally
            {
                DeleteTestQueues(queueClient);
            }
        }
开发者ID:rafaelmtz,项目名称:azure-webjobs-sdk,代码行数:30,代码来源:FunctionChainingPerfTest.cs


示例3: Main

        public static void Main(string[] args)
        {
            // Set up default WebHook logger
            ILogger logger = new TraceLogger();

            // Set the WebHook Store we want to get WebHook subscriptions from. Azure store requires
            // a valid Azure Storage connection string named MS_AzureStoreConnectionString.
            IWebHookStore store = AzureWebHookStore.CreateStore(logger);

            // Set the sender we want to actually send out the WebHooks. We could also 
            // enqueue messages for scale out.
            IWebHookSender sender = new DataflowWebHookSender(logger);

            // Set up WebHook manager which we use for creating notifications.
            Manager = new WebHookManager(store, sender, logger);

            // Initialize WebJob
            var listener = ConfigurationManager.ConnectionStrings["WebHookListener"].ConnectionString;
            JobHostConfiguration config = new JobHostConfiguration
            {
                StorageConnectionString = listener
            };
            JobHost host = new JobHost(config);
            host.RunAndBlock();
        }
开发者ID:aspnet,项目名称:WebHooks,代码行数:25,代码来源:Program.cs


示例4: JobHost

 static void JobHost()
 {
     var config = new JobHostConfiguration();
     var host = new JobHost(config);
     host.RunAndBlock();
     host.Start();
 }
开发者ID:yonglehou,项目名称:Microservices2015,代码行数:7,代码来源:Program.cs


示例5: Main

        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        public static void Main()
        {
            try
            {
#if !DEBUG
                LogManager.Logger = new OneTimeLogger(new ProfileRepository());
#endif

                LogManager.Log("Start !");
                JobHostConfiguration config = new JobHostConfiguration();
                config.Queues.BatchSize = 1;
                var host = new JobHost(config);

                Init();
                Run();
#if DEBUG
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
#else
                LogManager.Log("This is release !");
                // The following code ensures that the WebJob will be running continuously
                //host.RunAndBlock();
#endif
            }
            catch (Exception ex)
            {
                LogManager.Log(ex);
            }
            finally
            {
                LogManager.Log("End");
                LogManager.FlushLogger();
            }
        }
开发者ID:v-pi,项目名称:cloud-deamon,代码行数:36,代码来源:Program.cs


示例6: ServiceBusArgumentsDisplayTestsFixture

        public ServiceBusArgumentsDisplayTestsFixture()
            : base(cleanStorageAccount: true)
        {
            _hostConfiguration = new JobHostConfiguration(StorageAccount.ConnectionString)
            {
                TypeLocator = new ExplicitTypeLocator(
                    typeof(ServiceBusArgumentsDisplayFunctions),
                    typeof(DoneNotificationFunction))
            };

            #if VNEXT_SDK
            ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration();
            serviceBusConfig.ConnectionString = ServiceBusAccount;
            _serviceBusConnectionString = serviceBusConfig.ConnectionString;
            _hostConfiguration.UseServiceBus(serviceBusConfig);
            #else
            _serviceBusConnectionString = ServiceBusAccount;
            _hostConfiguration.ServiceBusConnectionString = _serviceBusConnectionString;
            #endif

            _namespaceManager = NamespaceManager.CreateFromConnectionString(_serviceBusConnectionString);

            // ensure we're starting in a clean state
            CleanServiceBusQueues();

            // now run the entire end to end scenario, causing all the job functions
            // to be invoked
            RunEndToEnd();
        }
开发者ID:farukc,项目名称:azure-webjobs-sdk-dashboard-tests,代码行数:29,代码来源:ServiceBusArgumentsDisplayFixture.cs


示例7: Main

 // Please set the following connection strings in app.config for this WebJob to run:
 // AzureWebJobsDashboard and AzureWebJobsStorage
 static void Main()
 {
     var config = new JobHostConfiguration();
     config.UseTimers();
     var host = new JobHost(config);
     host.RunAndBlock();
 }
开发者ID:bestwpw,项目名称:letsencrypt-siteextension,代码行数:9,代码来源:Program.cs


示例8: Main

        public int Main(string[] args)
        {
            var builder = new ConfigurationBuilder();
            builder.Add(new JsonConfigurationProvider("config.json"));
            var config = builder.Build();
            var webjobsConnectionString = config["Data:AzureWebJobsStorage:ConnectionString"];
            var dbConnectionString = config["Data:DefaultConnection:ConnectionString"];
            if (string.IsNullOrWhiteSpace(webjobsConnectionString))
            {
                Console.WriteLine("The configuration value for Azure Web Jobs Connection String is missing.");
                return 10;
            }

            if (string.IsNullOrWhiteSpace(dbConnectionString))
            {
                Console.WriteLine("The configuration value for Database Connection String is missing.");
                return 10;
            }

            var jobHostConfig = new JobHostConfiguration(config["Data:AzureWebJobsStorage:ConnectionString"]);
            var host = new JobHost(jobHostConfig);
            var methodInfo = typeof(Functions).GetMethods().First();

            host.Call(methodInfo);
            return 0;
        }
开发者ID:dpiessens,项目名称:PartsUnlimited,代码行数:26,代码来源:Program.cs


示例9: ApplyConfiguration_Singleton

        public void ApplyConfiguration_Singleton()
        {
            JObject config = new JObject();
            config["id"] = ID;
            JObject singleton = new JObject();
            config["singleton"] = singleton;
            JobHostConfiguration jobHostConfig = new JobHostConfiguration();

            ScriptHost.ApplyConfiguration(config, jobHostConfig);

            Assert.Equal(ID, jobHostConfig.HostId);
            Assert.Equal(15, jobHostConfig.Singleton.LockPeriod.TotalSeconds);
            Assert.Equal(1, jobHostConfig.Singleton.ListenerLockPeriod.TotalMinutes);
            Assert.Equal(1, jobHostConfig.Singleton.ListenerLockRecoveryPollingInterval.TotalMinutes);
            Assert.Equal(1, jobHostConfig.Singleton.LockAcquisitionTimeout.TotalMinutes);
            Assert.Equal(3, jobHostConfig.Singleton.LockAcquisitionPollingInterval.TotalSeconds);

            singleton["lockPeriod"] = "00:00:17";
            singleton["listenerLockPeriod"] = "00:00:22";
            singleton["listenerLockRecoveryPollingInterval"] = "00:00:33";
            singleton["lockAcquisitionTimeout"] = "00:05:00";
            singleton["lockAcquisitionPollingInterval"] = "00:00:08";

            ScriptHost.ApplyConfiguration(config, jobHostConfig);

            Assert.Equal(17, jobHostConfig.Singleton.LockPeriod.TotalSeconds);
            Assert.Equal(22, jobHostConfig.Singleton.ListenerLockPeriod.TotalSeconds);
            Assert.Equal(33, jobHostConfig.Singleton.ListenerLockRecoveryPollingInterval.TotalSeconds);
            Assert.Equal(5, jobHostConfig.Singleton.LockAcquisitionTimeout.TotalMinutes);
            Assert.Equal(8, jobHostConfig.Singleton.LockAcquisitionPollingInterval.TotalSeconds);
        }
开发者ID:wondenge,项目名称:azure-webjobs-sdk-script,代码行数:31,代码来源:ScriptHostTests.cs


示例10: ApplyConfiguration_Queues

        public void ApplyConfiguration_Queues()
        {
            JObject config = new JObject();
            config["id"] = ID;
            JObject queuesConfig = new JObject();
            config["queues"] = queuesConfig;
            JobHostConfiguration jobHostConfig = new JobHostConfiguration();

            ScriptHost.ApplyConfiguration(config, jobHostConfig);

            Assert.Equal(ID, jobHostConfig.HostId);
            Assert.Equal(60 * 1000, jobHostConfig.Queues.MaxPollingInterval.TotalMilliseconds);
            Assert.Equal(16, jobHostConfig.Queues.BatchSize);
            Assert.Equal(5, jobHostConfig.Queues.MaxDequeueCount);
            Assert.Equal(8, jobHostConfig.Queues.NewBatchThreshold);

            queuesConfig["maxPollingInterval"] = 5000;
            queuesConfig["batchSize"] = 17;
            queuesConfig["maxDequeueCount"] = 3;
            queuesConfig["newBatchThreshold"] = 123;

            ScriptHost.ApplyConfiguration(config, jobHostConfig);

            Assert.Equal(5000, jobHostConfig.Queues.MaxPollingInterval.TotalMilliseconds);
            Assert.Equal(17, jobHostConfig.Queues.BatchSize);
            Assert.Equal(3, jobHostConfig.Queues.MaxDequeueCount);
            Assert.Equal(123, jobHostConfig.Queues.NewBatchThreshold);
        }
开发者ID:wondenge,项目名称:azure-webjobs-sdk-script,代码行数:28,代码来源:ScriptHostTests.cs


示例11: Main

        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);
            }
        }
开发者ID:JasonHaley,项目名称:Redis.WebJobs.Extensions,代码行数:29,代码来源:Program.cs


示例12: Main

        public int Main(string[] args)
        {
            var builder = new ConfigurationBuilder();
            //builder.Add(new JsonConfigurationSource("config.json"));
            builder.AddJsonFile("config.json");
            var config = builder.Build();
            var webjobsConnectionString = config["Data:AzureWebJobsStorage:ConnectionString"];
            var dbConnectionString = config["Data:DefaultConnection:ConnectionString"];

            if (string.IsNullOrWhiteSpace(webjobsConnectionString))
            {
                Console.WriteLine("The configuration value for Azure Web Jobs Connection String is missing.");
                return 10;
            }

            if (string.IsNullOrWhiteSpace(dbConnectionString))
            {
                Console.WriteLine("The configuration value for Database Connection String is missing.");
                return 10;
            }

            var jobHostConfig = new JobHostConfiguration(webjobsConnectionString);
            var host = new JobHost(jobHostConfig);

            host.RunAndBlock();
            return 0;
        }
开发者ID:philljeff,项目名称:PartsUnlimited-master,代码行数:27,代码来源:Program.cs


示例13: UseServiceBus_NoServiceBusConfiguration_PerformsExpectedRegistration

        public void UseServiceBus_NoServiceBusConfiguration_PerformsExpectedRegistration()
        {
            JobHostConfiguration config = new JobHostConfiguration();
            string serviceBusConnection = "test service bus connection";
#pragma warning disable 0618
            config.ServiceBusConnectionString = serviceBusConnection;
#pragma warning restore 0618

            IExtensionRegistry extensions = config.GetService<IExtensionRegistry>();
            IExtensionConfigProvider[] configProviders = extensions.GetExtensions<IExtensionConfigProvider>().ToArray();
            Assert.Equal(0, configProviders.Length);

            config.UseServiceBus();

            // verify that the service bus config provider was registered
            configProviders = extensions.GetExtensions<IExtensionConfigProvider>().ToArray();
            Assert.Equal(1, configProviders.Length);

            ServiceBusExtensionConfig serviceBusExtensionConfig = (ServiceBusExtensionConfig)configProviders.Single();

            // verify that a default ServiceBusConfiguration was created, with the host (obsolete)
            // service bus connection string propagated
#pragma warning disable 0618
            Assert.Equal(serviceBusConnection, serviceBusExtensionConfig.Config.ConnectionString);
#pragma warning restore 0618
        }
开发者ID:rafaelmtz,项目名称:azure-webjobs-sdk,代码行数:26,代码来源:ServiceBusJobHostConfigurationExtensionsTests.cs


示例14: Main

    static void Main()
        {
            // setup unobserved exceptions
            TaskScheduler.UnobservedTaskException += Program.handleUnObservedExceptions;



         // Setup configuration sources.
        Configuration = new Configuration()
                .AddEnvironmentVariables("APPSETTING_");

            var storageCstr = GetConnectionString();

            JobHostConfiguration config = new JobHostConfiguration(storageCstr);
            config.Queues.BatchSize = 1; //Number of messages parallel processed in parallel. Will need some concurrency check before increasing.
            config.Queues.MaxDequeueCount = 4;
            config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(15);
            JobHost host = new JobHost(config);
            Console.WriteLine("Web Job starting..");

            // TEST Lines
            //ProvisioningLibrary.WebJobController w = new WebJobController(Configuration);
            //w.SubmitActionInQueue("8fd8fbfc-8fb6-4e95-ae17-aa4779423cb8", ResourceAction.Start );

            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
开发者ID:hpatel98,项目名称:SCAMP,代码行数:27,代码来源:Program.cs


示例15: Main

        static void Main()
        {
            JobHost host;
            string connectionString;
            // To run webjobs locally, can't use storage emulator
            // for local execution, use connection string stored in environment vatiable
            if ((connectionString = Environment.GetEnvironmentVariable("AzureStorageQueueTransport.ConnectionString")) != null)
            {
                var configuration = new JobHostConfiguration
                {
                    DashboardConnectionString = connectionString,
                    StorageConnectionString = connectionString
                };
                host = new JobHost(configuration);
            }
            // for production, use DashboardConnectionString and StorageConnectionString defined at Azure website
            else
            {
                host = new JobHost();
            }

            Console.WriteLine("Starting VideoStore.Operations host");
            host.Call(typeof(Functions).GetMethod("Host"));
            host.RunAndBlock();
        }
开发者ID:nigelhamer,项目名称:VideoStore.DistributedAppDemo,代码行数:25,代码来源:Program.cs


示例16: Main

        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            Console.WriteLine("*************************************************************************");
            Console.WriteLine("WebJobUsageHistory:Main starting. DateTimeUTC: {0}", DateTime.UtcNow);

            /*/
            DateTime sdt = DateTime.Now.AddYears(-3);
            DateTime edt = DateTime.Now.AddDays(-1);
            BillingRequest br = new BillingRequest("30d4242f-1afc-49d9-a993-59d0de83b5bd",
                                                    "72f988bf-86f1-41af-91ab-2d7cd011db47",
                                                    sdt, //Convert.ToDateTime("2015-10-28 00:00:00.000"),
                                                    edt);//Convert.ToDateTime("2015-10-29 00:00:00.000"));
            Functions.ProcessQueueMessage(br);
            return;
            /**/

            JobHostConfiguration config = new JobHostConfiguration();
            config.Queues.BatchSize = 3;
            config.Queues.MaxDequeueCount = 3;
            config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(15);

            var host = new JobHost(config);
            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
开发者ID:ChrisRisner,项目名称:AzureUsageAndBillingPortal,代码行数:27,代码来源:Program.cs


示例17: ScriptHostConfiguration

 public ScriptHostConfiguration()
 {
     HostConfig = new JobHostConfiguration();
     FileWatchingEnabled = true;
     RootScriptPath = Environment.CurrentDirectory;
     RootLogPath = Path.Combine(Path.GetTempPath(), "Functions");            
 }
开发者ID:isaacabraham,项目名称:azure-webjobs-sdk-script,代码行数:7,代码来源:ScriptHostConfiguration.cs


示例18: Main

 // Please set the following connection strings in app.config for this WebJob to run:
 // AzureWebJobsDashboard and AzureWebJobsStorage
 static void Main()
 {
     JobHostConfiguration config = new JobHostConfiguration();
       config.UseServiceBus();
       JobHost host = new JobHost(config);
       host.RunAndBlock();
 }
开发者ID:michael-chi,项目名称:Azure-IOTHub,代码行数:9,代码来源:Program.cs


示例19: Initialize_PerformsExpectedRegistrations

        public void Initialize_PerformsExpectedRegistrations()
        {
            JobHostConfiguration config = new JobHostConfiguration();
            config.AddService<INameResolver>(new RandomNameResolver());

            ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration();
            ServiceBusExtensionConfig serviceBusExtensionConfig = new ServiceBusExtensionConfig(serviceBusConfig);

            IExtensionRegistry extensions = config.GetService<IExtensionRegistry>();
            ITriggerBindingProvider[] triggerBindingProviders = extensions.GetExtensions<ITriggerBindingProvider>().ToArray();
            Assert.Equal(0, triggerBindingProviders.Length);
            IBindingProvider[] bindingProviders = extensions.GetExtensions<IBindingProvider>().ToArray();
            Assert.Equal(0, bindingProviders.Length);

            ExtensionConfigContext context = new ExtensionConfigContext
            {
                Config = config,
                Trace = new TestTraceWriter(TraceLevel.Verbose)
            };
            serviceBusExtensionConfig.Initialize(context);

            // ensure the ServiceBusTriggerAttributeBindingProvider was registered
            triggerBindingProviders = extensions.GetExtensions<ITriggerBindingProvider>().ToArray();
            Assert.Equal(1, triggerBindingProviders.Length);
            ServiceBusTriggerAttributeBindingProvider triggerBindingProvider = (ServiceBusTriggerAttributeBindingProvider)triggerBindingProviders[0];
            Assert.NotNull(triggerBindingProvider);

            // ensure the ServiceBusAttributeBindingProvider was registered
            bindingProviders = extensions.GetExtensions<IBindingProvider>().ToArray();
            Assert.Equal(1, bindingProviders.Length);
            ServiceBusAttributeBindingProvider bindingProvider = (ServiceBusAttributeBindingProvider)bindingProviders[0];
            Assert.NotNull(bindingProvider);
        }
开发者ID:ConnorMcMahon,项目名称:azure-webjobs-sdk,代码行数:33,代码来源:ServiceBusExtensionConfigTests.cs


示例20: Main

        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            var config = new JobHostConfiguration();
            var slackConfig = new SlackConfiguration();
            WebHooksConfiguration webhookConfig;

            if(config.IsDevelopment)
            {
                config.UseDevelopmentSettings();
                webhookConfig = new WebHooksConfiguration(3000);
            }
            else
            {
                webhookConfig = new WebHooksConfiguration();
            }

            // These are optional and will be applied if no other value is specified.
            /*
            slackConfig.WebHookUrl = "";
            // IT IS A BAD THING TO HARDCODE YOUR WEBHOOKURL, USE THE APP SETTING "AzureWebJobsSlackWebHookKeyName"
            slackConfig.IconEmoji = "";
            slackConfig.Username = "";
            slackConfig.Channel = "";
            */

            config.UseSlack(slackConfig);
            config.UseWebHooks(webhookConfig);

            var host = new JobHost(config);
            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
开发者ID:christopheranderson,项目名称:azure-webjobs-sdk-extensions-slack,代码行数:34,代码来源:Program.cs



注:本文中的JobHostConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JobKey类代码示例发布时间:2022-05-24
下一篇:
C# JobHost类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap