static void Main()
        {
            CreateDemoData();

            JobHost host = new JobHost();
            host.RunAndBlock();
        }
        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);
            }
        }
        static void Main()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureJobsData"].ConnectionString);
            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
            CloudQueue queue = queueClient.GetQueueReference("inputtext");
            queue.CreateIfNotExist();
            queue.AddMessage(new CloudQueueMessage("Hello World!"));

            // The connection string is read from App.config
            JobHost host = new JobHost();
            host.RunAndBlock();
        }
        /// <summary>
        /// There is a function that takes > 10 minutes and listens to a queue.
        /// </summary>
        /// <remarks>Ignored because it takes a long time. Can be enabled on demand</remarks>
        // Uncomment the Fact attribute to run
        //[Fact(Timeout = 20 * 60 * 1000)]
        public void QueueMessageLeaseRenew()
        {
            _messageFoundAgain = false;

            _queue.AddMessage(new CloudQueueMessage("Test"));

            _tokenSource = new CancellationTokenSource();
            JobHost host = new JobHost(_config);

            _tokenSource.Token.Register(host.Stop);
            host.RunAndBlock();

            Assert.False(_messageFoundAgain);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            CloudStorageAccount storageAccount;
            if (CloudStorageAccount.TryParse(
                ConfigurationManager.ConnectionStrings[STORAGE_CONN_STR_KEY_NAME].ConnectionString,
                out storageAccount))
            {
                // Create the queue we're using to trigger on if it doesn't already exist.
                CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
                CloudQueue queue = queueClient.GetQueueReference(PICTURE_LOADER_QUEUE_NAME.ToLower());
                queue.CreateIfNotExists();
            }
            else
            {
                Console.WriteLine("Unable to initialize CloudStorageAccount.");
            }

            JobHost jobHost = new JobHost();
            jobHost.RunAndBlock();
        }
 private static void Main()
 {
     var host = new JobHost();
     host.RunAndBlock();
 }
        static void Main()
        {
            CreateDemoData();

            JobHost host = new JobHost();
            host.Call(typeof(Program).GetMethod("ManualTrigger"));

            host.RunAndBlock();
        }
Exemple #8
0
        static void Main(string[] args)
        {
            JobHost host = new JobHost();

            host.RunAndBlock();
        }
Exemple #9
0
        static void Main()
        {
            var host = new JobHost();

            host.RunAndBlock();
        }
 private static void Main(string[] args)
 {
     var host = new JobHost();
     host.RunAndBlock();
 }
Exemple #11
0
        /// <summary>
        /// This is subscriber entry point its read IMessage from subscription and process.It will return APIResponse and call PrepareMessageForAnalytics to print data
        /// </summary>
        static void Main()
        {
            var host = new JobHost();

            ILog                 log = new Log();
            ReflectionHelper     reflectionHelper     = new ReflectionHelper();
            EventStreamPublisher eventStreamPublisher = new EventStreamPublisher();


            Console.WriteLine(LogMessage.SubscriberStarted);

            string connectionString = CloudConfigurationManager.GetSetting(LogMessage.ServiceBusConnectionString);

            SubscriptionClient Client = SubscriptionClient.CreateFromConnectionString(connectionString, LogMessage.TopicName, LogMessage.SubscriptionName);

            OnMessageOptions options = new OnMessageOptions();

            options.AutoComplete = false;

            Client.OnMessage((message) =>
            {
                int workflowDefinitionID = 0;
                try
                {
                    var data = message.GetBody <string>();

                    using (var db = new DataLakeEntities())
                    {
                        DateTime startedOn   = DateTime.UtcNow;
                        string workflowGuid  = Convert.ToString(data);
                        var workFlowURL      = db.GetWorkFlowServiceURL(workflowGuid).FirstOrDefault();
                        workflowDefinitionID = Convert.ToInt32(workFlowURL.WorkflowDefinitionID);
                        log.InsertWorkFlowLog(workflowDefinitionID, 3, LogMessage.OnMessageCall, null, null);

                        var getURLParameter = db.GetWorkFlowURLParameter(workflowGuid).ToList();

                        IDictionary <string, object> parameters = new Dictionary <string, object>();

                        var type   = getURLParameter.Where(o => o.ConfigurationKey == "Type").FirstOrDefault();
                        var method = getURLParameter.Where(o => o.ConfigurationKey == "Method").FirstOrDefault();

                        string serviceURL = GenrateURL(getURLParameter);

                        parameters.Add("ServiceURL", serviceURL);
                        parameters.Add("WorkflowDefinitionID", workflowDefinitionID);
                        parameters.Add("StartedOn", startedOn);


                        dynamic getAPIResponse = reflectionHelper.InvokeMethodByReflection("", Convert.ToString(type.ConfigurationValue), Convert.ToString(method.ConfigurationValue), parameters);
                        eventStreamPublisher.PublishMessages(getAPIResponse);
                    }

                    message.Complete();
                }

                catch (Exception ex)
                {
                    var getExceptionType = ex.GetType();
                    log.InsertWorkFlowLog(workflowDefinitionID, 1, LogMessage.SubscriberError + "--" + ex.Message, getExceptionType.Name, null);
                    message.Abandon();

                    Console.WriteLine(ex.Message);
                }
            }, options);

            host.RunAndBlock();
            Console.ReadLine();
        }
