Azure-functions-host: Preserve datatype constraints provided in HttpTrigger route

Created on 5 Jan 2018  路  16Comments  路  Source: Azure/azure-functions-host

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.

P1 improvement

Most helpful comment

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

All 16 comments

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)

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

This is still a problem.

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

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.

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

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

+1 ran into this issue as well.

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

+1 Guid in POCO fails.

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

+1 Guid in POCO fails.

Any updates on this?

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ElvenSpellmaker picture ElvenSpellmaker  路  3Comments

silencev picture silencev  路  4Comments

mathewc picture mathewc  路  3Comments

rati3l picture rati3l  路  3Comments

silencev picture silencev  路  3Comments