Azure / Azure/azure-functions-host

HttpTrigger cannot bind to customobject named "data"

Open
#6,748 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

This happens running it locally using the Azure Core Tools. Never tried it on Azure.

#### Investigative information

Please provide the following:

- Timestamp: 2020-10-03 10:39
- Function App version: 0
- Function App name: MyFunctionApp
- Function name(s) (as appropriate): MyFunction
- Invocation ID:
- Region:

#### Repro steps

Provide the steps required to reproduce the problem:

1. Create a new Azure Function App in Visual Studio 2019 (16.7.5)
2. Choose HttpBinding
3. Replace the HttpReqeust with a custom class. See code below

``` csharp
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;

namespace FunctionApp
{
public class MyFunctionApp
{
[FunctionName("MyFunction")]
public IActionResult Run([HttpTrigger()] CustomObject data)
{
return new OkResult();
}
}

public class CustomObject
{
public string Data { get; set; }
}
}

```
4. Run it with F5

#### Expected behavior
A normal run where the Core Tools tell me on what port my application is listening.

#### Actual behavior
A runtime error:

[2020-10-03T08:46:01.699] Microsoft.Azure.WebJobs.Host: Error indexing method 'MyFunction'. Microsoft.Azure.WebJobs.Host: Can't bind parameter 'data' to type 'FunctionAPp.CustomObject'.
[2020-10-03T08:46:01.748] Error indexing method 'MyFunction'
[2020-10-03T08:46:01.750] Microsoft.Azure.WebJobs.Host: Error indexing method 'MyFunction'. Microsoft.Azure.WebJobs.Host: Can't bind parameter 'data' to type 'FunctionAPp.CustomObject'.

#### Known workarounds
There are two workarounds:
1. Name the parameter to the function anything else than "data".
2. Name the property of the custom object anything else than "Data"

#### Related information
C#

CSPROJ:
``` xml


netcoreapp3.1
v3






PreserveNewest


PreserveNewest
Never

```

Contributor guide

Open the contributing guide

Research direction

Start with the MyFunction entry point and reproduce the binding failure using the provided CustomObject example in Visual Studio with Azure Core Tools. Compare the behavior when the parameter or property is renamed, then verify that a custom object named data binds without the runtime indexing error.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.