question

KenFaubel-7867 avatar image
0 Votes"
KenFaubel-7867 asked KenFaubel-7867 commented

azure function authLevel anonymous requests authentication

I have been working with Azure functions with timer triggers for a while but I am now trying to get an httpTrigger to work and I must be doing something dumb. My project uses Nodejs (16) and I want anonymous access so I have my function.json setup like this:

 {
   "bindings": [
     {
       "authLevel": "anonymous",
       "type": "httpTrigger",
       "direction": "in",
       "name": "req",
       "methods": [ "get" ],
       "route": "test/{key:alpha}"
     },
     {
       "type": "http",
       "direction": "out",
       "name": "res"
     }
   ],
   "scriptFile": "../dist/test/index.js"
 }

When I run it locally with Advanced REST Client the function gets called and everything is good.

When I deploy it to Azure and run the request again it prompts with "Authentication required, The endpoint requires user credentials".

I looked around the settings in the Azure portal and everything looks OK to me. I see this and my other trigger functions and I can see under Integration that the function is setup for anonymous authorization.

I have been digging through articles about but no clues as to what I am doing wrong. Any ideas?

Many thanks

Ken

azure-functions
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hmm, function.json looks correct. Can you check the Authentication in the Function App Level, just to make sure there's nothing set there?
193616-image.png


0 Votes 0 ·
image.png (37.9 KiB)

Thanks, let me check...

I checked there and all I see is an option to "Add an identity provider".

I also tried creating a new Azure Function project in VSCode called kfunctest with a single trigger called test. I picked anonymous for the authLevel and left everything else as the default. The function.json is the same as above except for the scriptFile which points to a different index.js file. I am using typescript but I did not make any changes to the index.ts file.

When I run it with curl I get:

 ~/OneDrive/projects $ curl -i https://kfunctest.scm.azurewebsites.net/api/test
 HTTP/1.1 401 Unauthorized
 Content-Length: 0
 Date: Sun, 17 Apr 2022 15:23:14 GMT
 WWW-Authenticate: Basic realm="site"

I am wondering where in the world the 'basic auth" is coming from. As above the Authorization tab just has an option to "Add identity provider"




0 Votes 0 ·

@KenFaubel-7867 , Could you please provide the screenshot of the auth prompt "Authentication required, The endpoint requires user credentials" ?
The kfunctest app doesnt have any authentication mechanism as I checked it from my end. Is there any auth libraries that you are using in the code?

0 Votes 0 ·
Show more comments

0 Answers