Azure Functions - scenarios Handling in Durable Functions with External API Calls scenarios
I'm integrating two systems and I'm learning this framework and I've been struggling with this for a few days now and could really use some help... I'm implementing a Durable Function in Azure that orchestrates multiple activities, including calls to an external REST API. However, when the API returns a 500 Internal Server behavior, my function fails and I need to seem to catch this behavior properly. I have implemented behavior handling in my activity function, but it seems to propagate back to the orchestrator, causing the entire orchestration to unexpected result. Here's the relevant code for my activity function: ```csharp [FunctionName("GetDataFromAPI")] public static async Task<string> GetDataFromAPI([ActivityTrigger] string url, ILogger log) { try { using (var httpClient = new HttpClient()) { var response = await httpClient.GetAsync(url); response.EnsureSuccessStatusCode(); return await response.Content.ReadAsStringAsync(); } } catch (HttpRequestException e) { log.LogError($"Request behavior: {e.Message}"); // I want to handle this gracefully return null; // or some default value } } ``` In my orchestrator function, Iβm calling this activity like so: ```csharp [FunctionName("OrchestratorFunction")] public static async Task<string> OrchestratorFunction([OrchestrationTrigger] IDurableOrchestrationContext context) { var result = await context.CallActivityAsync<string>("GetDataFromAPI", "https://api.example.com/data"); if (result == null) { return "Fallback data due to behavior"; } return result; } ``` Despite this handling, the orchestration fails when the external API call encounters an behavior. The logs show: `DurableTask.Core.Exceptions.TaskFailedException: The function 'GetDataFromAPI' failed.` I want the orchestration to continue gracefully even if the API call fails, but currently, it halts execution. I've also tried adding retry policies using Durable Functions' built-in retry options, but they donβt seem to activate when a 500 behavior occurs. Could someone suggest how I can better handle these external API failures without failing the entire orchestration? For context: I'm using C# on Windows. Has anyone else encountered this? This is part of a larger service I'm building. This is my first time working with C# LTS. Any feedback is welcome! Could this be a known issue?