Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.92k stars 441 forks source link

Preserve datatype constraints provided in HttpTrigger route #2279

Open pragnagopa opened 6 years ago

pragnagopa commented 6 years ago

Route Constraints allow specifying datatypes for query string parameters on HttpTrigger route property. These constraints are only used to match the route. When using binding parameters datatype is converted to strings. For example:

{
  "disabled": false,
  "bindings": [{
      "authLevel": "admin",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get"
      ],
      "route": "InventoryPosition/{locationNumber:int}/{itemNumber:int}"
    },
    {
      "name": "inventoryPositions",
      "type": "documentdb",
      "direction": "in",
      "databaseName": "ihub",
      "collectionName": "inventoryPosition",
      "sqlQuery": "SELECT * FROM c WHERE c.locationNumber = udf.toInt({locationNumber}) AND c.itemNumber = udf.toInt({itemNumber})",
      "connection": "DOCUMENTDB_CONNECTIONSTRING"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}

locationNumber and itemNumber have int constraints but are converted to string when using then doccument db query string.

christopheranderson commented 6 years ago

Should this be in the extensions repo, or is this behavior in the webhost? https://github.com/Azure/azure-webjobs-sdk-extensions/tree/dev/src/WebJobs.Extensions.Http (@fabiocav @mathewc)

wilkovanderveen commented 5 years ago

Is there any update on this one? We still are experiencing this issue using .NET core 2.1 functions.

Sorrien commented 5 years ago

This is still a problem.

itsknob commented 5 years ago

The only current workaround is the User Defined Function to convert the string to a number from azure-webjobs-sdk-extensions#533.

Sorrien commented 5 years ago

That seems to be related to Cosmos triggers. My issue is with binding Guids in my model in an http trigger azure function. The solution for me was to take it in as a string and parse it as a Guid myself.

gdodd1977 commented 5 years ago

Is there any update on this? It would be nice to be able to use POCOs with HttpTrigger that have Guids.

jchannon commented 5 years ago

Just hit this today, assumed it was using asp.net core routing under the hood but clearly not.

espray commented 5 years ago

+1 ran into this issue as well.

pijemcolu commented 5 years ago

+1 same issue with a guid in .NetCore functions 2.1

ahaugedk commented 5 years ago

+1 Guid in POCO fails.

roeb commented 5 years ago

+1 the same issue here. Expecting a guid from the route prameters.

kristianGNI commented 5 years ago

+1 Guid in POCO fails.

itsknob commented 5 years ago

Any updates on this?

fabiocav commented 5 years ago

Thank you for the feedback.

Assigning this for triage again since it didn't make it in the a previous sprint it was allocated to.

gzuber commented 5 years ago

After looking into the original issue, the issue with Guids being parsed as strings when using route constraints is unrelated. That issue is tracked/resolved in #2960

fabiocav commented 4 years ago

@gzuber was this meant to be closed? Any follow up items from your previous investigation?