Skip to content

Instantly share code, notes, and snippets.

@AnthonyGiretti
Last active December 10, 2024 15:41
Show Gist options
  • Save AnthonyGiretti/f786d799ca430d7236a0507b7dede474 to your computer and use it in GitHub Desktop.
Save AnthonyGiretti/f786d799ca430d7236a0507b7dede474 to your computer and use it in GitHub Desktop.
Example of an OrchestrationTrigger with .NET 8 isolated, Voluntarily missing some business logic)
[Function(nameof(ExportOrchestrator))]
public async Task<string> RunOrchestrator([OrchestrationTrigger] TaskOrchestrationContext context)
{
try
{
// Handling business logic
// ...
var entityId = new EntityInstanceId(nameof(ExportProcessState), entityKey);
// Handling business logic
// ...
await using (await context.Entities.LockEntitiesAsync(entityId))
{
// Define activity retry policy
var retryConfig = new retryConfig(); // Getting default config
var taskOptions = TaskOptions.FromRetryPolicy(
new RetryPolicy(
retryConfig.MaxNumberOfAttempts,
retryConfig.FirstRetryInterval,
retryConfig.BackoffCoefficient,
retryConfig.MaxRetryInterval,
retryConfig.RetryTimeout
));
var report = await context.CallActivityAsync<ReportParameters>(nameof(StorageActivity), new Parameters(), taskOptions);
// Handling business logic
// ...
}
return "Task Completed";
}
catch (Exception ex)
{
Error handling
// ...
context.SetCustomStatus($"Exception details: {ex.Message}");
return "Failure";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment