0

Inputs:

  1. We have several azure functions in one resource group.
  2. 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?

Nikita
  • 1,019
  • 2
  • 15
  • 39

1 Answers1

0

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.

  • Go to Azure portal>> select function app>> Select the function which you want to allow access. Here i am taking Http trigger1 function.
  • In Functions over view page select Function keys>> + New function key >> As shown in below image enter name for your function key and select save by default it provides value to the key. You can save that value.

enter image description here

  • 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. enter image description here

  • 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.

vijaya
  • 1,525
  • 1
  • 2
  • 6
  • thank you for the answer, it is a valid way to update function level authorization, however in that case you have to provide both: 'accessToken' and 'functionKey', the desires result "when key is provided **instead of** access token", so it means we would like turn off function app security level for one of the functions. Now I know, it is impossible and actualy such possiblity may be a cumbersome (when function app secure, but functions inside not). Going to post an answer once we found solution. – Nikita Apr 18 '23 at 08:32