public void Execute()
        {
            // Read task body
            string taskMessageBody;

            using (var receiveStream = this.Request.Body)
            {
                using (var sr = new StreamReader(receiveStream, Encoding.UTF8))
                {
                    taskMessageBody = sr.ReadToEnd();
                }
            }

            // Since we expect all the VSTS properties to be in the request headers, fetch them from the headers
            //
            var taskProperties = GetTaskProperties(this.Request.Headers);

            // Create my own task execution handler. You should replace it with your task execution handler.
            ITaskExecutionHandler myTaskExecutionHandler = new MyTaskExecutionHandler();

            var executionHandler = new ExecutionHandler(myTaskExecutionHandler, taskMessageBody, taskProperties);
            var executionThread  = new Thread(() => executionHandler.Execute(CancellationToken.None));

            executionThread.Start();
        }
Ejemplo n.º 2
0
        public async Task ReceiveAsync(ServiceBusMessage message, CancellationToken cancellationToken)
        {
            try
            {
                var executionHandler = new ExecutionHandler(taskExecutionHandler, message.GetBody(), message.GetMyProperties());
                await executionHandler.Execute(cancellationToken).ConfigureAwait(false);

                await this.queueClient.CompleteAsync(message.GetLockToken()).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Trace.TraceError("{0}", ex);

                // You can add code to abandon the service bus message or put the message in dead letter queue
            }
        }
Ejemplo n.º 3
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            // Get request body
            var messageBody = await req.Content.ReadAsStringAsync().ConfigureAwait(false);

            // Since we expect all the VSTS properties to be in the request headers, fetch them from the headers
            //
            var taskProperties = GetTaskProperties(req.Headers);

            // Create my own task execution handler. You should replace it with your task execution handler.
            ITaskExecutionHandler myTaskExecutionHandler = new MyTaskExecutionHandler();

            var executionHandler = new ExecutionHandler(myTaskExecutionHandler, messageBody, taskProperties);
            var executionThread  = new Thread(() => executionHandler.Execute(CancellationToken.None));

            executionThread.Start();

            return(req.CreateResponse(HttpStatusCode.OK, "Request accepted!"));
        }
Ejemplo n.º 4
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            TypeDescriptor.AddAttributes(typeof(IdentityDescriptor), new TypeConverterAttribute(typeof(IdentityDescriptorConverter).FullName));
            TypeDescriptor.AddAttributes(typeof(SubjectDescriptor), new TypeConverterAttribute(typeof(SubjectDescriptorConverter).FullName));
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            // Get request body
            var messageBody = await req.Content.ReadAsStringAsync().ConfigureAwait(false);

            // Since we expect all the VSTS properties to be in the request headers, fetch them from the headers
            //
            var taskProperties = GetTaskProperties(req.Headers);

            // Create my own task execution handler. You should replace it with your task execution handler.
            ITaskExecutionHandler myAzureFunctionSampleHandler = new MyTaskExecutionHandler();

            var executionHandler = new ExecutionHandler(myAzureFunctionSampleHandler, messageBody, taskProperties);

            Task.Run(() => executionHandler.Execute(CancellationToken.None));

            return(req.CreateResponse(HttpStatusCode.OK, "Request accepted!"));
        }
Ejemplo n.º 5
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            TypeDescriptor.AddAttributes(typeof(IdentityDescriptor), new TypeConverterAttribute(typeof(IdentityDescriptorConverter).FullName));
            TypeDescriptor.AddAttributes(typeof(SubjectDescriptor), new TypeConverterAttribute(typeof(SubjectDescriptorConverter).FullName));
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            // Get request body
            var messageBody = await req.Content.ReadAsStringAsync().ConfigureAwait(false);

            // Fetch all the VSTS properties from the headers
            var taskProperties = GetTaskProperties(req.Headers);

            // Created task execution handler
            ITaskExecutionHandler myTaskExecutionHandler = new MyTaskExecutionHandler();

            var executionHandler = new ExecutionHandler(myTaskExecutionHandler, messageBody, taskProperties);
            var executionThread  = new Thread(() => executionHandler.Execute(CancellationToken.None));

            executionThread.Start();

            return(req.CreateResponse(HttpStatusCode.OK, "Request accepted!"));
        }
        public void Execute(CancellationToken cancellationToken)
        {
            var executionHandler = new ExecutionHandler(taskExecutionHandler, taskProperties);

            executionHandler.Execute(cancellationToken);
        }