Exemple #12
0
        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("AzureWebJobsStorage"));

            // Create a CloudFileClient object for credentialed access to File storage.
            CloudFileClient fileClient = storageAccount.CreateCloudFileClient();

            // Get a reference to the file share we created previously.
            CloudFileShare share = fileClient.GetShareReference("Log");

            // Ensure that the share exists.
            if (share.Exists())
            {
                //do something
            }

            var config = new JobHostConfiguration();

            if (config.IsDevelopment)
            {
                config.UseDevelopmentSettings();
            }

            config.UseTimers();

            _logger.Log(LogLevel.Info, "Service started");
            try
            {
                if (profile == null)
                {
                    Console.WriteLine(string.Format("No Profile id : {0}", ProfileId));
                    _logger.Log(LogLevel.Info, string.Format("No Profile id : {0}", ProfileId));
                    return;
                }

                Instagram.ProfileId = profile.Id;
                //Instagram.InitPhantomDriver();
                Instagram.InitFirefoxDriver();
                Instagram.Open("https://www.instagram.com/");
                Instagram.InitCookiesAndRefreshPage(profile.ProfileName);


                if (Instagram.IsNeedToLogin())
                {
                    Instagram.Login(profile.Login, profile.Password, profile.ProfileName);
                }
                else
                {
                    _logger.Log(LogLevel.Info, "Service already logged!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Service exception: {0}", ex));
                _logger.Log(LogLevel.Error, string.Format("Service exception: {0}", ex));
            }

            var host = new JobHost(config);

            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
Exemple #13
0
        /// <summary>
        /// Defines the entry point of the application.
        /// <remarks>
        /// Please set the following connectionstring values in app.config
        /// AzureJobsRuntime and AzureJobsData
        /// </remarks>
        /// </summary>
        public static void Main()
        {
            var jobHost = new JobHost();

            jobHost.RunAndBlock();
        }
Exemple #14
0
 static void Main(string[] args)
 {
     var str = "DefaultEndpointsProtocol=https;AccountName=sychevigortestsite;AccountKey=dWDlc0DEcOvHufjiA2uZ7SjID5ZflmTeZvkhrEFIOQNFwqbZ3JNOjXgJ+GTYqvxhludZVVZBbTAQbnNTCBI/7g==";
     var host = new JobHost(str, str);
     host.RunAndBlock();
 }
Exemple #15
0
        public static void Main()
        {
            JobHost host = new JobHost();

            host.RunAndBlock();
        }
Exemple #16
0
 // Please set the following connectionstring values in app.config
 // AzureJobsRuntime and AzureJobsData
 static void Main()
 {
     JobHost host = new JobHost();
     host.RunAndBlock();
 }
Exemple #17
0
        static void Main()
        {
            CreateTestQueues();
            CreateServiceBusQueues();

            CreateServiceBusTestMessage();

            // This test message kicks off the sample on how to perform graceful
            // shutdown. It will shut down the host, so if you want to run other
            // samples, comment this out.
            CreateShutdownTestMessage();

            JobHostConfiguration config = new JobHostConfiguration()
            {
                NameResolver = new ConfigNameResolver(),
            };

            // Demonstrates the global queue processing settings that can
            // be configured
            config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(3);
            config.Queues.MaxDequeueCount    = 3;
            config.Queues.BatchSize          = 16;
            config.Queues.NewBatchThreshold  = 20;

            // Demonstrates how queue processing can be customized further
            // by defining a custom QueueProcessor Factory
            config.Queues.QueueProcessorFactory = new CustomQueueProcessorFactory();

            // Demonstrates how the console trace level can be customized
            config.Tracing.ConsoleLevel = TraceLevel.Verbose;

            // Demonstrates how a custom TraceWriter can be plugged into the
            // host to capture all logging/traces.
            config.Tracing.Trace = new CustomTraceWriter(TraceLevel.Info);

            ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration
            {
                ConnectionString = _servicesBusConnectionString,

                // demonstrates global customization of the default OnMessageOptions
                // that will be used by MessageReceivers
                MessageOptions = new OnMessageOptions
                {
                    MaxConcurrentCalls = 10
                }
            };

            // demonstrates use of a custom MessagingProvider to perform deeper
            // customizations of the message processing pipeline
            serviceBusConfig.MessagingProvider = new CustomMessagingProvider(serviceBusConfig);

            config.UseServiceBus(serviceBusConfig);

            try
            {
                SetEnvironmentVariable(Functions.ShutDownFilePath);
                JobHost host = new JobHost(config);
                host.RunAndBlock();
            }
            finally
            {
                ClearEnvironmentVariable();
            }

            Console.WriteLine("\nDone");
            Console.ReadLine();
        }
Exemple #18
0
 static void Main(string[] args)
 {
     JobHost host = new JobHost();
     host.RunAndBlock();
 }
Exemple #19
0
        /// <summary>
        /// Execute a job with some arguments
        /// </summary>
        /// <param name="verbose"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        static int ExecuteJob(bool verbose, string[] args)
        {
            // Check if a parameter is defined

            switch (args.Length)
            {
            case 0:
                Info("Running Web jobs ...");

                // WebJob is running if and only if the application has a connection string to a storage account into azure environment

                string connectionString = ConfigurationManager.ConnectionStrings[ConfigurationManager.CONNEXION_STRING_AZURE]?.ConnectionString;
                if (String.IsNullOrWhiteSpace(connectionString))
                {
                    break;
                }

                // Run a function on terminating the application by the webjob process

                System.Threading.CancellationToken cancellationToken = new WebJobsShutdownWatcher().Token;
                cancellationToken.Register(() => {
                    // The process is correctly done ...
                    // This notification is raised on closing the web jobs
                    OnClose();
                });

                // Run WebJob in continuous mode

                JobHostConfiguration config = new JobHostConfiguration();
                if (config.IsDevelopment)
                {
                    config.UseDevelopmentSettings();
                }

                config.UseTimers();

                var host = new JobHost(config);
                host.RunAndBlock();
                return(0);

            case 1:
                Info("Running test ...");

                // run a module without any function

                switch (args[0])
                {
                case "Test":
                    return((new Syncytium.WebJob.Module.Test.Job()).Run(verbose, args.RemoveAt(0, 1)));
                }
                break;

            default:
                // run a module within a function

                switch (args[0])
                {
                case Syncytium.Module.Administration.DatabaseContext.AREA_NAME:
                    break;

                case Syncytium.Module.Customer.DatabaseContext.AREA_NAME:
                    break;
                }
                break;
            }

            Usage(args);
            return(-1);
        }