public async Task Orchestrator( [OrchestrationTrigger] IDurableOrchestrationContext context) { var commandHookContext = context.GetInput <CommandHookContext>(); var response = await context.CallActivityAsync <EntityStateResponse <PullRequestStateContext> >(nameof(PullRequestEntity) + "_GetPullRequestStateContext", commandHookContext.PullRequestUri.GetEntityId()); // Ignore if the Decoration has not finished. if (response.EntityExists) { PullRequestStateContext pullRequestStateContext = response.EntityState; switch (CommandRouter.GetValueOrDefault(commandHookContext.Command)) { case CommandRouter.CreateWorkItemCommand: // GetIssue that match Scan Provider. You can find the ScanProvider from response. await CreateWorkItem(context, pullRequestStateContext, commandHookContext); break; case CommandRouter.IssueTransitionCommand: await TransitIssueAsync(context, pullRequestStateContext, commandHookContext); break; default: // Create Sorry Comment await context.CallActivityAsync(nameof(CommandOrchestrator) + "_" + BotConfiguration.RepositoryProvider + "_CreateSimpleReplyComment", new CreateSimpleReplyCommentContext() { Body = $"Command [{commandHookContext.Command}] hasn't been supported. Ask bot administrator.", InReplyTo = commandHookContext.ReplyToId, PullRequestId = commandHookContext.PullRequestId }); break; } // Update the CurrentPullRequestStatus await context.CallEntityAsync <PullRequestStateContext>( new EntityId(nameof(PullRequestEntity), commandHookContext.PullRequestUri.GetEntityId()), "update", pullRequestStateContext); } else { await context.CallActivityAsync(nameof(CommandOrchestrator) + "_" + BotConfiguration.RepositoryProvider + "_CreateSimpleReplyComment", new CreateSimpleReplyCommentContext() { Body = "Security Decoration seems not finished. Wait until the PullRequest validation CI has done.", InReplyTo = commandHookContext.ReplyToId, PullRequestId = commandHookContext.PullRequestId }); } }