コード例 #1
0
ファイル: Program.cs プロジェクト: HouseOfTheFuture/API-App
        public static void Main()
        {
     //       string connectionString =
     //ConfigurationManager.ConnectionStrings["RootManageSharedAccessKey"].ConnectionString;
     //       Action<BrokeredMessage> callback = x =>
     //       {
                
     //       };
     //       var clients = new List<SubscriptionClient>();
     //       for (int i = 0; i < 5; i++)
     //       {
     //           var client = TopicClient.CreateFromConnectionString(connectionString, "signalr_topic_push_" + i);
     //           client.
     //           client.OnMessage(callback);
     //           clients.Add(client);
     //       }
     //       Console.ReadLine();
            //var ctx = GlobalHost.ConnectionManager.GetHubContext<yourhub>();
            //ctx.Clients.Client(connectionId).< your method >

            var cloudStorage = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["DataStorage"].ConnectionString);
            var tableClient = cloudStorage.CreateCloudTableClient();
            _tickEvents = tableClient.GetTableReference("tickevents");
            _tickEvents.CreateIfNotExists();
            var host = new JobHost();
            var cancelToken = new WebJobsShutdownWatcher().Token;
            _eventHubClient = EventHubClient.CreateFromConnectionString(ConfigurationManager.ConnectionStrings["IotHubConnection"].ConnectionString, iotHubD2cEndpoint);
            var d2CPartitions = _eventHubClient.GetRuntimeInformation().PartitionIds;
            Task.WaitAll(d2CPartitions.Select(partition => ListenForEvent(host, partition, cancelToken)).ToArray(), cancelToken);
            host.RunAndBlock();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Kgabo707/azure-guidance
 // Please set the following connection strings in app.config for this WebJob to run:
 // AzureWebJobsDashboard and AzureWebJobsStorage
 static void  Main()
 {
     var host = new JobHost();
     
     // The following code ensures that the WebJob will be running continuously
     host.RunAndBlock();
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: v-pi/cloud-deamon
        // 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();
            }
        }
コード例 #4
0
 // 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();
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: sadiqna/TicketDesk
        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        private static void Main()
        {
            var demoMode = (ConfigurationManager.AppSettings["ticketdesk:DemoModeEnabled"] ?? "false").Equals("true", StringComparison.InvariantCultureIgnoreCase);
            var isEnabled = false;
            var interval = 2;
            using (var context = new TdPushNotificationContext())
            {
                isEnabled = !demoMode && context.TicketDeskPushNotificationSettings.IsEnabled;
                interval = context.TicketDeskPushNotificationSettings.DeliveryIntervalMinutes;
            }
            var storageConnectionString = AzureConnectionHelper.CloudConfigConnString ??
                                             AzureConnectionHelper.ConfigManagerConnString;
            var host = new JobHost(new JobHostConfiguration(storageConnectionString));
            if (isEnabled)
            {
                host.Call(typeof(Functions).GetMethod("StartNotificationScheduler"), new { interval});
                host.RunAndBlock();
            }
            else
            {
                Console.Out.WriteLine("Push notifications are disabled");
                host.RunAndBlock();//just run and block, to keep from recycling the service over and over
            }


        }
コード例 #6
0
ファイル: Program.cs プロジェクト: dpiessens/PartsUnlimited
        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;
        }
コード例 #7
0
        static void Main()
        {
            CreateDemoData();

            JobHost host = new JobHost();
            host.RunAndBlock();
        }
コード例 #8
0
        static void Main()
        {
            CreateDemoData();

            JobHost host = new JobHost();
            host.Start();
        }
コード例 #9
0
		static void Main()
		{
			_servicesBusConnectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
			namespaceManager = NamespaceManager.CreateFromConnectionString(_servicesBusConnectionString);

			if (!namespaceManager.QueueExists(nameof(Step1)))
			{
				namespaceManager.CreateQueue(nameof(Step1));
			}
			if (!namespaceManager.QueueExists(nameof(Step2)))
			{
				namespaceManager.CreateQueue(nameof(Step2));
			}

			JobHostConfiguration config = new JobHostConfiguration();
			config.UseServiceBus();



			var host = new JobHost(config);

			CreateStartMessage();

			host.RunAndBlock();
		}
コード例 #10
0
        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);
            }
        }
コード例 #11
0
 static void Main(string[] args)
 {
     var host = new JobHost();
     Console.WriteLine("EventHubReader has been started at " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:tt"));
     host.Call(typeof(Functions).GetMethod("ReadEventHub"));
     //host.RunAndBlock();
 }
コード例 #12
0
ファイル: Program.cs プロジェクト: codesocket/CodeSocketAD
        static void Main(string[] args)
        {
            var host = new JobHost();
            Console.Error.Write("An error occurred in this web job");

            host.RunAndBlock();
        }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: CrewNerd/BoatTracker
        /// <summary>
        /// Set up for logging and call our web job functions as appropriate.
        /// </summary>
        public static void Main()
        {
            var env = EnvironmentDefinition.Instance;
            var timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd_HH:MM");

            var logName = $"{env.Name}_report_{timestamp}";

            var host = new JobHost();
            host.Call(
                typeof(DailyReport).GetMethod("SendDailyReport"),
                new
                {
                    logName = logName,
                    log = $"container/{logName}"
                });

            // We refresh the bot caches every two hours for now. The bots will automatically
            // refresh on their own every 8 hours if the webjob fails to run for some reason.
            // It's better if we do it here so that user's don't see the latency.

            if (DateTime.UtcNow.Hour % 2 == 0)
            {
                logName = $"{env.Name}_refresh_{timestamp}";
                host.Call(
                    typeof(RefreshCaches).GetMethod("RefreshBotCaches"),
                    new
                    {
                        logName = logName,
                        log = $"container/{logName}"
                    });
            }
        }
コード例 #15
0
        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;
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: aaronhoffman/azure-101
 // Please set the following connection strings in app.config for this WebJob to run:
 // AzureWebJobsDashboard and AzureWebJobsStorage
 static void Main()
 {
     var host = new JobHost();
     // The following code will invoke a function called ManualTrigger and
     // pass in data (value in this case) to the function
     host.Call(typeof(Functions).GetMethod("ManualTrigger"), new { value = 20 });
 }
コード例 #17
0
 static void Main()
 {
     var host = new JobHost();
     // The following code ensures that the WebJob will be running continuously
     var TWITTERAPPACCESSTOKEN = ConfigurationManager.AppSettings["TWITTERAPPACCESSTOKEN"];
     var TWITTERAPPACCESSTOKENSECRET = ConfigurationManager.AppSettings["TWITTERAPPACCESSTOKENSECRET"];
     var TWITTERAPPAPIKEY = ConfigurationManager.AppSettings["TWITTERAPPAPIKEY"];
     var TWITTERAPPAPISECRET = ConfigurationManager.AppSettings["TWITTERAPPAPISECRET"];
     var trackersKeywords = ConfigurationManager.AppSettings["TrackerKeywords"];
     var pusherAppId = ConfigurationManager.AppSettings["PusherAppId"];
     var pusherAppKey = ConfigurationManager.AppSettings["PusherAppId"];
     var pusherAppSecret = ConfigurationManager.AppSettings["PusherAppId"];
     var pusherChannel = ConfigurationManager.AppSettings["PusherAppId"];
     var pusherEvent = ConfigurationManager.AppSettings["PusherAppId"];
     var pusherConfig = new PusherConfig {
          AppId = pusherAppId,
          AppKey = pusherAppKey,
          AppSecret = pusherAppSecret,
          Channel = pusherChannel,
          Event = pusherEvent
     };
     Auth.SetUserCredentials(TWITTERAPPAPIKEY, TWITTERAPPAPISECRET, TWITTERAPPACCESSTOKEN, TWITTERAPPACCESSTOKENSECRET);
     Auth.ApplicationCredentials = new TwitterCredentials(TWITTERAPPAPIKEY, TWITTERAPPAPISECRET, TWITTERAPPACCESSTOKEN, TWITTERAPPACCESSTOKENSECRET);
     Program p = new Program();
     p.Stream_FilteredStreamExample(trackersKeywords, pusherConfig);
     host.RunAndBlock();
 }
コード例 #18
0
        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();
        }
コード例 #19
0
 static void JobHost()
 {
     var config = new JobHostConfiguration();
     var host = new JobHost(config);
     host.RunAndBlock();
     host.Start();
 }
