If you are developing an API using Azure Functions that can be used by multiple applications, then it's good practice to have a different function key for each client application that is going to use your functions.
Navigate to the Manage tab of Azure Functions to view and manage all the keys related to the function.
By default, a key with the name default is generated for us. If you would like to generate a new key, then click on the Add new function key button.
As per the preceding instruction, I have created the keys for the following applications:
-
WebApplication: The key name WebApplication is configured to be used in the website that uses the Azure Function
-
MobileApplication: The key name MobileApplication is configured to be used in the mobile app that uses the Azure Function
In a similar way, you can create different keys for any other app (such as an IoT application) depending on your requirements.
The idea behind having different keys for the same function is to have control over the access permissions to the usage of the functions by different applications. For example, if you would like to revoke the permissions only to one application but not for all applications, then you would just delete (or revoke) that key. In that way, you are not impacting other applications that are using the same function.
Here is the downside of the function keys; if you are developing an application where you need to have multiple functions and each function is being used by multiple applications, then you will end up having many keys. Managing these keys and documenting them would be a nightmare. In that case, you can go with host keys, which are discussed next.