To recreate my exact issue, create 2 new HTTP triggered function endpoints for a node.js 22 Azure Function v4 (latest version). Nothing fancy in the code, you can use the boiler plate code. One is public and the other is private (name them as such). Publish those to a web app (on Azure App Service) since we want to use Easy Auth. You need to have the Authentication tab (this is Easy Auth) of the web app configured with at least one identity provider and make sure it requires authentication. The web app should have an environment variable called WEBSITE_WARMUP_PATH
set to a value of /api/public,/api/public/,/api/public*,/api/public/*
(in my testing it seems the *'s don't act as wildcards like you think they might). Now test by hitting these new function endpoints in the browser. The private endpoint should give you a 401 as expected. The public endpoint should give you a normal response which is great.
Now add something like this to the public function route: 'public/{*id}'
. Route can of course can change the name of the function in the URL but notice we didn't do that here since we called it public. I also made id optional (that's the * next to id). Deploy that code and test again in your browser, all is good like it was before except when you do .../api/public/1
you get a 401 unauthorized response. Interestingly you can get a good response by going to ../api/public/*
so the environment variable is very specific it seems. However, that is not my desired result.
What is the proper way to format my environment variable to allow this route option code to function properly?
I could create another Azure Function and not use Easy Auth on my public function but that makes it more code for me and more things to manage which is unfortunate. Or is there a better more effective way I am missing?