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

Cannot bind parameter '$return' to type IActionResult #3061

Open
andremiranda-act3d opened this issue Feb 29, 2024 · 2 comments
Open

Cannot bind parameter '$return' to type IActionResult #3061

andremiranda-act3d opened this issue Feb 29, 2024 · 2 comments

Comments

@andremiranda-act3d
Copy link

Hi! When executing ServiceBusTrigger or TimeTrigger Functions, I got this exception:

The 'CrmOrderSubscriptionFunction' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'CrmOrderSubscriptionFunction'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter '$return' to type IActionResult&. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

Before, all the Functions were returning a Task and they were working just fine. But, many of these Functions call to some external apis and we would like to get these calls responses and make the Functions return them. Otherwise, the Functions are always returning a 200 (or at maximum a 500 if it is something out of our control).

We have 1 HttpTrigger function that is not throwing this exception. Only the ServiceBus and TimeTrigger ones.

We are using .NET 6. Don't know if the host.json is necessary, but currently in VS is like this:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    },
    "logLevel": {
      "Default": "Debug"
    }
  },
  "extensions": {
    "queues": {
      "maxPollingInterval": "00:00:02",
      "visibilityTimeout": "00:00:30",
      "batchSize": 1,
      "maxDequeueCount": 2,
      "newBatchThreshold": 0
    },
    "serviceBus": {
      "messageHandlerOptions": {
        "maxConcurrentCalls": 2
      },
      "sessionHandlerOptions": {
        "maxConcurrentSessions": 1
      }
    }
  }
}
@bhagyshricompany
Copy link

Thanks for reporting please share the all repro steps

@andremiranda-act3d
Copy link
Author

Just setting up a ServiceBusTriggered or TimerTrigger Function like below and the exception will be thrown at startup:

 [FunctionName(FunctionName)]
    public override async Task<IActionResult> Main([ServiceBusTrigger(TopicName, IdentitySubscriptionName, Connection = "ServiceBusConnection")] string request, ExecutionContext executionContext)
    {
        return await base.Main(request, executionContext);
    }

base.Main also returns an IActionResult.

Our local.settings.json looks like this (just a piece of the file):

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "ServiceBusConnection": "UseDevelopmentStorage=true",

    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
}

The "problem" is that our Function project is not using a regular HostBuilder, it's abstracting with a lot of interfaces. So, for example, I created a new Function project as a test and I could create this:

Program.cs

using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
    .ConfigureFunctionsWebApplication()
    .Build();

host.Run();

We don't have a Program.cs in our solution, just a Startup with a bunch Configure. Maybe I would need to re-create the Function solution, but for now that's not an option.

So, that's why I'm trying to figure out this without having to create a new solution and start from scratch.

Thanks!

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

No branches or pull requests

2 participants