-
Notifications
You must be signed in to change notification settings - Fork 280
Description
Description
When an orchestrator call an activity with no parameters data, the warning DURABLE2001
is raised with the following message: CallActivityAsync is passing the incorrect type 'none' instead of 'FunctionContext' to the activity function 'GetData'
.
To reproduce the warning of the analyzer:
public static class Function1
{
[Function(nameof(Function1))]
public static async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] TaskOrchestrationContext context)
{
ILogger logger = context.CreateReplaySafeLogger(nameof(Function1));
logger.LogInformation("Saying hello.");
var outputs = new List<string>();
outputs.Add(await context.CallActivityAsync<string>(nameof(GetData))); // Here a warning DURABLE2001 is display.
return outputs;
}
[Function(nameof(GetData))]
public static string GetData([ActivityTrigger] FunctionContext executionContext)
{
return $"THE DATA !!!";
}
[Function("Function1_HttpStart")]
public static async Task<HttpResponseData> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
[DurableClient] DurableTaskClient client,
FunctionContext executionContext)
{
ILogger logger = executionContext.GetLogger("Function1_HttpStart");
// Function input comes from the request content.
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
nameof(Function1));
logger.LogInformation("Started orchestration with ID = '{instanceId}'.", instanceId);
// Returns an HTTP 202 response with an instance management payload.
// See https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-http-api#start-orchestration
return await client.CreateCheckStatusResponseAsync(req, instanceId);
}
}
Remarks: The is no data passed as argument. Only a
FunctionContext
parameter is declared because we need at least one parameter to declare the activity binding with[ActivityTrigger]
.
Expected behavior
When we call the CallActivityAsync()
method to an activity which take no parameters, no warning DURABLE2001
should be raised by the compiler.
Actual behavior
When we call the CallActivityAsync()
method to an activity which take no parameters, a warning DURABLE2001
is display during the compilation.
Relevant source code snippets
There is a repository which contains a complete sample to reproduce the error : https://github.com/GillesTourreau/DurableAnalyzersIssueActivityWithFunctionContext
Known workarounds
Provide a description of any known workarounds you used.
App Details
- Durable Functions extension version (e.g. v1.8.3): v1.8.0
- Azure Functions runtime version (1.0 or 2.0): 4.0
- Programming language used: .NET / C#