Inputs:
- We have several azure functions in one resource group.
- We can access that functions only with the access token.
we need to allow access to one of the funciton only when key is provided instead of access token
Could we somehow achieve that?
we need to allow access to one of the funciton only when key is provided instead of access token Could we somehow achieve that?
Yes, you can achieve this by using function keys. Function keys are a secure way to authenticate and authorize access to your functions. You can create a function key for a specific function and use it to authenticate requests to that function. Here the steps to create function key and value.
In the function's code editor, open the function.json
file and add the authLevel as function to the function.json
file and save it.
Change to "authLevel": "function"
and save it.
Get the function key from the request headers and validate it in your function code before granting access to the function. In this way you can create and use function key for access.
In General , Three degrees of authentication are available in Azure Functions: anonymous, function, and host1. So, You can use function-level authorization to only permit access to an Azure Function when a key is supplied. To use a given function, you can establish a function key and distribute it to the authorized users.
Refer this SO thread it may helps.