private static async Task <ICommandResult> StartCommandOrchestration(IDurableClient durableClient, IOrchestratorCommand orchestratorCommand) { var orchestratorCommandMessage = new OrchestratorCommandMessage(orchestratorCommand); var orchestratorCommandResult = orchestratorCommand.CreateResult(); var orchestratorCommandOrchestration = orchestratorCommand switch { _ => $"{orchestratorCommand.GetType().Name}Orchestration" }; try { var instanceId = await durableClient .StartNewAsync <object>(orchestratorCommandOrchestration, orchestratorCommand.CommandId.ToString(), orchestratorCommandMessage) .ConfigureAwait(false); var status = await durableClient .GetStatusAsync(instanceId) .ConfigureAwait(false); orchestratorCommandResult.ApplyStatus(status); } catch (FunctionFailedException exc) { orchestratorCommandResult.Errors.Add(exc); } return(orchestratorCommandResult); } }
private static async Task RollbackAsync(IDurableOrchestrationContext functionContext, OrchestratorProjectCreateCommand command) { var systemUser = await functionContext .CallActivityWithRetryAsync <User>(nameof(TeamCloudUserActivity), null) .ConfigureAwait(true); var deleteCommand = new OrchestratorProjectDeleteCommand(systemUser, command.Payload); var deleteCommandMessage = new OrchestratorCommandMessage(deleteCommand); functionContext .StartNewOrchestration(nameof(OrchestratorProjectDeleteCommandOrchestration), deleteCommandMessage); }