-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Function Filters In v2.0.12050.0 (and above) #3401
Comments
@mayoatbm I'm not sure if it's well documented already, but it seems possible to add global filters to internal DI within custom Startup class Configure call:
It's working like a charm when building and running locally (bin\extensions.json is generated correctly and contains my custom Startup type). |
@ArtyomBaranovskiy Thanks for the heads up, that does work locally. @mathewc @paulbatum The situation with Function Filters doesn't look good in GA and going forward. We now get the obsolete warnings message below. We've built key parts of our function apps on Filters (e.g. Scope cleanup for DI as in Azure/azure-webjobs-sdk#1865 and Azure/azure-webjobs-sdk#1934) and we very much need the functionality they provide (being able to run code before and after function executions). Can you confirm that you'll be replacing this functionality and not removing it entirely? And what would the timeline be? |
We are not removing Filters - we applied Obsolete attribute to those APIs because unfortunately we didn't have time to finish the feature before we had to release the v3 SDK. The work remaining that we didn't have time to complete was to rationalize filters with all the new DI work that was done. I'm hoping we can get to this soon and finish the feature. See Azure/azure-webjobs-sdk#1284 for more details. |
@mathewc That's good news. The Obsolete warning was alarming because of how much we've built on filters. I would suggest adding this clarification somewhere in the release notes, function filter docs or even using a different annotation. Thanks! |
I’m looking to handle exceptions at a function app level for my http triggered azure functions similar to how it is done in dotnetcore apps with ‘ExceptionFilterAttribute’. My goal is to catch all uncaught exceptions in the application at a single place and prepare the http response for the error scenario. I see that there is ‘IFunctionExceptionFilter’ which has a method ‘OnExceptionAsync’. However I’m not sure how I can get the context in this method so that I can manipulate Response to provide the right error messages. Also I believe this can only be done at a function level and not at the function app level. I also came across the [ErrorHandler] attribute here. However I’m not sure how I can use it. OnException method in ExceptionFilterAttribute public override void OnException(ExceptionContext context) Get ErrorResponse method returns an object which implements IActionResult |
Can we get this feature implemented part of V3? This article https://social.msdn.microsoft.com/Forums/en-US/98a7c43a-eac1-42bf-9fcc-23e3e9fff34d/should-we-go-ahead-and-implement-functionfilters-in-azure-function-in-production?forum=AzureFunctions says we can go ahead and implement Azure Functions Filter with all the already implemented features. Warns only for the feature which is still in progress. Please clarrify! Thanks. |
I am looking for a confirmation as well. Can someone confirm this is threadsafe based on the following comment? |
+1 |
Hey folks,
How do we use global function filters in the newest version of the runtime?
We did this in the past by using the Config property on the ExtensionConfigContext to get the IExtensionRegistry service. That Config property is now gone and our code does not compile (much less run).
What are we missing?
The text was updated successfully, but these errors were encountered: