コード例 #1
0
 public static async Task HandleApiReplyQueue([QueueTrigger(nameof(HandleApiReplyQueue), Connection = "csb15feceb925a5x4498xa55_STORAGE")] StartJobDto data,
                                              ILogger log)
 {
     await Task.Run(() =>
     {
         log.LogInformation($"Handled Job: {data.JobId}");
     });
 }
コード例 #2
0
        public static async Task CallChildApi([ActivityTrigger] StartJobDto dto, [Queue(nameof(CallChildApi)), StorageAccount("csb15feceb925a5x4498xa55_STORAGE")] ICollector <StartJobDto> msg)
        {
            await Task.Delay(dto.Delay); // wait xx milliseconds

            await Task.Run(() =>
            {
                msg.Add(dto);
            });
        }
コード例 #3
0
        public static async Task QueueStart([QueueTrigger(nameof(QueueStart), Connection = "csb15feceb925a5x4498xa55_STORAGE")] StartJobDto data,
                                            [OrchestrationClient] DurableOrchestrationClient starter,
                                            [Queue(nameof(HandleApiReplyQueue)), StorageAccount("csb15feceb925a5x4498xa55_STORAGE")] ICollector <StartJobDto> msg,
                                            ILogger log)
        {
            string instanceId = await starter.StartNewAsync(nameof(DurableFunctionsOrchestration), data);

            msg.Add(data);
        }
コード例 #4
0
        public static async Task <StartJobDto> DurableFunctionsOrchestration(
            [OrchestrationTrigger] DurableOrchestrationContext context, ILogger log)
        {
            StartJobDto input = context.GetInput <StartJobDto>();

            input.InstanceId = context.InstanceId;

            await context.CallActivityAsync(nameof(CallChildApi), input);


            var result = await context.WaitForExternalEvent <StartJobDto>(input.JobId.ToString());

            return(result);
        }
コード例 #5
0
        public static async Task <HttpResponseMessage> HttpStart(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestMessage req,
            [OrchestrationClient] DurableOrchestrationClient starter,
            ILogger log)
        {
            string value = await req.Content.ReadAsStringAsync();

            StartJobDto data       = Newtonsoft.Json.JsonConvert.DeserializeObject <StartJobDto>(value);
            string      instanceId = await starter.StartNewAsync(nameof(DurableFunctionsOrchestration), data);



            log.LogInformation($"Started orchestration with ID = '{instanceId}' for {data.JobId}.");
            if (!data.Async)
            {
                return(await starter.WaitForCompletionOrCreateCheckStatusResponseAsync(req, instanceId));
            }
            else
            {
                return(starter.CreateCheckStatusResponse(req, instanceId));
            }
        }
コード例 #6
0
 public static async Task HandleChildApiQueue([QueueTrigger(nameof(CallChildApi), Connection = "csb15feceb925a5x4498xa55_STORAGE")] StartJobDto data,
                                              [OrchestrationClient] DurableOrchestrationClient client)
 {
     await client.RaiseEventAsync(data.InstanceId, data.JobId.ToString(), data);
 }