Bypassing Easy Auth for a Specific v4 Azure Function Endpoint in Node.js 22

ShawnPOWER 0 Reputation points
2024-12-26T17:16:23.5666667+00:00

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?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,311 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Khadeer Ali 1,790 Reputation points Microsoft Vendor
    2024-12-26T22:00:50.51+00:00

    @ShawnPOWER ,

    Welcome to the Microsoft Q&A Platform!

    Thank you for reaching out about Bypassing Easy Auth for a Specific v4 Azure Function Endpoint.

    We can consider setting the authLevel for this specific function to anonymous. This configuration is designed to bypass Easy Auth for that endpoint, allowing unauthenticated access as intended.

    Could you give this a try and see if it resolves the issue? While this approach aligns with Azure Function configurations, there might still be edge cases depending on your setup. If it doesn’t work as expected, I’d be happy to explore other options with you.
    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.