Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filters for Azure Functions

Is it possible to have Filters (Auth or Exception) for Azure functions? I just want to not duplicate code to validate bearer token in every function. I see that there is a filter concept in webjobs sdk. https://github.com/Azure/azure-webjobs-sdk/wiki/Function-Filters

I want to only validate the bearer token before executing any function. So if filters are not the best option then is there any other better way to handle this situation ?

like image 756
Venky Avatar asked Oct 18 '22 04:10

Venky


1 Answers

Depending on how feature rich you want your responses you could use function filtered but they are very limited at the moment until this issue has been completed - https://github.com/Azure/azure-webjobs-sdk/issues/1314

Alternatively, you could set up a pipeline in each of your functions so you could apply the same cross-cutting concern logic inside your function app. obviously this will be a lot more work but comes with a lot more flexibility.

Example - https://github.com/kevbite/AzureFunctions.GreenPipes

like image 72
Kevin Smith Avatar answered Nov 15 '22 09:11

Kevin Smith