azure-webjobs-sdk-extensions icon indicating copy to clipboard operation
azure-webjobs-sdk-extensions copied to clipboard

Can't use a literal '.'(dot) as separator in HttpBinding routes.

Open luciobemquerer opened this issue 5 years ago • 2 comments

I have the following route set for a http triggered function:

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "name": "req",
      "type": "httpTrigger",
      "direction": "in",
      "methods": [
        "get"
      ],
      "route": "image/{filename:regex(^[0-9a-zA-Z-]+$)}.{ext:regex(^(jpeg|bmp|png)$)?}"
    },
    {
      "name": "$return",
      "type": "http",
      "direction": "out"
    },
    {
      "name": "imageBlob",
      "type": "blob",
      "path": "images/{recordId}/{imageId}",
      "connection": "ImagesStorage",
      "direction": "inout"
    }
  "disabled": false
}

The functions host is giving me the following error:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.image-GET'. Microsoft.Azure.WebJobs.Host: No binding parameter exists for 'filename'.

According to ASP.NET documentation, this should be a valid route: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-2.2#route-template-reference

Removing the .{ext:regex(^(jpeg|bmp|png)$)?} from the route "fixes" the error, but I need to allow optional file extensions in the url.

I'm running [email protected]

luciobemquerer avatar Jan 23 '19 04:01 luciobemquerer

What I did to work around this issue is to create a proxy that includes the .ext in the route and then have it forward to the actual implementation route. I didn't need the actual extension but if you do you can capture it as a parameter (e.g. .{ext}) and pass it in as a route segment.

Reach out to me if you want more details on this.

DarinMacRae avatar Feb 18 '19 20:02 DarinMacRae

Thanks @DarinMacRae! I did use a work around as well. I still believe this issue should be addressed in the framework level.

luciobemquerer avatar Feb 18 '19 22:02 luciobemquerer