I’m trying to construct the function.json file where the url has a custom ending that we don’t know. This customer ending may include forward slashes so I can’t be guaranteed this will be one parameter. My current code :
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"route": "{param1}/customer/{param2}/{restOfUrl}",
"name": "req",
"methods": [
"get"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"scriptFile": "../dist/src/handlers/myScript.js"
}
this works fine when for example the url is:
...123/customer/456/rest-of-url
however if the rest of the url contains forward slashes eg:
...123/customer/456/rest/of/url
I get a 404 not found.
How do I correctly define the route if the url is unknown and will likely include forward slashes / ?
2
Answers
After trying the suggested solution I discovered this doc in Azure documentation. The solution was to * the remaining parameter which returns the remainder of the path as a string. The change looks as so :
There is an appsetting to disable the url encoding so that it will match a full path. By default slashes are encoded as
%2F
https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#azure_function_proxy_backend_url_decode_slashes