Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function Indexing Exception with WebJobs SDK for Integration Test #3053

Open
kolexinfos opened this issue Jan 11, 2024 · 1 comment
Open

Comments

@kolexinfos
Copy link

kolexinfos commented Jan 11, 2024

I am trying to use the WebJobs SDK with the below configuration to run Integration Test for Azure Activity and Durable functions(v4, .Net6.0) as done here but running into the below exception .

Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException : Error indexing method 'ForceRefreshTrigger'
---- System.InvalidOperationException : Functions must return Task or void, have a binding attribute for the return value, or be triggered by a binding that natively supports return values.

When I change the Function return type to something different from IActionResult the Indexing seem to work without issues so I was wondering if this is the issue but it works using the Azure Functions SDK when I ran the same set of functions in Visual Studio(Azure Function Core Tools).

I also observed that when I remove the [DurableClient] IDurableOrchestrationClient durableClient, the function indexing also does not throw the above exception. So I am not sure what the root cause of this problem is looking at these 2 anomalies.

public static async Task<ActionResult> ForceRefreshTrigger(
      [HttpTrigger(AuthorizationLevel.Anonymous, "post"/{operations/refresh")] HttpRequest request,
        string orgId,
        string taskId,
        [DurableClient] IDurableOrchestrationClient durableClient)
{
	........................
}

functionsHost = new HostBuilder()
             .ConfigureAppConfiguration(builder =>
             {
                 builder.SetBasePath(Directory.GetCurrentDirectory())
                     .AddJsonFile("appsettings.taskfunction.json", optional: true, reloadOnChange: true);
             })
            //.ConfigureFunctionsWorkerDefaults()
            .ConfigureWebJobs(builder =>
            {
                builder.AddAzureStorageCoreServices();
                builder.AddAzureStorage();
                builder.AddTimers();
                builder.AddDurableTask(options =>
                {
                    options.HubName = this.taskHubName;
                    options.StorageProvider["type"] = "AzureStorage";
                    options.StorageProvider["connectionStringName"] = "AzureWebJobsStorage";

                });

            })
            .ConfigureServices(services =>
            {
		services.AddSingleton<ITaskResolverService>(this.tyeResolveService)
            })
             .Build();

 await this.functionsHost.StartAsync();

Repro steps

Provide the steps required to reproduce the problem

  1. Create HttpTriggered or TimerTriggered function with the signature similar to the above.

  2. Setup a WebJobs host builder configuration above

Expected behavior

The WebJobs SDK should run the Functions successfully

Actual behavior

Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException : Error indexing method 'ForceRefreshTrigger'
---- System.InvalidOperationException : Functions must return Task or void, have a binding attribute for the return value, or be triggered by a binding that natively supports return values.

Known workarounds

Change the return type but this would not work for my scenario as we have lots of functions with similar signature that we want to run Integration Test on.

Related information

Provide any related information

  • Package version
    Microsoft.Azure.WebJobs.Extensions: 3.0.6
    Azure Function: v4
  • Links to source
@bananamufu
Copy link

I'm experiencing the same issue. If you remove the binding, the function won't work in azure. If you keep it, the integration tests don't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants