Last active
December 10, 2024 15:41
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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