I tried to reproduce your issue. Yes, We will get Unauthorized if the specific key is not passed to the URL after deploying to azure functions.
Every Function app has some authorization levels:
- Anonymous
- Function
- Admin
- System
- User
They are defined in authLevel
attribute in function.json code file.
I tried with Admin authLevel to run the function and to get the 401 unauthorized, I given the function key in the function app URL:
Now I have Host (_master) key to the function app URL along with the query string parameter (name), then the result is:
Hence,
We get unauthorized when suitable keys are not passed to the function app URL. Based on the authLevel, we have to pass the keys in the URL.
Anonymous - no authentication is required. Any valid HTTP request passes
Function - host (master) and function keys.
Admin - requires a host key for authorization.
System - requires the master key of a function app for authorization.
User - requires a valid authentication token.
Function, Admin & System authorization level are key based.
For more information on authorization level usage in function app, refer here.