コード例 #20
0
ファイル: Program.cs プロジェクト: hpatel98/SCAMP
    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();
        }
コード例 #21
0
        // 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();
        }
コード例 #22
0
        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            var host = new JobHost();
            // The following code ensures that the WebJob will be running continuously
            //host.RunAndBlock();           

            //DB에 데이터 저장 예제
            using (SqlConnection connection = new SqlConnection("Data Source = (local); Initial Catalog = pubs; Integrated Security = True; MultipleActiveResultSets = True"))
            {
                using (SqlCommand command = new SqlCommand("insert into azurecamptable(idx, value) values(1, 'test')", connection))
                {
                    connection.Open();
                    using (SqlDataReader dreader = command.ExecuteReader())
                    {
                        while (dreader.Read())
                        {
                            //result = dreader[0].ToString();
                        }
                        dreader.Close();
                    }
                    connection.Close();

                    return;
                }
            }
        }
コード例 #23
0
ファイル: Program.cs プロジェクト: michael-chi/Azure-IOTHub
 // 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();
 }
コード例 #24
0
        // 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();
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: sadiqna/TicketDesk
 static void Main()
 {
     Initialize();
     var storageConnectionString = AzureConnectionHelper.CloudConfigConnString ?? AzureConnectionHelper.ConfigManagerConnString;
     var host = new JobHost(new JobHostConfiguration(storageConnectionString));
     host.RunAndBlock();
 }
コード例 #26
0
 // Please set the following connection strings in app.config for this WebJob to run:
 // AzureWebJobsDashboard and AzureWebJobsStorage
 static void Main()
 {
     var host = new JobHost();
     // The following code ensures that the WebJob will be running continuously
     //host.RunAndBlock();
     host.Call(typeof(Program).GetMethod("CreateQueueMessage"), new { value = "Hello world!" });
 }
        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();
            }
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: aspnet/WebHooks
        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();
        }
コード例 #29
0
        public static void Main()
        {
            var webJobsDashboard = CloudConfigurationManager.GetSetting("AzureWebJobsDashboard");
            var webJobsStorage = CloudConfigurationManager.GetSetting("AzureWebJobsStorage");
            var storageAcc = CloudConfigurationManager.GetSetting("StorageAccount");

            if (string.IsNullOrWhiteSpace(webJobsStorage) || string.IsNullOrWhiteSpace(storageAcc) || string.IsNullOrWhiteSpace(webJobsDashboard))
            {
                Console.WriteLine("Please add the Azure Storage account credentials ['StorageAccount' & 'AzureWebJobsStorage' & 'AzureWebJobsDashboard'] in App.config");
                Console.Read();
                return;
            }
            else
            {
                var config = new TaskConfiguration()
                {
                    ConnectionString = storageAcc,
                    StorageElements = new StorageElements(),
                };

                var factory = new ImageTaskFactory();
                foreach (var task in factory.Initialize(config))
                {
                    task.Start();
                }

                var host = new JobHost();
                host.RunAndBlock();
            }
        }
コード例 #30
-1
        static void Main(string[] args)
        {
            JobHostConfiguration config = new JobHostConfiguration();

            config.Tracing.ConsoleLevel = TraceLevel.Verbose;

            // Set to a short polling interval to facilitate local
            // debugging. You wouldn't want to run prod this way.
            config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(2);

            FilesConfiguration filesConfig = new FilesConfiguration();
            if (string.IsNullOrEmpty(filesConfig.RootPath))
            {
                // when running locally, set this to a valid directory
                filesConfig.RootPath = @"c:\temp\files";
            };
            EnsureSampleDirectoriesExist(filesConfig.RootPath);
            config.UseFiles(filesConfig);

            config.UseTimers();
            config.UseSample();
            config.UseCore();

            JobHost host = new JobHost(config);

            host.Call(typeof(FileSamples).GetMethod("ReadWrite"));
            host.Call(typeof(SampleSamples).GetMethod("Sample_BindToStream"));
            host.Call(typeof(SampleSamples).GetMethod("Sample_BindToString"));
            host.Call(typeof(TableSamples).GetMethod("CustomBinding"));

            host.RunAndBlock();
        }