azure-webjobs-sdk-extensions
azure-webjobs-sdk-extensions copied to clipboard
order HTTP routes in a logical way
Consider two routes:
/api/recent /api/{id}
Currently, Azure Functions orders routes by the alphabetical order of the function name, so it is non-deterministic as to which route will be choosen if a request for '/api/recent' comes in depending on the names of the functions.
This PR makes the order deterministic and sensible. It prefers static segments over parameterized segments (will always pick '/api/recent' for a request of '/api/recent' even though '/api/{id}' is also a match) and prefers more-specific (longer) routes over less-specific (shorter) routes if everything else is the same.
Addresses: https://github.com/Azure/azure-functions-host/issues/3153 https://github.com/Azure/azure-functions-core-tools/issues/2442 https://github.com/Azure/azure-functions-host/issues/3152 https://github.com/MicrosoftDocs/azure-docs/issues/11755
cc @fabiocav
Please consider this PR. It dramatically improves the logic of how functions handles routes. The PR has been open since April!
Any progress on this? Our team would use this - our use case is that we have multiple routes defined, but also need to add a route at the root of the cname and want the more specific routes to take precedence over a wildcard match at the root. Either this or supporting Order on the HttpTriggerAttribute would support this scenario. Otherwise, we're implementing our own custom logic to route to sub-paths in a single function at the root.
Just also found this note that states that routes are considered alphabetically by FunctionName - https://github.com/Azure/azure-functions-host/issues/3153#issuecomment-1073158123 - this should work for our scenario by prefixing the function with z_.
Could also use this in the workers SDK...