0

I have a problem with passing class object as an input parameter to azure function, what is the proper way of doing it? I have function like posted below.

    public async Task<IActionResult> GetClinics(
        [HttpTrigger(AuthorizationLevel.Function, "get", Route = "clinics")] HttpRequest req, ILogger log, PersonDocument thePerson)
    {
        //do something
    }

Error that i got:

The 'GetClinics' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'GetClinics'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'thePerson' to type PersonDocument. 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.).

what is the simplest way to solve it? Do i have to prepare my own custom binding? PersonDocument is just a class with some properties that i would like to extract from body. The only information that i found show how to add custom binding with custom attribute, but I am curious if it is really required to add them to solve such an easy problem?

1 Answer 1

1

Method signatures developed by the azure function C # class library can only include these:

ILogger or TraceWriter for logging (v1 version only)

A CancellationToken parameter for graceful shutdown

Mark input and output bindings by using attribute decoration

Binding expressions parameters to get trigger metadata

For your question, what you need seems a input binding, so have a look of this doc:

https://learn.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#supported-bindings

You can see that only a few input bindings is support by azure function by default. So I think if you want to achieve what you want, custom binding is needed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.